-
Notifications
You must be signed in to change notification settings - Fork 0
Search all Benchmarks for Product
Endpoint: https://co2.dcronqvist.se/benchmarks/get/all
Example cURL POST:
$ curl -d '{"product": "accumulator"}' -H "Content-Type: application/json" -X POST https://co2.dcronqvist.se/benchmarks/get/all
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.
{
"product": ["str"]
}
The field product
should contain the _id
field of a product in the database.
On successfully specifying an ID of a product that exists, you will be met with a response of the following format, where response
is an array of all the benchmarks ever created for that product. Be careful with this endpoint as the more benchmarks that are created for a product, the larger the array that is returned will be.
{
"response": [
{
"_id": "accumulator-2020-12-04-10:57:00",
"date": "2020-12-04",
"product": "accumulator",
"kg_per_unit": 0.43,
"unit": "litre",
"self_impact": {
"co2": 0.51,
"measurement_error": 0.06,
"energy_sources": [
"wind",
"nuclear"
]
},
"chain_impact": {
"co2": 5904.338,
"measurement_error": 0
},
"sub_products": [
{
"product": "iron-plate",
"transport": 7,
"unit_amount": 2
},
{
"product": "battery",
"transport": 108,
"unit_amount": 5
}
],
"latest_benchmark": true
}
],
"status_code": 200,
"status": "200 OK"
}
If you receive a 400 BAD REQUEST
, you either have missed a key or have specified a disallowed type for a specific key.
{
"response": "ERROR: Missing key 'product'",
"status_code": 400,
"status": "400 BAD REQUEST"
}
If you receive a 405 METHOD NOT ALLOWED
, you are trying to access this POST endpoint by using some other HTTP method than POST.
{
"response": null,
"status": "405 METHOD NOT ALLOWED",
"status_code": 405
}
- 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