-
Notifications
You must be signed in to change notification settings - Fork 0
Search Product by Tags
Daniel Cronqvist edited this page Dec 11, 2020
·
3 revisions
Endpoint: https://co2.dcronqvist.se/products/search/tags
Example cURL POST:
$ curl -X POST -d '{ "tags": ["iron", "green"] }' -H "Content-Type: application/json" https://co2.dcronqvist.se/products/search/tags
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 tags
which is an array of strings.
{
"tags": ["list:str"],
}
On successfully specifying an array of tags which are of type str
, you will be met with a response of the following format. The field response
will contain an array of all the products that have all of the specified tags in the payload.
{
"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 are no products that have all of the tags specified in the payload, you will receive a 404 NOT FOUND
error.
{
"response": "No products found.",
"status_code": 404,
"status": "404 NOT FOUND"
}
If you receive a 400 BAD REQUEST
, you are either missing the field tags
or you have not specified the field tags
to be an array of strings.
{
"response": "ERROR: On key 'tags', expected 'str', got 'int'.",
"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