Agriaffaires API: from a typed fragment to a page of matches
A search box can go from a few typed letters to a page of results:
- Send the letters typed so far as
body.querytoagriaffaires-suggest; it answers with matching free-text phrases and categories, each with a count. - Pick a suggested phrase and send it as
body.querytoagriaffaires-search, or pick a suggested category and send its id asbody.category_idinstead. - Add
body.siteandbody.marketto read the right catalogue and host for the user.
body.category_id also takes rubric_id or tree_id as alternative names, and sending it together with other filters costs one extra request, because this operation resolves the category alone before adding the rest.
Paging a large search result set
agriaffaires-search returns 50 rows per body.page, up to page 200:
- Start at
body.page1 and read the rows returned. - Raise
body.pageby one on the next call, keeping every other field identical, since changing any of them starts a different result list. - Stop once
body.pagereaches 200; a page past that ceiling is rejected rather than quietly repeating page 1, so a loop should stop at the documented cap instead of relying on an empty page.
Narrowing with body.category_id, body.manufacturer_id, body.year_min, body.year_max, body.price_min or body.price_max reaches further into a large result set than paging alone, because these filters bite hard: one measured chain of filters took a result set from the tens of thousands down to under a thousand rows.
Resolving ids before filtering a search
Several agriaffaires-search filters take an id rather than a name, and the safe way to get each one is a dedicated lookup rather than a guess:
- Call
agriaffaires-facetsfor the query or category you plan to search, and readmanufacturer_idfrom itsmakeentries rather than resolvingbody.manufacturerby name on every call. - Call
agriaffaires-locationswithbody.countryfor that country's regions, and again withbody.region_idfor a region's departments. - Use the ids this operation hands back, because an id it does not recognise still answers with a different, wrong result set rather than an error.
body.manufacturer_id is a global id, so one taken from any agriaffaires-facets call works in any other query on the same site.
From a search row to full listing detail
A listing shown as a compact row can be read in full with one further call:
- Take the
listing_idof the row that interests you fromagriaffaires-search. - Send it as
body.listing_idtoagriaffaires-detail, with the samebody.siteandbody.marketthe search used. - Read
specsfor the seller's spec table,price_witnessfor the price cross-check, andsellerfor the business or private party behind the advert.
Keeping the same body.site matters, because a listing_id from one catalogue does not exist on the other, and keeping the same body.market keeps the labels in the language the row was already read in.
Watching the price observatory for one make, model and year
The price observatory is reached in steps, because it only answers a price band once it has enough to go on:
- Call
agriaffaires-price-indexwith no parameters for its rubric list. - Send that rubric's
body.rubric_idfor its list of makes. - Send
body.rubric_idandbody.make_idtogether for its list of models. - Send
body.modelandbody.yearon top of both ids for the price band itself:price_min,price_max,price_averageand how many classified listings the figure rests on.
body.model has to match the spelling the observatory's own model list uses for that make, which is exactly why step 3 exists: read the spelling from there rather than reusing the spelling a search row happens to show. These ids belong only to the price observatory; the body.rubric_id for a farm tractor and the body.make_id for a given brand are not the category_id or manufacturer_id the same brand carries on agriaffaires-search, and the observatory answers an empty result rather than an error when given the wrong one.
Tracking one dealer's stock over time
To follow what one dealer has for sale:
- Find the dealer's
dealer_idfromagriaffaires-dealers, filtered bybody.company, or from a row returned byagriaffaires-search. - Send that id as
body.dealer_idtoagriaffaires-dealer-listings, starting atbody.page1. - Raise
body.pagewhile rows keep returning, 50 to a page, up to the ceiling of 200 pages carried over fromagriaffaires-search; no dealer in the directory has come close to it. - Compare the
listing_idvalues between runs to tell a new advert from one that has already been seen.
account_id is accepted in place of body.dealer_id throughout.
Agriaffaires in brief
MB Diffusion runs both Agriaffaires and MachineryZone from France, as part of the Leboncoin group under Sweden's Schibsted since a reported November 2016 acquisition. Agriaffaires focuses on used and new agricultural machinery such as tractors and harvesting equipment, while MachineryZone covers construction, handling, transport and forestry machinery across many countries, including auctions and rentals. A machine's hour-meter reading, together with its age, condition, brand and market demand, is what buyers and sellers rely on to judge what a used machine is actually worth as it depreciates.
[
{
"body": {
"query": "tract",
"market": "fr"
}
},
{
"body": {
"query": "tracteur",
"market": "fr",
"page": 1
}
},
{
"body": {
"listing_id": "46952423",
"market": "fr"
}
}
]{
"body": {
"market": "fr",
"query": "tracteur",
"manufacturer_id": 7607,
"year_min": 2018,
"year_max": 2024,
"price_min": 30000,
"price_max": 90000,
"with_price_only": true
}
}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/agriaffaires/agriaffaires-categories' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"market":"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.
Agriaffaires API: machinery search, listings and dealers overview and prices · Read the API reference · Try it in the playground