Avito.ma API workflow: from topic to category search
A topic first becomes a category id, and the id then drives the search. Category names come back in French, so look for terms such as Immobilier or Véhicules, or set body.lang to ar to read Arabic names.
- Call
avito-ma-categoriesand find the node that matches the topic, for example a phone leaf or an apartment leaf. - Copy its
category_idintobody.categoryofavito-ma-search. - For a property leaf, also copy
search_ad_typeintobody.ad_type; otherwise the sale tree is searched. - Add
body.qwhen a keyword such as iphone is needed to narrow the category further. - Read the rows of
listings[]and keep eachlist_idfor the later steps.
A category id alone is enough to browse a section, so body.q stays optional. A leaf id gives a narrower result than a root id. The url_slug of a node shows the slug that Avito uses for that category in its own addresses.
Narrowing a search to a city, district and price band
City and district filters take slugs, so look them up before searching. A call to avito-ma-locations with a city name returns that city together with its districts.
- Call
avito-ma-locationswithbody.cityset to a name such as casablanca, and withbody.langset to ar when Arabic names are wanted. - Read the city
slugand theslugof the district insideareas[]. - Send them as
body.cityandbody.areatoavito-ma-search; a district needs its city. - Add
body.price_minandbody.price_maxfor a band in dirhams,body.seller_typefor private or professional sellers andbody.ad_optionsfor one ad flag.
Use ad_count from the city list to rank cities by their number of ads before deciding which ones to search. Project cards in projects[] come back without regard to body.area, so a district search can still return cards that lie outside that district.
Paging through Avito.ma search results
Paging moves through Avito's own result pages, so only body.page changes between calls and every other input stays fixed. The first page is the default, so a first request can leave body.page out.
- Send the first request, with
body.pageset to 1 or left out. - Store the
list_idof each row you have seen. - Increase
body.pageby one and repeat the same search. - Skip rows whose
list_idis already stored, because neighbouring pages of a changing feed repeat a row or two.
Project cards in projects[] sit apart from the ad rows, so deduplicate on the list_id of listings[] only. Plan the number of calls around Avito's own page size of about 35-38 rows, which no input changes.
Opening an ad from a search row
A search row carries just enough to choose an ad, and avito-ma-detail turns the choice into a detail record.
- Take
list_idorurlfrom the row ofavito-ma-search. - Send it to
avito-ma-detailasbody.list_idorbody.url. - Read
attributes[]: its rows depend on the vertical, so a car and an apartment expose differentlabelvalues. - Read
phonewhen a contact is needed; the field is null when Avito hides it.
A removed or expired ad comes back as not found, which tells a monitoring job that the ad has left Avito. A search row already carries the price, the attributes[] rows and the seller profile, so open the detail record only for ads that need videos[], vertical or has_hidden_phone.
Searching rentals, holiday lets and flat-shares
Rent and holiday searches reuse the property category ids, and body.ad_type decides which tree answers.
- Take the apartment leaf id from
avito-ma-categories. - Set
body.categoryto that id andbody.ad_typeto rent, holiday_rent or shared_rent. - Add
body.city, andbody.price_maxfor a ceiling in dirhams. - Check
ad_typeon each returned row: it echoes SELL, LET, VAC_RENT or CO_RENT.
A rent type needs a category, so a keyword-only search cannot be filtered by ad type. The same pattern covers cars, where category 2100 with rent is car rental.
Tracking asking prices over time
Price tracking repeats one fixed search and stores what each run returns.
- Fix the filters: a
body.category, abody.cityand a band frombody.price_mintobody.price_max. - Set
body.ad_optionsto has_price so that only ads that publish a price come back. - Store
list_id,price,currencyandposted_atfor each row. - Run the same search on a schedule and compare
pricefor the samelist_id;old_priceshows an earlier price of the ad.
Prices are in the currency the ads publish, the Moroccan dirham printed DH, and price_display keeps the string as the card prints it.
What is Avito.ma
Avito.ma publishes studies built from its own listings. A 2019 study of the Moroccan used-car market covered the most listed brands, the share of diesel cars, mileage and the average asking price in dirhams, and vehicles is the platform's top category.
A 2018 study of summer rentals ranked Marrakech third among the most sought-after cities, with listing counts, nightly price ranges and demand compared against supply.
[
{
"body": {
"lang": "fr"
}
},
{
"body": {
"category": 1010,
"ad_type": "rent",
"city": "casablanca",
"price_max": 8000
}
},
{
"body": {
"list_id": "56251043"
}
}
]{
"body": {
"q": "iphone",
"category": 5010,
"city": "casablanca",
"price_min": 1000,
"price_max": 2000,
"seller_type": "private",
"ad_options": "has_image",
"page": 1
}
}{
"body": {
"city": "casablanca",
"lang": "ar"
}
}Server-side request template
This server-side template shows authentication and request identity using the first operation of this API. Choose the operation for your use case and check its current availability and price on the API page. After a timeout, resend the unchanged request with the same Idempotency-Key.
The gateway request is always POST.
Use a JSON object with the documented path, query, headers and body locations; omit unused locations. input.headers is JSON data for the operation, not browser request headers. Do not put credentials here. Keep body arrays, scalar values and null as documented; omission is different from null.
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/avito-ma/avito-ma-categories' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"lang":"fr"}}'Integration checklist
- The API key is stored in a server-side secret manager and never sent to a browser.
- Each request carries its own Idempotency-Key, kept until the request has a final answer.
- The integration reads ok and error.code and handles each error code as the error table describes.
- An uncertain POST is inspected using its original identity, never blindly repeated with a new one.
- The operation’s current availability and price have been checked on its API page.
Avito.ma API overview and prices · Read the API reference · Try it in the playground