-
Notifications
You must be signed in to change notification settings - Fork 0
Search Parent Benchmarks of Product
Endpoint: https://co2.dcronqvist.se/benchmarks/get/parents
Example cURL POST:
$ curl -d '{"product": "accumulator", "search": "latest"}' -H "Content-Type: application/json" -X POST http://localhost:5000/benchmarks/get/parents
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"],
"search": ["str"] # must be either "latest" or "all".
}
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 for the parents of the specified product. If you specified search: "latest"
, then the list of benchmarks that you receive will be the latest benchmarks for the parents. If you instead specify search: "all"
, you'll get all benchmarks for all parents.
{
"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 'search'",
"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