Skip to main content
GuidesExamples

Fuel Price

Estimated reading time: 4 minutes

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.

Currency Note

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

FieldTypeDescription
creationTimestampIntegerTimestamp when the fuel prices were created.
dieselStandardFloatPrice per unit of standard diesel fuel. Default: 1.09.
dieselPremiumFloatPrice per unit of premium diesel fuel. Default: 1.17.
gasolineStandardFloatPrice per unit of standard gasoline. Default: 1.07.
gasolinePremiumFloatPrice per unit of premium gasoline. Default: 1.19.
electricFloatPrice per unit of electric charging (e.g., kWh). Default: 0.10.
lpgFloatPrice 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 CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase error occurred.
Note

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 CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
404 Not FoundThe fuel prices were not found.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase 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
}