Show your stock on your website
The website stock API gives you the vehicles your company is selling: the active adverts of your company’s seller profiles on the marketplaces we read. Nothing else is reachable with it, and no filter reaches anyone else’s adverts.
By the end you have a list page with filters, a page for each vehicle, and a cache on your server that keeps you well inside the rate limit.
Set up
Section titled “Set up”-
Create one API key for the website on the API keys page of the AvtoPodatki app, with only the website stock permission (
integration.stock, shown in the app as Zaloga za spletno stran). -
Limit the key to your web server’s IP address (
allowed_ips), so the key works from nowhere else. -
Keep the key on your server, in its configuration, never in a page’s JavaScript:
.env AVTOPODATKI_KEY=ap_…
List your vehicles
Section titled “List your vehicles”GET /v1/integrations/stock/vehicles returns your vehicles, newest first, 50 a
page. Page with limit (up to 200) and offset; sort with sort
(first_seen_at, price, year or mileage_km). You get every vehicle class
unless you pass category.
curl "https://api.avtopodatki.si/v1/integrations/stock/vehicles?limit=20" \ -H "Authorization: Bearer $AVTOPODATKI_KEY"$ch = curl_init('https://api.avtopodatki.si/v1/integrations/stock/vehicles?limit=20');curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('AVTOPODATKI_KEY')],]);$vehicles = json_decode(curl_exec($ch), true);const res = await fetch('https://api.avtopodatki.si/v1/integrations/stock/vehicles?limit=20', { headers: { Authorization: `Bearer ${process.env.AVTOPODATKI_KEY}` },});const vehicles = await res.json();Build the filters
Section titled “Build the filters”Build your filters from GET /v1/integrations/stock/filter-values. It lists
only the makes, models, fuels and other values your stock has, with counts, and
the year, price and mileage ranges.
Pass the visitor’s current filters to it too: each field’s counts then follow
the other filters, so a dropdown keeps its choices. GET /count gives the
number of results for a set of filters, for a “Show 23 vehicles” button.
The class, fuel, gearbox, body, colour, drive, powertrain, emission class and
condition are codes (diesel, black), the same on every marketplace.
/filter-values gives each value’s label in Slovenian, English or Croatian
(lang=sl, en or hr). Show a vehicle’s values with those labels too.
The vehicle page
Section titled “The vehicle page”GET /v1/integrations/stock/vehicles/{vehicle_id} returns one vehicle with
everything its advert shows.
- Link by
vehicle_id. It stays the same when you take an advert down and post the car again, so your links keep working.idis the advert’s own id and changes with a repost; the detail takes it too. - A sold or withdrawn vehicle answers
404: show “no longer available”. description_htmlis ready to put on your page: only paragraphs, line breaks, lists and bold or italic text, with no links, images, styles or scripts.equipmentis the advert’s list, by group (Varnost,Udobje, …), in the marketplace’s own words and language. A group with nonameis a list the marketplace does not group. The detail also hasinterior,inspection_valid_until(YYYY-MM),co2_g_kmandconsumption_l_100km.imagesholds everything the advert shows, in its order. A YouTube link (youtube.comoryoutu.be) is a video: embed it as a video, not as an image.
Prices
Section titled “Prices”price is the advertised price. discount_price is a reduced price anyone can
pay, if there is one, and conditional_price one paid only on a condition
(price_condition, most often financing). A null price means the advert has
none, and price_note says why (call_for_price, negotiate). Pass
has_price=true to the list to leave those out.
Every field is described in the API reference, under
WebsiteVehicleDetail.
Cache on your server
Section titled “Cache on your server”Your stock changes a few times a day, and every answer carries an ETag and
Cache-Control: private, max-age=300.
-
Keep each answer for five minutes and serve your visitors from that copy.
-
After that, ask again with
If-None-Matchset to theETag. -
If nothing changed, the answer is an empty
304 Not Modified: keep your copy.
Don’t call the API once per visitor. The key’s rate limit (120 calls a minute
today) is sized for one server, and a busy page would hit it: 429, with a
Retry-After header.
When something goes wrong
Section titled “When something goes wrong”| Status | What to do |
|---|---|
401 |
No key, or not a valid one: check the key. |
403 |
The key lacks the integration, or the call came from an address the key does not allow. |
404 on a vehicle |
Sold, withdrawn or not yours: show “no longer available”. |
422 |
A filter value that does not exist. An unknown make names the nearest ones in detail. |
429 |
Too many calls: wait Retry-After seconds. |
A car you advertise but don’t see in the API is usually under a seller profile that is not linked to your company yet. Tell us which advert at info@avtopodatki.si, and we link it.