Endpoint: /wp-json/apicloud/v1/products/list
Description
This API endpoint returns a list of products from the custom post type api_service. The endpoint fetches the published posts and includes details like the post ID, title, description (excerpt), and a custom field value for cost.
URL
GET /wp-json/apicloud/v1/products/list
Methods
- GET: Retrieves a list of products from the custom post type
api_service.
Query Parameters
None.
Response
The API will return a JSON array of products with the following structure:
jsonCopy[
{
"id": 123,
"name": "Product Name",
"description": "Product Description",
"cost": 199
},
{
"id": 124,
"name": "Another Product",
"description": "Another Product Description",
"cost": 299
}
]
Each product contains:
- id: The unique ID of the product.
- name: The title of the product (post title).
- description: The excerpt of the post, typically a short description of the product.
- cost: The custom field value
_api_service_cost(must be an integer).
Permissions
- The permission callback is set to
__return_true, meaning it allows access to anyone without authentication.Note: This can be changed to a more restrictive permission setup if necessary.
Response Codes
- 200 OK: Successfully returns the list of products.
- 400 Bad Request: If there is an issue with the query or data format.
- 500 Internal Server Error: If an error occurs in the backend or server.