Publishing adverts
How to publish adverts
Overview
Publishing adverts is probably the main reason you're here for. By now you should have a registered application, know how to make requests, authorize users, advert payload, and validations that need to be in place to sends us a successful request. Let's see how to publish an Advert.
Basic workflow
To publish an advert you need the following information:
- Advert data: The actual advert data (example below)
- Site URN: The URN of the site where you are publishing the advert (check here the available sites)
- Category URN: The category for your advert (check out the Taxonomy API)
- Attribute URNs: Attributes make your advert more complete (also available in the Taxonomy API)
Publish payload example
You use the example below to test it out (you can also find it on our API Reference or check Advert validation rules:
JSON
{
"title": "[qatest-mercury] Apartamento moderno em Cabanelas",
"description": "Imóvel em Cabanelas com boa luminosidade, mobilado, 2 casas de banho. Este anúncio é um teste, não deve ser considerado.",
"category_urn": "urn:concept:apartments-for-sale",
"contact": {
"name": "Joaquim Silva",
"phone": "918888888",
"email": "joaquim.silva@testmail.com",
"photo": "https://i.imgur.com/9Em2tky.png"
},
"price": {
"value": 123000,
"currency": "EUR"
},
"location": {
"lat": 41.573603,
"lon": -7.214126,
"exact": true
},
"images": [
{
"url": "https://i.imgur.com/WozSfdQg.jpg"
},
{
"url": "https://i.imgur.com/3YNg1bI.jpg"
}
],
"movie_url": "https://www.youtube.com/watch?v=2me2WO6C1J8",
"attributes": [
{
"urn": "urn:concept:area-m2",
"value": "110"
},
{
"urn": "urn:concept:price-negotiable",
"value": "urn:concept:yes"
},
{
"urn": "urn:concept:number-of-rooms",
"value": "urn:concept:3"
},
{
"urn": "urn:concept:characteristics",
"value": "urn:concept:alarm"
},
{
"urn": "urn:concept:characteristics",
"value": "urn:concept:central-heating"
}
],
"site_urn": "urn:site:imovirtualcom",
"custom_fields": {
"id": "123456",
"reference_id": "TEST1234"
}
}
Copied to clipboard
Making the API Request
Endpoint: POST https://api.olxgroup.com/advert/v1
With the payload saved in advert.json, the following request will publish the advert:
cURL
curl --location --request POST 'https://api.olxgroup.com/advert/v1'\
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: ' \
--header 'Authorization: Bearer ' \
--header 'User-Agent: '
--data-raw @advert.json \
Copied to clipboard
If all goes well, you should receive a Response with a 201 HTTP Status code, which looks like this:
JSON
{
"transaction_id": "74c6bfc9-4163-11e8-a4a5-aff93b12a0c2",
"message": "Data is valid",
"data": {
"uuid": "b195bdbc-9074-4bac-99a1-7248c0c98892",
"last_action_status": "TO_POST"
}
}
Copied to clipboard
Great, you're almost there! To check if the request was successful, prepare the Webhook/Notification URL to handle notifications. Learn more about webhooks here.