Authentication
You'll need to authenticate your requests to access any of the endpoints in the OLX API. In this guide, we'll look at how authentication works.
To verify requests, we need a token. We can use the Login endpoint to obtain a Token.
POST/auth/login
Login
Login ednpoint.
Headers
- Name
Content-Type
- Type
- string
- Description
application/json
Required fields
- Name
username
- Type
- string
- Description
Username field can be 'username' or 'email'
- Name
password
- Type
- string
- Description
Password
- Name
device_name
- Type
- string
- Description
Device name ( api_integration )
Request
POST
/auth/logincurl https://api.olx.ba/auth/login \
-d username="test@olx.ba" \
-d password="password" \
-d device_name="integration"
Response
{
"token": "163|1bA8cqxhtoohFDROFAWYPGhkvYApzLpm2ojzD6Tc",
"user": {
"id": 1,
"type": "shop",
"email": "email@olx.ba",
"username": "OLX",
"first_name": "Svijet",
"last_name": "Kupoprodaje",
...
}
}
Requests with Bearer token
Example request with bearer token
curl https://api.olx.ba/me \
-H "Authorization: Bearer {token}"
Always keep your token safe and reset it if you suspect it has been compromised.
Requests with old tokens
If you don't have access to password you can use older tokens for authorization.
You need to send OLX-CLIENT-ID and OLX-CLIENT-TOKEN headers.
Example request with bearer token
curl https://api.olx.ba/me \
-H "OLX-CLIENT-ID: {client-id}"
-H "OLX-CLIENT-TOKEN: {client-token}"