-
Notifications
You must be signed in to change notification settings - Fork 0
Search Transport by ID
Daniel Cronqvist edited this page Dec 11, 2020
·
1 revision
Endpoint: https://co2.dcronqvist.se/transports/search/id
Example cURL POST:
$ curl -X POST -d '{ "_id": [100, 2] }' -H "Content-Type: application/json" 127.0.0.1:5000/transports/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.
{
"_id": ["list:int"],
}
All of the transports that it finds based on the array of ID's you specified in the request, you get a response with an array of all the transports that it finds.
{
"response": [ {
"_id": 100,
"type": "transport",
"type_description": "train",
"impact": {
"co2_per_kg_km":0.005,
"measurement_error": 0.11,
"distance_travelled": 14000,
"energy_sources":["nuclear", "coal"]
},
"start_lat": 27.19,
"start_lon": 113.69,
"end_lat": 27.49,
"end_lon": 119.66,
"max_weight": 3219
} ],
"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 '_id'",
"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