Get up and running with ZeroClick using the REST API. You’ll fetch personalized offers, render them, and track impressions.
Get Your API Key
- Visit the Developer Dashboard
- Sign up or log in
- Navigate to App API Keys → Create API Key
- Copy your key
For production, use server-side integration to keep keys secure.
1. Fetch Offers
Make a POST request to /api/v2/offers with your query:
const response = await fetch("https://zeroclick.dev/api/v2/offers", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-zc-api-key": "your-api-key" // Get from developer dashboard
},
body: JSON.stringify({
method: "server",
ipAddress: clientIpAddress, // required for server method
userAgent: clientUserAgent, // optional but recommended
query: "best running shoes",
limit: 3
})
});
const offers = await response.json();
console.log(offers);
Expected response:
[
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"title": "Nike Air Zoom Pegasus 40",
"subtitle": "Premium running shoe for daily training",
"content": "Responsive cushioning and breathable mesh upper...",
"cta": "Shop Now",
"clickUrl": "https://zero.click/1234...",
"imageUrl": "https://example.com/pegasus40.jpg",
"brand": {
"name": "Nike",
"url": "https://nike.com"
},
"price": {
"amount": "129.99",
"currency": "USD"
}
}
]
When calling from the browser, use method: "client". IP and User-Agent are extracted automatically from request headers.Using method: "client" requires a public API key, since the key will be exposed in client-side code. Create a public key in the Developer Dashboard. const response = await fetch("https://zeroclick.dev/api/v2/offers", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-zc-api-key": "your-public-api-key"
},
body: JSON.stringify({
method: "client",
query: "best running shoes",
limit: 3
})
});
2. Render Offers
Display the offers in your UI however you’d like:
offers.forEach(offer => {
const card = `
<div class="offer-card" data-offer-id="${offer.id}">
<img src="${offer.imageUrl}" alt="${offer.title}" />
<h3>${offer.title}</h3>
<p>${offer.content}</p>
<a href="${offer.clickUrl}" target="_blank">${offer.cta}</a>
<span class="price">${offer.price.currency} ${offer.price.amount}</span>
</div>
`;
document.querySelector('#offers').innerHTML += card;
});
3. Track Impressions
Call the impressions endpoint when offers are displayed:
// Track all displayed offers
await fetch("https://zeroclick.dev/api/v2/impressions", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
ids: offers.map(offer => offer.id)
})
});
Impression requests must originate from the end user’s device, not your server. Requests will be rate limited per IP.
What’s Next?
Troubleshooting
401 Unauthorized:
- Check that your API key is correct
- Verify you’re using the
x-zc-api-key header
Need help? Email developers@zeroclick.ai