Code Samples
For Developers
Terminal window
Terminal window
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.
List locations
Section titled “List locations”Retrieve all locations for the brand associated with your API key.
curl https://api.kynectlocal.com/v1/locations \ -H "X-API-Key: your-api-key"Node.js
Section titled “Node.js”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);Python
Section titled “Python”import osimport 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)Get a single location
Section titled “Get a single location”Retrieve the profile for one location by its ID.
curl https://api.kynectlocal.com/v1/locations/loc_abc123 \ -H "X-API-Key: your-api-key"Node.js
Section titled “Node.js”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);Python
Section titled “Python”import osimport 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)Handling rate limits
Section titled “Handling rate limits”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();}
// Usageconst { locations } = await apiFetch('/v1/locations');Related
Section titled “Related”- Authentication — API key format and storage
- Rate Limits — limit values and
Retry-Afterdetails - Errors — full error envelope reference
- API Reference — complete endpoint and response schema docs