API Reference¶
REST Client¶
- class fuelog.FuelogClient(token, base_url='https://api.fuelog.app', timeout=30)[source]¶
Bases:
objectSynchronous client for the Fuelog REST API.
- Parameters:
Example:
client = FuelogClient(token="sk-...") vehicle_id = client.create_vehicle( CreateVehicleRequest( name="My Car", make="Toyota", model="Corolla", year="2022", fuel_type=FuelType.PETROL, ) )
- create_log(request)[source]¶
Create a new fuel log entry.
- Parameters:
request (CreateFuelLogRequest) – A
CreateFuelLogRequestwith the required fields.- Returns:
The newly created log’s ID string.
- Raises:
FuelogForbiddenError – If the token lacks the
write:logsscope.- Return type:
- update_log(log_id, request)[source]¶
Update an existing fuel log entry.
- Parameters:
log_id (str) – ID of the log to update.
request (UpdateFuelLogRequest) – Fields to update wrapped in
UpdateFuelLogRequest.
- Returns:
Trueon success.- Raises:
FuelogNotFoundError – If no log with
log_idexists.FuelogForbiddenError – If the token lacks the
write:logsscope.
- Return type:
- delete_log(log_id)[source]¶
Delete a fuel log entry.
- Parameters:
log_id (str) – ID of the log to delete.
- Returns:
Trueon success.- Raises:
FuelogNotFoundError – If no log with
log_idexists.FuelogForbiddenError – If the token lacks the
write:logsscope.
- Return type:
- create_vehicle(request)[source]¶
Register a new vehicle.
- Parameters:
request (CreateVehicleRequest) – A
CreateVehicleRequestwith the required fields.- Returns:
The newly created vehicle’s ID string.
- Raises:
FuelogForbiddenError – If the token lacks the
write:vehiclesscope.- Return type:
- update_vehicle(vehicle_id, request)[source]¶
Update an existing vehicle profile.
- Parameters:
vehicle_id (str) – ID of the vehicle to update.
request (UpdateVehicleRequest) – Fields to update wrapped in
UpdateVehicleRequest.
- Returns:
Trueon success.- Raises:
FuelogNotFoundError – If no vehicle with
vehicle_idexists.FuelogForbiddenError – If the token lacks the
write:vehiclesscope.
- Return type:
- delete_vehicle(vehicle_id)[source]¶
Delete a vehicle profile.
- Parameters:
vehicle_id (str) – ID of the vehicle to delete.
- Returns:
Trueon success.- Raises:
FuelogNotFoundError – If no vehicle with
vehicle_idexists.FuelogForbiddenError – If the token lacks the
write:vehiclesscope.
- Return type:
- get_analytics(vehicle_id=None, start_date=None, end_date=None)[source]¶
Retrieve aggregated fuel efficiency and cost statistics.
- Parameters:
- Returns:
An
AnalyticsStatsobject.- Return type:
MCP Client¶
- class fuelog.FuelogMCPClient(token, base_url='https://api.fuelog.app', timeout=30)[source]¶
Bases:
objectClient for the Fuelog MCP server at
/api/mcp.- Parameters:
- list_logs(limit=100, vehicle_id=None, start_date=None, end_date=None, brand=None)[source]¶
Invoke the
list_logsMCP tool.- Parameters:
- Returns:
- Return type:
- log_fuel(brand, cost, distance_km, fuel_amount_liters, currency=None, original_cost=None, exchange_rate=None, vehicle_id=None, timestamp=None, latitude=None, longitude=None)[source]¶
Invoke the
log_fuelMCP tool.Requires the
write:logsscope.- Returns:
- Return type:
- edit_fuel_log(log_id, brand=None, cost=None, distance_km=None, fuel_amount_liters=None, currency=None, original_cost=None, exchange_rate=None, vehicle_id=None)[source]¶
Invoke the
edit_fuel_logMCP tool.Requires the
write:logsscope.- Parameters:
log_id (str) – ID of the log entry to update.
- Returns:
- Return type:
- delete_fuel_log(log_id)[source]¶
Invoke the
delete_fuel_logMCP tool.Requires the
write:logsscope. Theconfirm: trueparameter is added automatically.- Parameters:
log_id (str) – ID of the log entry to permanently delete.
- Returns:
- Return type:
- list_vehicles(include_archived=False)[source]¶
Invoke the
list_vehiclesMCP tool.- Returns:
- Return type:
- add_vehicle(name, make, model, year, fuel_type, is_default=None)[source]¶
Invoke the
add_vehicleMCP tool.Requires the
write:vehiclesscope.- Returns:
- Return type:
- update_vehicle(vehicle_id, name=None, make=None, model=None, year=None, fuel_type=None, is_default=None, is_archived=None)[source]¶
Invoke the
update_vehicleMCP tool.Requires the
write:vehiclesscope.- Returns:
- Return type:
- get_analytics(vehicle_id=None, start_date=None, end_date=None)[source]¶
Invoke the
get_analyticsMCP tool.- Returns:
- Return type:
- compare_vehicles(vehicle_ids=None, start_date=None, end_date=None)[source]¶
Invoke the
compare_vehiclesMCP tool.- Returns:
- Return type:
- read_resource(uri)[source]¶
Read an MCP resource by its
fuelog://URI.Available resources: -
fuelog://logs-fuelog://logs/{id}-fuelog://vehicles-fuelog://vehicles/{id}-fuelog://analytics/summary-fuelog://analytics/monthly-fuelog://analytics/vehicles-fuelog://profile- Returns:
The parsed resource contents (dict or list).
- Return type:
- monthly_report(month, vehicle_id=None)[source]¶
Get the
monthly_reportprompt populated with data.- Parameters:
- Returns:
- Return type:
- trend_analysis(start_date, end_date, metric=None, vehicle_id=None)[source]¶
Get the
trend_analysisprompt populated with data.- Parameters:
start_date (str) – ISO 8601 start date.
end_date (str) – ISO 8601 end date.
metric (TrendMetric | str | None) – One of
kml,mpg,l100km, orcost.vehicle_id (str | None) – Optional vehicle scope.
- Returns:
- Return type:
- cost_optimization(period=None)[source]¶
Get the
cost_optimizationprompt populated with data.- Parameters:
period (CostOptimizationPeriod | str | None) – One of
last_month,last_quarter(default), orlast_year.- Returns:
- Return type:
Models¶
Fuel Logs¶
- class fuelog.FuelLog(id, brand=None, cost=None, distance_km=None, fuel_amount_liters=None, currency=None, original_cost=None, exchange_rate=None, vehicle_id=None, latitude=None, longitude=None, timestamp=None)[source]¶
Bases:
objectA single fuel log entry returned by the API.
All fields other than
idare optional because the GET endpoint returns whatever the server stored at creation time.
- class fuelog.CreateFuelLogRequest(brand, cost, distance_km, fuel_amount_liters, currency=None, original_cost=None, exchange_rate=None, vehicle_id=None, latitude=None, longitude=None, timestamp=None)[source]¶
Bases:
objectParameters required to create a new fuel log entry.
- class fuelog.UpdateFuelLogRequest(brand=None, cost=None, distance_km=None, fuel_amount_liters=None, currency=None, original_cost=None, exchange_rate=None, vehicle_id=None, latitude=None, longitude=None, timestamp=None)[source]¶
Bases:
objectParameters accepted when updating an existing fuel log entry.
All fields are optional — only non-
Nonefields are sent to the API.
Vehicles¶
- class fuelog.Vehicle(id, name=None, make=None, model=None, year=None, fuel_type=None, is_default=None, is_archived=None)[source]¶
Bases:
objectA vehicle profile returned by the API.
- class fuelog.CreateVehicleRequest(name, make, model, year, fuel_type, is_default=None)[source]¶
Bases:
objectParameters required to register a new vehicle.
Analytics¶
- class fuelog.AnalyticsStats(log_count=None, total_spent=None, home_currency=None, total_fuel_liters=None, total_distance_km=None, efficiency=None, avg_cost_per_liter=None, avg_cost_per_km=None, extra=<factory>)[source]¶
Bases:
objectAggregated analytics stats returned by
get_analytics().
MCP Results¶
- class fuelog.MCPToolResult(content, is_error=False)[source]¶
Bases:
objectResult returned by an MCP tool invocation.
Enumerations¶
- class fuelog.FuelType(*values)[source]¶
-
Fuel type accepted by the Fuelog API.
- PETROL = 'Petrol'¶
- DIESEL = 'Diesel'¶
- HYBRID = 'Hybrid'¶
- ELECTRIC = 'Electric'¶