Endpoint #
GET /wp-json/rtcl/v1/listings/{listing_id}
Description #
Fetch a single listing by ID with full details, including author info, store info, contact info, custom fields, and favorite status (for authenticated users only).
Request Headers #
| Header | Type | Required | Description |
|---|---|---|---|
X-API-KEY | string | ✅ Yes | API key stored in plugin settings. |
Authorization | string | Conditional | Required if you want is_favourite field populated. Format: Bearer <JWT> |
Content-Type | string | ✅ Yes | application/json |
URL Parameters #
| Parameter | Type | Required | Description |
|---|---|---|---|
listing_id | integer | ✅ Yes | ID of the listing to fetch. |
Example URL:
GET https://yourwebsite.com/wp-json/rtcl/v1/listings/401
Response Fields #
| Field | Type | Description |
|---|---|---|
listing_id | integer | Listing ID |
title | string | Listing title |
pricing_type | string | Price type (e.g., price) |
price | string | Price |
price_type | string | Fixed, range, or negotiable price |
categories | array | Array of category objects (term_id, name, slug) |
tags | array/boolean | Array of tags or false if none |
ad_type | string | Sell, rent, etc. |
status | string | Listing status (publish, draft, pending) |
images | array | URLs of listing images |
view_count | integer | Number of views |
badges | array | Array of badge flags (e.g., is-new, is-featured) |
contact | object | Contact information (phone, email, address, zipcode, website, whatsapp_number) |
store | object | Store details if the author has a store |
author | object | Author information including membership and store status |
is_favourite | boolean | Authenticated users only: true if the logged-in user has favorited this listing |
Behavior #
Authenticated User (JWT token sent and valid) #
- Field
is_favouriteis included. - Value is
trueif the logged-in user has favorited this listing, otherwisefalse.
Example Response (Authenticated):
{
"data": [
{
"listing_id": 401,
"title": "Demo Listing",
"price": "100",
"price_type": "fixed",
"categories": [
{ "term_id": 2, "name": "Apartments", "slug": "apartments" }
],
"status": "publish",
"images": ["https://example.com/images/listing1.jpg"],
"badges": ["is-new", "is-sell"],
"is_favourite": true,
"contact": {
"phone": "123456789",
"email": "contact@example.com",
"address": "Dhaka",
"zipcode": "1212",
"website": "https://www.example.com",
"whatsapp_number": "123456789"
},
"author": {
"id": 1,
"username": "demo_user",
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"pp_thumb_url": "https://gravatar.com/avatar/demo?s=80&d=mm",
"membership": {
"is_expired": false,
"remaining_ads": 10
},
"store": true
},
"store": {
"id": 386,
"title": "Demo Store",
"email": "store@example.com",
"phone": "+88012345678",
"address": "Dhaka, Bangladesh",
"logo_url": "https://example.com/logo.jpg"
}
}
],
"pagination": {
"total": 1,
"count": 1,
"per_page": 20,
"current_page": 1,
"total_pages": 1
}
}
Unauthenticated User (No JWT or invalid token) #
- Field
is_favouriteis either omitted orfalse. - All other listing data is returned as usual.
Example Response (Unauthenticated):
{
"data": [
{
"listing_id": 401,
"title": "Demo Listing",
"price": "100",
"price_type": "fixed",
"categories": [
{ "term_id": 2, "name": "Apartments", "slug": "apartments" }
],
"status": "publish",
"images": ["https://example.com/images/listing1.jpg"],
"badges": ["is-new", "is-sell"],
"is_favourite": false,
"contact": {
"phone": "123456789",
"email": "contact@example.com",
"address": "Dhaka",
"zipcode": "1212"
},
"author": { "id": 1, "username": "demo_user" },
"store": { "id": 386, "title": "Demo Store" }
}
]
}
cURL Example #
curl -X GET https://yourwebsite.com/wp-json/rtcl/v1/listings/401 \
-H "Content-Type: application/json" \
-H "X-API-KEY: your_api_key_here" \
-H "Authorization: Bearer your auth key"
Error Responses #
❌ API Access Disabled
Status: 403 Forbidden
{
"code": "DENIED_REST_API",
"message": "Denied api call",
"data": {
"status": 403
}
}
❌ Missing Authorization Header
Status: 401 Unauthorized
{
"status": "error",
"error": "MISSING_X_API_KEY_HEADER",
"code": "401",
"error_message": "X_API_KEY header not received. Either authorization header was not sent or it was removed by your server due to security reasons."
}
❌ Invalid Authorization Header
Status: 401 Unauthorized
{
"status": "error",
"error": "INVALID_API_KEY",
"code": "401",
"error_message": "Sorry, you are using invalid API Key."
}
❌ Listing Not Found
Status: 400 Bad Request
{
"status": "error",
"error": "BADREQUEST",
"code": "400",
"error_message": "Listing not found."
}
❌ Invalid Listing ID
Status: 400 Bad Request
{
"status": "error",
"error": "BADREQUEST",
"code": "400",
"error_message": "Listing not found."
}
Notes #
is_favouriteonly exists for authenticated users.- Sending JWT via
Authorization: Bearer <token>is required to populate this field. - All other fields (
author,store,contact,badges,categories) are available for everyone.