Skip to content

Code Samples

For Developers

Copy-ready examples for the most common KynectLocal API operations. All examples use https://api.kynectlocal.com as the base URL and X-API-Key for authentication.


Retrieve all locations for the brand associated with your API key.

Terminal window
curl https://api.kynectlocal.com/v1/locations \
-H "X-API-Key: your-api-key"
const res = await fetch('https://api.kynectlocal.com/v1/locations', {
headers: {
'X-API-Key': process.env.KYNECT_API_KEY,
},
});
if (!res.ok) {
const err = await res.json();
throw new Error(`${err.status} ${err.error}`);
}
const { locations } = await res.json();
console.log(locations);
import os
import requests
api_key = os.environ["KYNECT_API_KEY"]
response = requests.get(
"https://api.kynectlocal.com/v1/locations",
headers={"X-API-Key": api_key},
)
response.raise_for_status()
locations = response.json()["locations"]
print(locations)

Retrieve the profile for one location by its ID.

Terminal window
curl https://api.kynectlocal.com/v1/locations/loc_abc123 \
-H "X-API-Key: your-api-key"
const locationId = 'loc_abc123';
const res = await fetch(
`https://api.kynectlocal.com/v1/locations/${locationId}`,
{
headers: {
'X-API-Key': process.env.KYNECT_API_KEY,
},
}
);
if (!res.ok) {
const err = await res.json();
throw new Error(`${err.status} ${err.error}`);
}
const location = await res.json();
console.log(location);
import os
import requests
api_key = os.environ["KYNECT_API_KEY"]
location_id = "loc_abc123"
response = requests.get(
f"https://api.kynectlocal.com/v1/locations/{location_id}",
headers={"X-API-Key": api_key},
)
response.raise_for_status()
location = response.json()
print(location)

The examples above do not retry on 429. Here is a Node.js helper that reads Retry-After and retries automatically:

async function apiFetch(path, options = {}, retries = 3) {
const res = await fetch(`https://api.kynectlocal.com${path}`, {
...options,
headers: {
'X-API-Key': process.env.KYNECT_API_KEY,
...options.headers,
},
});
if (res.status === 429 && retries > 0) {
const wait = parseInt(res.headers.get('Retry-After') || '5', 10);
await new Promise(resolve => setTimeout(resolve, wait * 1000));
return apiFetch(path, options, retries - 1);
}
if (!res.ok) {
const err = await res.json();
throw new Error(`${err.status} ${err.error}`);
}
return res.json();
}
// Usage
const { locations } = await apiFetch('/v1/locations');