API Documentation¶
Summary¶
Most requests require authentication; valid forms of authentication are described in Authentication.
Resource |
Operation |
Description |
|---|---|---|
Get the api version |
||
Weight |
Log new weight entry |
|
Update the given weight entry. |
||
Delete one weight entry. |
||
Get collection of weight measurements. |
Authentication¶
- LifeLogServer.auth.requireAuth(func=None, /, permissions=['ultimate'], userid_keyword='userid')[source]¶
In order to authenticated a particular user, you must provide one of that user’s tokens in the ‘token’ header.
Example:
curl --header 'token: XXX' --request GET --url 'https://lifelog.ivanjohnson.net/api/v1/weight/get?since=0&before=2000000000&limit=3000&offset=0'
At present there is no automatic way of obtaining an API token.
API Details¶
- GET /api_version¶
Returns the api version of the Life Log Server.
Example Request
curl --request GET --url https://lifelog.ivanjohnson.net/api_version
Example Response
HTTP/1.0 200 OK Content-Type: text/plain; charset=utf-8 0.4.0a0
- POST /api/v1/weight/entry¶
Add one new weight entry
Omitting any query string parameters results in undefined behavior.
Requires authentication (See Authentication).
- Query Parameters:
datetime – Integer number of seconds since the Unix epoch, representing the time the measurement was made at
weight – The recorded weight in kilograms
units – Specifies the units of measure for the weight parameter
- Status Codes:
201 Created – measurement created
400 Bad Request – possibly returned when missing parameters
422 Unprocessable Entity – possibly returned when provided date is in the future
- PUT /api/v1/weight/entry/(uuid: entryid)¶
Update the given weight entry.
Requires authentication (See Authentication).
- Query Parameters:
datetime – new datetime (optional)
weight – new weight (optional)
units – units for new weight (optional)
- Status Codes:
204 No Content – Success
- DELETE /api/v1/weight/entry/(uuid: entryid)¶
Delete one weight entry.
Requires authentication (See Authentication).
- Status Codes:
204 No Content – Success
422 Unprocessable Entity – provided entryid does not exist
- GET /api/v1/weight/batch¶
Get weight measurements for a given time range.
Omitting any query parameter results in undefined behavior.
Requires authentication (See Authentication).
The “format” parameter controls how the data is returned. The possibilities are:
“csv” (default): The data is returned as a csv text file with one row for each measurement. In order, the columns are:
the id of the entry
the time of the measurement
the recorded weight in kilograms
“scatter”: The data is returned as an image of a scatter plot.
This defines additional query string parameters:
time_format: the format string for dates (as defined by https://docs.python.org/3/library/datetime.html#datetime.datetime.strftime)
marker_size: proportional to the area of the marker (see the “s” parameter of https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.pyplot.scatter.html)
- Query Parameters:
since – Integer number of seconds since the Unix epoch; return only measurements occuring on or after this time
before – Integer number of seconds since the Unix epoch; return only measurements occuring before this time
limit – Maximum number of results to return. Behavior is undefined when strictly greater than 100.
offset – Instead of returning the start of the sorted list of results, start from this offset.
format – specifies how to represent the data
- Status Codes:
400 Bad Request – A required parameter is missing or a parameter is invalid
422 Unprocessable Entity – A required parameter is invalid