Request examples: server and browser
Every method page has examples for curl, Node.js, Python, PHP, and Go. Replace the service URL, identifiers, and field values with your own. Response examples are shortened; actual responses may include more fields.
Prepare the environment
Set BASE on your server to the API host URL without a trailing /api/v1, and set API_KEY to your key. Each example shows the variables it uses. Create a key on the API keys tab of Tokens. Read operations need no write permission.
Keep the key in environment variables or your server's secret store. Do not put it in a repository, URL, error message, or request log.
Node.js: server
The Node.js blocks run in a server process. Save an example as .mjs and run node example.mjs. They use the built-in fetch and require Node.js 22 or newer. process.env reads server environment variables.
JavaScript: browser
Node.js and browser JavaScript run in different environments. Never embed a persistent API key in browser code, including Vite build variables: visitors can inspect it.
The browser calls your server. Your server checks the user's identity and permissions before calling the Akmelo API with its key. For example, your interface could read a site list like this:
const response = await fetch('/integration/sites', {
credentials: 'same-origin',
headers: { Accept: 'application/json' },
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const sites = await response.json();
/integration/sites is a route in your application. Implement it behind your existing sign-in flow. On the server, use the GET /api/v1/sites example. Allow only the operations you need and check the user's rights. Do not create a general-purpose proxy that forwards arbitrary URLs with your key.
curl
Run it in a terminal. Set BASE and API_KEY before using the examples. JSON requests use Content-Type: application/json; file downloads save the response to a file. Avoid exposing a live key in shared command history or logs.
Python
Save the example as a .py file and run Python 3. It uses standard-library urllib.request; no extra package is needed. Unsuccessful HTTP responses raise HTTPError, whose body contains the API error.
PHP
Run PHP examples on your server with the cURL extension. This is external API integration code, not a collection algorithm inside Akmelo. Collection algorithms use $ctx methods described in the SDK section.
Go
Save the example as main.go and run go run main.go. It uses the Go standard library. Check the HTTP status before processing a response; the examples print the body to expose an error message.
Retries and errors
For 429, respect Retry-After. If the network breaks while creating a resource, first check whether it was created. Blindly retrying a POST may create a duplicate. Responses 401, 403, 404, and 422 call for checking the key, rights, ID, or parameters, not endless retries.