Fuel Price
Overview
The Fuel Price RestAPI allows you to manage fuel price records within the Fleet Management system. You can create, retrieve, update, and delete fuel price data. This RestAPI supports filtering, sorting, and pagination to help manage large datasets efficiently.
No specific currency is used for the fuel price to keep the method as generic as possible. However, it is recommended that users apply the same currency consistently to ensure route cost calculations reflect reality as closely as possible.
Fuel Price Object Fields
Field | Type | Description |
---|---|---|
creationTimestamp | Integer | Timestamp when the fuel prices were created. |
dieselStandard | Float | Price per unit of standard diesel fuel. Default: 1.09 . |
dieselPremium | Float | Price per unit of premium diesel fuel. Default: 1.17 . |
gasolineStandard | Float | Price per unit of standard gasoline. Default: 1.07 . |
gasolinePremium | Float | Price per unit of premium gasoline. Default: 1.19 . |
electric | Float | Price per unit of electric charging (e.g., kWh). Default: 0.10 . |
lpg | Float | Price per unit of LPG fuel. Default: 0.55 . |
Endpoints
1. Create Fuel Price
Description: Adds a new fuel price record to the database.
- Method:
POST
- Endpoint:
/fuel-prices
- Headers:
Authorization: YOUR_API_KEY
Content-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/fuel-prices
- Returned error codes:
- Returned error codes:
Error Code | Description |
---|---|
200 Successful | Successful operation. |
400 Bad Request | Invalid input or missing required fields. |
401 Unauthorized | API key is missing or invalid. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
If the operation is successful, the Fuel Price
object will have its creationTimestamp
field populated. If the operation fails, an error code is returned, which can be interpreted as described in the Returned error codes section.
Example:
- Request Body:
{
"dieselStandard": 1.5,
"dieselPremium": 2,
"gasolineStandard": 1.51,
"gasolinePremium": 1.48,
"electric": 0.18,
"lpg": 0.6
}
- Response Body: (error code
200
)
{
"creationTimestamp": 1602684618476,
"dieselStandard": 1.5,
"dieselPremium": 2,
"gasolineStandard": 1.51,
"gasolinePremium": 1.48,
"electric": 0.18,
"lpg": 0.6
}
2. Get All Fuel Prices
Description: Get fuel prices. If no entry was previously added, the default values will be returned
-
Method:
GET
-
Endpoint:
/fuel-prices
-
Headers:
Authorization: YOUR_API_KEY
-
URL:
https://fleetmanagement.magiclaneapis.com/v1/fuel-prices
-
Returned error codes:
Error Code | Description |
---|---|
200 Successful | Successful operation. |
400 Bad Request | Invalid input or missing required fields. |
401 Unauthorized | API key is missing or invalid. |
404 Not Found | The fuel prices were not found. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
Example:
- Response Body: (error code
200
)
{
"creationTimestamp": 1602684618476,
"dieselStandard": 1.5,
"dieselPremium": 2,
"gasolineStandard": 1.51,
"gasolinePremium": 1.48,
"electric": 0.18,
"lpg": 0.6
}