Documentation menu

Requests and parameters

The Asense REST API v2 has one endpoint. Query parameters choose the table, the device, the time window and the shape of the response.

View as Markdown

Endpoint

GET https://api.semitronica.pt/asense/v2/

All parameters go in the query string. The API answers with JSON and allows calls from any web origin, so you can also call it from a browser page. The machine-readable description of this API is the OpenAPI 3.1 file.

Authentication

Send your API key in the x-api-key header on every request. Requests without a valid key are refused before they reach the data.

curl -H "x-api-key: $ASENSE_API_KEY" "https://api.semitronica.pt/asense/v2/?table_name=env&id=ASENSE00000005&start_time=1764547200000&end_time=1764633600000"

Required parameters

NameTypeDescription
table_namestringThe table to read: acc, gyr, ain, fft, data, env or connected. See the data model.
idstringDevice ID: ASENSE followed by eight digits, for example ASENSE00000005.
start_timeintegerStart of the window, as a Unix timestamp in milliseconds (UTC). Records at exactly this time are included.
end_timeintegerEnd of the window, in the same units. Records at exactly this time are included.

Paging and order

NameDefaultDescription
limit256The most stored records one response reads. For acc, gyr and ain a stored record is one packet of samples, so one page can hold many samples. A value that is not a whole number falls back to 256.
ascendingtrueSort by time, oldest first. Set false to get the newest records first. This works on data, env and connected only; other tables return 400.

When more records are left in the window, the response carries next_timestamp. Pagination shows how to use it in both directions.

Response shape

NameDefaultDescription
mergetrueJoins the stored packets into longer series. On acc, gyr and ain the whole page becomes one item. On fft the three axes of each UTC hour become one item with fft_x, fft_y and fft_z. On data and env records are never joined. Any value other than false counts as true.
output_formatmapLayout of every time or frequency series: map, tuple_array, dict_array, combined_tuple or combined_dict. An unknown value falls back to map. See output formats.
timestamps_onlyfalseOn data and env, returns only the list of record times in the window, with a count, and no readings. This list is never paged and ignores limit.

With merge=true, the fields seq, odr and scale are removed from every item, including data items. Set merge=false to keep them.

Timing corrections

These parameters apply to the high-rate tables acc, gyr and ain. The defaults give the best sample times, and most users never change them. Timing and accuracy explains what each one does.

NameDefaultDescription
auto_odrtrueSpaces the samples of each packet by the measured time since the previous packet, instead of the nominal output data rate. Only the value true turns it on.
enable_correctiondepends on the deviceRepairs single packets whose timestamp is out of step with its neighbours. It is on by default only for devices that need it.
sync_acc_gyrsame as enable_correctionOn gyr, aligns each gyroscope packet to the accelerometer packet recorded up to 200 ms before it.
load_prior_elementstrue when any correction above is onReads up to 3 seconds before start_time so the first packet of the window can be corrected too. Those extra packets are dropped before the response is sent.

Booleans and numbers

Booleans are the strings true and false. Times are whole milliseconds. Every time in a response is UTC: time in milliseconds, and datetime as an ISO 8601 string ending in Z.