Skip to content

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.

  1. 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).

  2. Limit the key to your web server’s IP address (allowed_ips), so the key works from nowhere else.

  3. Keep the key on your server, in its configuration, never in a page’s JavaScript:

    .env
    AVTOPODATKI_KEY=ap_…

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.

Terminal window
curl "https://api.avtopodatki.si/v1/integrations/stock/vehicles?limit=20" \
-H "Authorization: Bearer $AVTOPODATKI_KEY"

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.

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. id is 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_html is ready to put on your page: only paragraphs, line breaks, lists and bold or italic text, with no links, images, styles or scripts.
  • equipment is the advert’s list, by group (Varnost, Udobje, …), in the marketplace’s own words and language. A group with no name is a list the marketplace does not group. The detail also has interior, inspection_valid_until (YYYY-MM), co2_g_km and consumption_l_100km.
  • images holds everything the advert shows, in its order. A YouTube link (youtube.com or youtu.be) is a video: embed it as a video, not as an image.

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.

Your stock changes a few times a day, and every answer carries an ETag and Cache-Control: private, max-age=300.

  1. Keep each answer for five minutes and serve your visitors from that copy.

  2. After that, ask again with If-None-Match set to the ETag.

  3. 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.

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.