Listdom API Settings Menu Documentation
यह कंटेंट अभी तक आपकी भाषा में उपलब्ध नहीं है।
Listdom provides a RESTful API for developers to integrate its listing functionality into external applications and services. The API allows secure operations such as user authentication, retrieving listings, uploading images, and adding or updating listings programmatically. All requests require a valid API token, and many also require a user session token.
Main Variables
Section titled “Main Variables”- Base URL: The base endpoint for all calls is
https://your-site.com/wp-json/listdom/v1/. All endpoints below are relative to this base URL. - API Token (
lsd-tokenheader) (Required): An API authentication key that must be included in the headers of every request. You can manage tokens in Listdom > Settings > API. - User Token (
lsd-userheader): A session token for a logged-in user, required for user-specific actions (like adding a listing). This token is obtained by calling theLoginorRegisterendpoints. - Content Type: All requests and responses use JSON format (
Content-Type: application/json), except for file uploads which usemultipart/form-data. - Encoding for Credentials: For security, sensitive fields like passwords in the
LoginandRegisterendpoints must be Base64-encoded.
The Login API allows a user to authenticate and retrieve a session token.
- Endpoint:
POST /login - Description: Logs in a user with a username and password.
- Required Headers:
lsd-token(API token). - Request Body: JSON with the following fields:
username: The user’s username or email, Base64-encoded.password: The user’s password, Base64-encoded.
- Response: On success, returns an object with
success: 1, the user’sid, and atokenstring. This token must be sent as thelsd-userheader in subsequent requests.
One-Time Login Key (Optional)
Section titled “One-Time Login Key (Optional)”This mechanism allows for seamless web authentication from an external app.
- Generate Key:
POST /login/key(requireslsd-tokenandlsd-userheaders). Returns a one-time usekey. - Redirect Endpoint:
GET /login/redirect/{key}?redirect_url={URL}. Use this URL to log the user into the WordPress site in a browser. The key is single-use and expires after use.
Register
Section titled “Register”The Register API allows creating a new user account.
- Endpoint:
POST /register - Description: Registers a new user and returns a login token.
- Required Headers:
lsd-token. - Request Body: JSON with the following fields:
name: (Optional) The display name of the user, Base64-encoded.email: The user’s email address, Base64-encoded.password: The user’s chosen password, Base64-encoded.
- Response: On success, returns
success: 1, the new user’sid, and atoken. The user is effectively logged in via the API upon registration.
Languages
Section titled “Languages”Retrieves active language codes if a compatible multilingual plugin (WPML, Polylang) is active.
- Endpoint:
GET /languages - Required Headers:
lsd-token. - Response: An object containing
success: 1and alanguagesarray of language codes (e.g.,["en", "fr"]).
Taxonomies (Categories, Locations, etc.)
Section titled “Taxonomies (Categories, Locations, etc.)”These endpoints provide the terms for Listdom’s taxonomies.
- Endpoint:
GET /taxonomies/{taxonomy_slug} - Description: Fetches a hierarchical list of terms for a given taxonomy.
- Examples:
- Listing Categories:
GET /taxonomies/listdom-category - Listing Locations:
GET /taxonomies/listdom-location - Listing Tags:
GET /taxonomies/listdom-tag - Listing Features:
GET /taxonomies/listdom-feature
- Listing Categories:
- Required Headers:
lsd-token. - Response: An array of term objects, each containing fields like
id,name,slug,parent, and achildsarray for sub-terms. - Query Parameters: You can refine the query with parameters like
hide_empty=1(to exclude terms with no listings) andparent={id}(to fetch only children of a specific term).
Get Listings
Section titled “Get Listings”Search Listings
Section titled “Search Listings”Retrieves a list of public listings with support for filtering and pagination.
- Endpoint:
GET /search - Required Headers:
lsd-token. - Query Parameters:
- Text Search:
s={keyword} - Taxonomy Filters:
listdom-category[]={id},listdom-location[]={id}, etc. - Ordering:
orderby=title&order=ASC - Pagination:
page={number}andlimit={number}
- Text Search:
- Response: An object with
success: 1, alistingsarray, and apaginationobject.
Current User’s Listings
Section titled “Current User’s Listings”Retrieves listings belonging to the currently authenticated user.
- Endpoint:
GET /my-listings - Required Headers:
lsd-tokenandlsd-user. - Response: Returns all listings submitted by the user, regardless of status (including draft, pending, etc.).
Single Listing by ID
Section titled “Single Listing by ID”Retrieves the details of a specific listing.
- Endpoint:
GET /listings/{id} - Required Headers:
lsd-token. - Response: An object with
success: 1and alistingobject containing the listing’s full data. This action increments the listing’s view count.
User Profile
Section titled “User Profile”Get Logged-in User Information
Section titled “Get Logged-in User Information”- Endpoint:
GET /profile - Required Headers:
lsd-tokenandlsd-user. - Response: An object with
success: 1and auserobject containing profile data (ID, username, email, contact info, social links, roles, etc.).
Update Profile
Section titled “Update Profile”- Endpoint:
PUT /profile - Required Headers:
lsd-tokenandlsd-user. - Request Body: A JSON object with any of the profile fields you want to update (e.g.,
first_name,phone,description). - Response: The updated
userobject.
Listing Management
Section titled “Listing Management”Get Add Listing Form Fields
Section titled “Get Add Listing Form Fields”- Endpoint:
GET /listings/fields - Description: Returns a structured JSON object detailing all available sections and fields for the “Add Listing” form. This is useful for dynamically building a submission UI.
- Required Headers:
lsd-token.
Upload Image
Section titled “Upload Image”- Endpoint:
POST /images - Description: Uploads an image file to the WordPress media library and returns its attachment ID.
- Required Headers:
lsd-tokenandlsd-user. - Request: Must be a
multipart/form-datarequest with the file field namedimage. - Response: An object containing
success: 1and animageobject with theid,url, andthumbnail_url. Use thisidwhen adding/updating listings.
Add Listing
Section titled “Add Listing”- Endpoint:
POST /listings - Description: Creates a new listing.
- Required Headers:
lsd-tokenandlsd-user. - Request Body: A JSON object with listing data. At minimum,
titleandlisting_category(a valid category ID) are required. Other fields likecontent,taxonomies,featured_image(using an ID from the upload endpoint), andgallerycan be included. - Response: A confirmation
messageand the newly createdlistingobject. The listing status will bependingorpublishdepending on the user’s permissions.
Update Listing
Section titled “Update Listing”- Endpoint:
PUT /listings - Description: Edits an existing listing.
- Required Headers:
lsd-tokenand thelsd-usertoken of the listing owner or an admin. - Request Body: A JSON object containing the
idof the listing to update, plus any other fields you want to change. - Response: The updated
listingobject.
Deleting Listings
Section titled “Deleting Listings”- Trash Listing:
DELETE /listings/{id}/trash- Moves the listing to the trash (soft delete). - Delete Listing:
DELETE /listings/{id}- Permanently deletes the listing (hard delete). - Required Headers:
lsd-tokenandlsd-userof an authorized user.