flespi Calculators API

API for [flespi analytics](https://flespi.com/kb/analytics-reports-and-events-engine) management. The API allows you to define the rules for how to split messages stored by devices into intervals and what to calculate inside generated intervals. Analytics is intended to build your own report engine on top of it or to be used as a source of events for your software - e.g. to generate and handle notifications from flespi about certain changes associated with the device. [Calculators](https://flespi.com/kb/analytics-reports-and-events-engine#calculators) are primary entity in flespi analytics. You define all the calculation configuration math inside calculator and than [assign devices to calculator](https://flespi.com/kb/analytics-reports-and-events-engine#assigned-devices) to apply this math to device. Once assigned to calculator device performs initial intervals calculation followed by automatical intervals update in the background as soon as new device messages are received. Intervals are defined by [**intervals selectors**](https://flespi.com/kb/analytics-reports-and-events-engine#interval-selectors) configuration. Then [**counters**](https://flespi.com/kb/analytics-reports-and-events-engine#interval-counters) can be applied to each interval to calculate user-defined metrics (e.g. mileage, engine hours, or any other custom calculations) over device messages. In general with calculators you can detect almost everything that is hapenning with device. Including geofence enter/exit, inactivity and GPS/connection problems, extract trips, parkings, stops, engine hours and any other user-defined events and calculations. Be aware that whenever the [calculator configuration](https://flespi.com/kb/analytics-reports-and-events-engine#calculators) changes - or the geofences, assets or device metadata it uses change - the system will recalculate intervals for assigned devices within 'update_period' time and thus may modify them. You control such behaviour with 'update_onchange' field in calculator properties. Each device assigned to the calculator has a dedicated intervals storage. You can [control](https://flespi.com/kb/how-to-manage-device-storage) the size and duration of this storage with 'intervals_ttl' and 'intervals_rotate' fields in calculator properties. One of the possibilities to optimize your flespi storage utilization is to set shorter **messages_ttl** for device messages, say 30-90 days, and set large **intervals_ttl** up to 10 years to store calculated intervals data for a much longer period. Intervals aggregate dozens of messages and thus take up much less space. ###### Calculator intervals The generated interval message contains timestamp of its generation, interval begin/end times, duration, id and all calculated counters as properties. Interval ID is generated automatically and you use ID if you want to attach own properties to the interval. To attach to the interval your custom properties you use **PUT /gw/calcs/{calcs.selector}/devices/{calc.devices.selector}/intervals/{calc.device.intervals.selector}** API call with corresponding interval ID in 'calc.device.intervals.selector'. However you can not attach own properties with same names as counters defined for calculator or reserved names such as id, timestamp, begin, end, duration. Calculated intervals from the corresponding intervals storage you may retrieve via REST API with **GET /gw/calcs/{calcs.selector}/devices/{calc.devices.selector}/intervals/{calc.device.intervals.selector}** call. Or via MQTT. MQTT has two sets of topics: * **flespi/state/gw/calcs/{calc_id}/devices/{device_id}/+** - retained topic from which you can retrieve and catch updates of last or active interval that was calculated; * **flespi/interval/gw/calcs/{calc_id}/devices/{device_id}/+** - real-time only topic to which any update with device intervals are published - create, delete, update events as well as last interval activated and deactivated events; Maximum size of data inside each counter can not exceed 8 MiB. If it will be larger during interval generation the counter will reset to null and corresponding log message will be added to calculator logs (event_code = 614). Maximum total JSON size for the interval message can not exceed 16 MiB. If it will be larger during generation - calculated device will be disabled with the reason indicated in calculator logs (event_code = 615). ###### Calculator logs All log messages in calculators related to intervals contain specific 'reason_code' field which clarifies why this or that interval event happened. Same 'reason_code' value is attached to MQTT messages as a user property to understand the reason of this or that interval event. If there are multiple reasons for the event the system will show the reason with bigger code value. List of possible reason codes: Reason code | Description -----|------ 2|timeout waiting for new data 5|referenced information has changed, e.g. intervals from referenced calculator 10|interval modified via REST API 20|received new message from device 30|asset interval update 47|calculator assigned assets change 48|calculator geofences change 49|device metadata change 50|calculator configuration change 90|automatic recalculation due to assigned device properties change 95|recalculation due to internal reason 100|initial automatic calculation 200|manual (forced) synchronization request via REST API 250|calculated device is disabled

GitHub OpenAPI

Operations 29

POST /calcs Create calculator configuration #
DELETE /calcs/{calcs.selector} Delete calculator and all calculated intervals from assigned devices #
GET /calcs/{calcs.selector} Retrieve calculator configuration #
PATCH /calcs/{calcs.selector} Patch item properties #
PUT /calcs/{calcs.selector} Update calculator configuration #
DELETE /calcs/{calcs.selector}/assets/{calc.assets.selector} Unassign assets from calc #
GET /calcs/{calcs.selector}/assets/{calc.assets.selector} Retrieve assets in calc #
POST /calcs/{calcs.selector}/assets/{calc.assets.selector} Assign assets to calc #
PUT /calcs/{calcs.selector}/assets/{calc.assets.selector} Modify asset data for calc #
DELETE /calcs/{calcs.selector}/devices/{calc.devices.selector} Unassign device from calculator #
GET /calcs/{calcs.selector}/devices/{calc.devices.selector} List devices assigned to calculator #
PUT /calcs/{calcs.selector}/devices/{calc.devices.selector} Modify configuration of device assignment to calculator #
POST /calcs/{calcs.selector}/devices/{calc.devices.selector}/calculate Split calculated intervals on a higher level intervals #
GET /calcs/{calcs.selector}/devices/{calc.devices.selector}/intervals/calculate Split calculated intervals on a higher level intervals #
PUT /calcs/{calcs.selector}/devices/{calc.devices.selector}/intervals/{calc.device.intervals.selector.put} Attach custom parameters to calculated device interval #
GET /calcs/{calcs.selector}/devices/{calc.devices.selector}/intervals/{calc.device.intervals.selector} Retrieve calculated device intervals #
POST /calcs/{calcs.selector}/devices/{calc.devices.selector}/recalculate Recalculate assigned device intervals #
POST /calcs/{calcs.selector}/devices/{dev-selector} Assign devices to calculator #
DELETE /calcs/{calcs.selector}/geofences/{calc.geofences.selector} Unassign geofences from calc #
GET /calcs/{calcs.selector}/geofences/{calc.geofences.selector} Retrieve geofences in calc #
POST /calcs/{calcs.selector}/geofences/{calc.geofences.selector} Assign geofences to calc #
PUT /calcs/{calcs.selector}/geofences/{calc.geofences.selector} Modify geofence data for calc #
DELETE /calcs/{calcs.selector}/groups/{calc.groups.selector} Unassign a group from calculator #
GET /calcs/{calcs.selector}/groups/{calc.groups.selector} Fetch groups assigned to the calculator #
POST /calcs/{calcs.selector}/groups/{calc.groups.selector} Assign a group of devices to a calculator #
PUT /calcs/{calcs.selector}/groups/{calc.groups.selector} Update assignment of group of devices to calculator #
GET /calcs/{calcs.selector}/logs Retrieve calculator logs #
GET /calcs/{calcs.selector}/logs/calculate Calculate intervals from calculator logs #
POST /calcs/{calcs.selector}/logs/calculate Calculate intervals from calculator logs #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/flespi:flespi-calculators-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

flespi-calculators-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: 'This API (full-stack API for telematics devices) provides methods to create and manage the following instances of the flespi telematics hub that jointly provide the end-to-end communication between the GPS trackers and your target application:

    * **channels** - inbound protocol-specific pipes where the raw data from the trackers get parsed and saved in the unified JSON format in the buffer for further consumption.

    * **devices** - virtual representations of the physical trackers on the flespi platform. Allow organizing messages storage by device (ident), remote device configuration, dedicated long-term storage, video telematics functionality, access to telemetry and much more.

    * **streams** - outbound data flows preformatted to forward the telematics data to specific target platforms (e.g. Google Pub/Sub, Amazon AWS IoT, Microsoft Azure IoT, and more).

    * **calculators** - sets of rules for detecting intervals and computing the associated values for them; integral prt of the flespi analytics engine.

    * **plugins** - allow extending the standard set of device parameters with additional ones required by specific platforms or applications, including copy of message into other devices, cancelling message registration and even enriching message parameters from your system via webhook.

    * **modems** - instance connecting the flespi platform with an SMS service provider for sending configurational text messages to change device settings.

    * **protocols** - access to the list of protocols, device types, available message parameters and commands.


    To identify each REST request flespi token has to be passed in the HTTP call via the header: **Authorization: FlespiToken XXXXXXXXXX**.

    The limit of URI component is 64 KiB.

    A request fails with 503 Service Unavailable when the server sends no response data for 300 seconds.


    All changes to the gateway items are recorded in the common logs subsystem.'
  title: flespi Telematics Hub REST Calculators API
  version: '1.0'
servers:
- url: https://flespi.io/gw
- url: http://flespi.io/gw
tags:


# --- truncated at 32 KB (224 KB total) ---
# Full source: https://artifacts.apis.io/flespi/openapi/flespi-calculators-api-openapi.yml