-
Notifications
You must be signed in to change notification settings - Fork 0
Search Product by ID
Daniel Cronqvist edited this page Dec 11, 2020
·
4 revisions
Endpoint: https://co2.dcronqvist.se/products/search/id
Example cURL POST:
$ curl -X POST -d '{ "_id": ["accumulator", "steel-axe"] }' -H "Content-Type: application/json" https://co2.dcronqvist.se/products/search/id
The following rules are applied to all keys in the payload using the EPF as a sample:
- Keys with arrays of specified types specify which types that are allowed for that specific key.
- Keys with specific values only allow that specific value in the payload.
- Keys that contain objects are recursively checked using rule 1 and 2.
The payload should contain the field _id
which is an array of strings.
{
"_id": ["list:str"],
}
On successfully specifying an array of id's that exist in the database, you will receive an array of all the products with the specified id's.
{
"response": [ {
"_id": ["str"], # e.g. "IKEA-BILLY-5"
"type": "product", # will always be product
"tags": ["list"], # e.g. ["furniture", "shelf", "wood"]
"type_description": ["str"], # "Assembly"
"prod_name": ["str"], # e.g. "Billy Shelf"
}],
"status_code": 200,
"status": "200 OK"
}
If there were no found products for the specified id's, then you will be met a 404 NOT FOUND
.
{
"response": "No products found.",
"status_code": 404,
"status": "404 NOT FOUND"
}
If you receive a 400 BAD REQUEST
, you are either missing the field _id
or you have not specified the field _id
to be an array of strings.
{
"response": "ERROR: On key '_id', expected 'str', got 'float'.",
"status_code": 404,
"status": "404 NOT FOUND"
}
- Create Product
- Search Product by ID
- Search Product by Tags
- Get all tags used on Products
- Get all Product ID's
- Regex Search Product ID's
- Regex Search Product names