If you want to work with the Listdom API, you’ll need to copy an API token. To do this, go to Listdom → Settings → API tab and press the “Add token” button. You can insert a descriptive name for the generated token. Copy and use it wherever needed. This token is also needed for Android and iOS apps. To remove a token, press the trash can icon once; it will turn red. Press it again if you are sure you want to delete it to permanently remove the token. Do not remove a token if an application is using it because it will destroy the functionality of the application!
👉 The API is included in the Listdom Pro Add-on. You can upgrade to the Pro Add-on now to enjoy all of the features of the Listdom.
Main Variables
In this section, we will define some variables and in the API call, we use them.
LISTDOM_TOKEN: This is the token that you copy from API Tokens. MAIN_DOMAIN: YOUR_DOMAIN/wp-json/ USER_TOKEN: You will take this after login.
Login
With this API you can log in to WordPress.
POST: MAIN_DOMAIN/listdom/v1/login/ Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN} Request Body: {'username': BASE64_USERNAME, 'password': BASE64_PASSWORD} Response Body: {"success": 1, "id": USER_ID, "token": "SOMETHING"}
Then you need to keep the token as USER_TOKEN for future requests.
Register
With this API you can register to WordPress.
POST: MAIN_DOMAIN/listdom/v1/register
Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN}
Request Body: {'email': BASE64_EMAIL, 'password': BASE64_PASSWORD, 'name': BASE64_NAME}
Response Body: {"success": 1, "id": USER_ID, "token": "SOMETHING"}
Then you need to keep the token as USER_TOKEN for future requests.
Languages
If you are using WPML or Polylang plugins in WordPress you can take the languages from this API.
GET: MAIN_DOMAIN/listdom/v1/languages
Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN}
Request Body: {}
Response Body: {"success": 1,"languages": [...]}
//Then you can add the language code in the header:
{'Accept-Language': LANGUAGE_CODE}
Listdom Categories
Get Listdom categories with this API.
GET: MAIN_DOMAIN/listdom/v1/taxonomies/listdom-category Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN} Request Body: {} Response Body: {"success": 1,"terms": [...]}
Listdom Locations
Get Listdom locations with this API.
GET: MAIN_DOMAIN/listdom/v1/taxonomies/listdom-location Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN} Request Body: {} Response Body: {"success": 1,"terms": [...]}
Get Listdom Listings
Get Listdom listings with this API.
GET: MAIN_DOMAIN/listdom/v1/search?page=PAGE_NUMBER Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN} Request Body: {} Response Body: {"success": 1, "listings": [...], "pagination": {"found_listings": INT,"listings_per_page": INT,"total_pages": INT,"previous_page": INT,"current_page": INT,"next_page": INT}}
Get Logged-in User Information
Get Logged-in user information with this API.
GET: MAIN_DOMAIN/listdom/v1/profile Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN, 'lsd-user': USER_TOKEN} Request Body: {} Response Body: {"success": 1, "user": {"id": INT, "data": {...}, "media": {...}, "roles": [...], "capabilities": {...} }}
Get Add Listing Form Fields
Get add listing form fields with this API.
GET: MAIN_DOMAIN/listdom/v1/listings/fields Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN, 'lsd-user': USER_TOKEN} Request Body: {} Response Body: { "success": 1, "form": { "general": {"section": {"title": "General"},"fields": {"title": {...},"content": {...}}}, "category": {"section": {"title": "Category"}, "fields": {"category": {"key": "listing_category","method": "dropdown","label": "Category","values": [...],"required": true}}}, "locations": {"section": {"title": "Locations"},"fields": {"locations": {"key": "taxonomies[listdom-location]","method": "checkboxes","label": "Locations","values": [...],"required": false}}}, "labels": {"section": {"title": "Labels"},"fields": {"labels": {"key": "taxonomies[listdom-label]","method": "checkboxes","label": "Labels","values": [...],"required": false}}}, "price": { "section": {"title": "Price Options"}, "fields": { "currency": {"key": "currency","method": "dropdown","label": "Currency","values": {...},"required": false}, "price": {"key": "price","method": "text-input","label": "Price","required": false}, "price_max": {"key": "price_max","method": "text-input","label": "Price (Max)","required": false}, "price_after": {"key": "price_after","method": "text-input","label": "Price Description","required": false} } }, "contact": { "section": {"title": "Contact Details"}, "fields": { "email": {"key": "email","method": "email-input","label": "Email","placeholder": "Email","required": false}, "phone": {"key": "phone","method": "tel-input","label": "Phone","placeholder": "Phone","required": false}, "link": {"key": "link","method": "url-input","label": "Listing Link","placeholder": "http://anothersite.com/listing-page/","guide": "","required": false} } }, "gallery": { "section": {"title": "Gallery"}, "fields": { "gallery": {"key": "gallery[]","method": "file","label": "Gallery","required": false,"developer": "You should upload images and send an array of attachment IDs!"} } }, "attributes": { "section": {"title": "Attributes"}, "fields": { "44": {"key": "attributes[44]","method": "dropdown","label": "Manufacturer","values": {},"all_categories": "0","categories": [...],"required": false}, ... } }, } }
As you see each field has a key that you should use it when you want to call add listing API.
Upload Image
You can upload images with this API to use in the gallery or featured image.
POST: MAIN_DOMAIN/listdom/v1/images Request Header: {Accept: 'application/json', 'Content-Type': 'multipart/form-data', 'lsd-token': LISTDOM_TOKEN, 'lsd-user': USER_TOKEN} Request Body: {image: FILE} Response Body: {"success": 1, 'image': URL}
Add Listing
With this API you can add a listing.
POST: MAIN_DOMAIN/listdom/v1/listings Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN, 'lsd-user': USER_TOKEN} Request Body: {'title': TITLE, 'content': CONTENT, 'listing_category': CATEGORY, ...} //The request body should calculate based on the fields' keys Response Body: {"success": 1, ...}
Update Listing
With this API you can update a listing.
PUT: MAIN_DOMAIN/listdom/v1/listings Request Header: {Accept: 'application/json', 'Content-Type': 'application/json', 'lsd-token': LISTDOM_TOKEN, 'lsd-user': USER_TOKEN} Request Body: {'id': LISTING_ID, 'title': TITLE, 'content': CONTENT, 'listing_category': CATEGORY, ...} //The request body should calculate based on the fields' keys Response Body: {"success": 1, ...}