{"id":17082034,"url":"https://github.com/fakufaku/timeseries-api","last_synced_at":"2026-04-20T05:32:39.623Z","repository":{"id":142812205,"uuid":"112504369","full_name":"fakufaku/timeseries-api","owner":"fakufaku","description":"A dead simple API to store measurements taken with IoT devices such as ESP8266 or ESP32.","archived":false,"fork":false,"pushed_at":"2019-05-07T16:13:08.000Z","size":602,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T19:33:54.703Z","etag":null,"topics":["api","iot","python","simple","timeseries"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fakufaku.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-29T17:10:30.000Z","updated_at":"2019-12-12T12:18:16.000Z","dependencies_parsed_at":"2023-06-25T22:22:35.389Z","dependency_job_id":null,"html_url":"https://github.com/fakufaku/timeseries-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakufaku%2Ftimeseries-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakufaku%2Ftimeseries-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakufaku%2Ftimeseries-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fakufaku%2Ftimeseries-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fakufaku","download_url":"https://codeload.github.com/fakufaku/timeseries-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245106489,"owners_count":20561721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","iot","python","simple","timeseries"],"created_at":"2024-10-14T12:59:06.119Z","updated_at":"2026-04-20T05:32:34.594Z","avatar_url":"https://github.com/fakufaku.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Timeseries API\n==============\n\nA dead simple API to store time-series collected by IoT devices such as the\nESP8266 or the ESP32.\n\nBased on [flask](http://flask.pocoo.org/),\n[flask-restful](https://flask-restful.readthedocs.io/en/latest/), and\n[dataset](https://dataset.readthedocs.io/en/latest/index.html).\n\nSee the `clients` folder for some applications.\n\nEndpoints\n---------\n\n* `/series` (GET) gets all series metadata\n* `/series/new` (PUT) creates a new series\n* `/series/\u003cseries_id\u003e` (GET) gets all the points in one series\n* `/series/\u003cseries_id\u003e` (DELETE) deletes a series and all the points associated\n* `/point/new` (PUT) Creates new point\n* `/point/\u003cpoint_id\u003e` (GET) Display a point\n* `/point/\u003cpoint_id\u003e` (DELETE) Delete a point\n\n### Authentification\n\nAll PUT and DELETE endpoints need to be authentified. GET endpoints are not\nauthentified.\n\nThe authentification is designed for (very) small scale operations. The list of\nusers is maintained as a JSON file stored at `/etc/timeseries-api/users.json`\nwith the following structure.\n\n    {\n      \"this-is-a-long-string-used-as-a-token\" : {\n        \"name\" : \"Robin\",\n          \"id\" : 1\n      }\n    }\n\nThe file is intended to be maintained manually.\n\nExample\n-------\n\n    import requests, time\n\n    # The URL of the server running the api\n    url = 'https://www.mydatadump.org/api'\n\n    # The authentication token\n    # This can be stored in a file for example\n    auth_token = 'my-secret-authentication-token'\n\n    new_series = {\n            'desc': 'Temperature in Tokyo',\n            'device_desc': 'ESP32 with DS18B20 temperature sensor',\n            'device_id': '12:AB:CD:XY:ZU:57',\n            'token' : auth_token,\n            }\n\n    new_points = [\n            { 'fields': {'temp_C': 13}, },\n            { 'fields': {'temp_C': 13.5}, },\n            { 'fields': {'temp_C': 12.5}, },\n            ]\n\n    # Create a new timeseries. The creation timestamp is done server side\n    ret = requests.put(url + '/series/new', json=new_series)\n\n    if ret.ok:\n        series_id = ret.json()\n    else:\n        raise ValueError('{} {}'.format(ret.status_code, ret.text))\n\n    # Now add some points to the series\n    for point in new_points:\n        # add authentication token\n        point['token'] = auth_token\n\n        # add the series_id\n        point['series_id'] = series_id\n\n        ret = requests.put(url + '/point/new', json=point)\n\n        if not ret.ok:\n            raise ValueError('{} {}'.format(ret.status_code, ret.text))\n\n        # The points are also timestamped server side\n        time.sleep(5)\n\n    # Now we can get the data\n    # No authentication required for that\n    ret = requests.get(url + '/series/' + str(series_id))\n    data = ret.json()\n    print(data)\n\nThe API can be automatically tested.\n\n1. Start the api \n\n        python api.py\n\n2. Run the tests\n\n        python tests/test_api.py\n\n\nClients\n-------\n\nA number of API clients are available in the `clients` folder.\n\n* `plotjs`: This is a javascript plotting tool to allow online visualization in\n  a browser.\n* `python_viewer`: This is a python tool to list and display the timeseries in\n  the API.\n* `micropython_esp32`: This is a temperature logger using ESP32 and\n  micropython.\n\n\nServer Configuration\n--------------------\n\nThe full configuration of the Apache2 server is beyond the scope\nof this doc, but here are a few pointers to get started.\n\nI use Apache2 with WSGI and followed the instructions in the [Flask\ndoc](http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/) to get going.\n\nThe authentification relies on secret tokens that should be transmitted with\nthe data. This means that it is essential to use an SSL encrypted connection.\nI used [Let's encrypt](https://letsencrypt.org/) to get a free and official SSL\ncertificate. I used the automatic `certbot from EFF to install it and even\nsetup automatic renewal. They have very good\n[instructions](https://certbot.eff.org/).\n\nHere is the apache site configuration file I am using\n`/etc/apache2/sites-available/api.conf` for my website\n`data.robinscheibler.org`. I configured it so that all requests to port 80 are\nautomatically redirected to 443 to avoid any problems.\n\n    \u003cVirtualHost *:80\u003e\n        ServerName data.robinscheibler.org\n\n        WSGIDaemonProcess api user=www-data group=www-data threads=5\n        WSGIScriptAlias /api /var/www/api/api.wsgi\n\n        \u003cDirectory /var/www/api\u003e\n            WSGIProcessGroup api\n            WSGIApplicationGroup %{GLOBAL}\n            Require all granted\n        \u003c/Directory\u003e\n\n        RewriteEngine on\n        RewriteCond %{SERVER_NAME} =data.robinscheibler.org\n        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]\n    \u003c/VirtualHost\u003e\n\n    \u003cIfModule mod_ssl.c\u003e\n    \u003cVirtualHost *:443\u003e\n        ServerName data.robinscheibler.org\n\n        WSGIScriptAlias /api /var/www/api/api.wsgi\n\n        \u003cDirectory /var/www/api\u003e\n            WSGIProcessGroup api\n            WSGIApplicationGroup %{GLOBAL}\n            Require all granted\n        \u003c/Directory\u003e\n        SSLCertificateFile /etc/letsencrypt/live/data.robinscheibler.org/fullchain.pem\n        SSLCertificateKeyFile /etc/letsencrypt/live/data.robinscheibler.org/privkey.pem\n        Include /etc/letsencrypt/options-ssl-apache.conf\n    \u003c/VirtualHost\u003e\n    \u003c/IfModule\u003e\n\nAPI root folder permission\n--------------------------\n\nThe apache user needs to be able to read/write the database file for correct operation.\nOnce the file has been created, for example by runnint `tests/test_api.py`\n\n    chown -R www-data:www-data /var/www/api\n    chmod -R u+w /var/www/api\n\nLicense\n-------\n\nMIT License\n\nCopyright (c) 2017-2018 Robin Scheibler (fakufaku@gmail.com)\n\nSee `LICENSE` file for the notice.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffakufaku%2Ftimeseries-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffakufaku%2Ftimeseries-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffakufaku%2Ftimeseries-api/lists"}