Preview changes locally and integrate with the API.
Prerequisite: Please ensure you have an up-to-date version of Node.js (v18 or higher) installed before proceeding.
Follow these steps to run and develop your Crafter project on your local machine.Step 1: Navigate to your project folder (where the .env.local file is located) and run the following command:
npm run dev
Once the local development server is started, a preview of your website will be accessible at http://localhost:3000.
By default, Next.js uses port 3000. You can use a different port by adding the --port flag. For example, to run the project on port 3333, use this command:
npm run dev -- --port 3333
If the port you specify is in use, the system will automatically try the next available port.
Crafter offers a powerful API for managing your server data and creating custom integrations. You can explore all API endpoints and models through the Swagger interface.
Detailed API Documentation
Visit the Swagger interface to see all API endpoints, required parameters, and response models.
For security reasons, the Origin header must be present in all requests sent to the Crafter API. The value of this header should be the address of the website making the request. Otherwise, your request will be rejected by the API.
When sending requests to the API, don’t forget to include your website_url value registered in the Crafter Admin Panel in the Origin header.
Below is an example API request using the POST method to check the validity of a license key. As seen in swagger, this endpoint verifies the correctness of the submitted key.
// Example: Request to validate license keyconst licenceKey = process.env.NEXT_PUBLIC_LICENCE_KEY;const websiteUrl = 'https://yoursiteaddress.com'; // Your own site addressfetch('https://api.crafter.net.tr/v1/website/key/verify', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Origin': websiteUrl }, body: JSON.stringify({ key: licenceKey })}).then(response => response.json()).then(data => { if (data.success) { console.log('License key successfully validated.'); } else { console.error('License key is invalid.'); }}).catch(error => { console.error('API Error:', error);});