{"id":22468502,"url":"https://github.com/projectweekend/thpl-data-api","last_synced_at":"2025-03-27T15:45:03.115Z","repository":{"id":76097611,"uuid":"48387635","full_name":"projectweekend/THPL-Data-API","owner":"projectweekend","description":"Serving data from THPL-Data-Logger (https://github.com/projectweekend/THPL-Data-Logger)","archived":false,"fork":false,"pushed_at":"2015-12-28T03:43:44.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T19:29:43.714Z","etag":null,"topics":[],"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/projectweekend.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}},"created_at":"2015-12-21T18:31:50.000Z","updated_at":"2015-12-27T02:10:13.000Z","dependencies_parsed_at":"2023-03-03T02:46:11.528Z","dependency_job_id":null,"html_url":"https://github.com/projectweekend/THPL-Data-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/projectweekend%2FTHPL-Data-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FTHPL-Data-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FTHPL-Data-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectweekend%2FTHPL-Data-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/projectweekend","download_url":"https://codeload.github.com/projectweekend/THPL-Data-API/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245874179,"owners_count":20686717,"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":[],"created_at":"2024-12-06T11:17:00.133Z","updated_at":"2025-03-27T15:45:03.089Z","avatar_url":"https://github.com/projectweekend.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Serving data from THPL-Data-Logger (https://github.com/projectweekend/THPL-Data-Logger)\n\n\n\nEnvironment Variables\n====================\n\nThere are just a couple of configurations managed as environment variables. In the development environment, these are injected by Docker Compose and managed from an `env_file` specified in the `docker-compose.yml` file.\n\n* `THPL_API_DATABASE_URL` - This is the connection URL for the PostgreSQL database.\n* `API_KEY` - This is the API key for the `X-API-KEY` header.\n\n\n\nRunning Tests\n====================\n\nTests, with code coverage reporting can be ran with the following command:\n```\ndocker-compose run web nosetests -v --with-coverage --cover-package=app --cover-xml --cover-html\n```\n\n\nPull Docker Image\n====================\n\n```\ndocker pull projectweekend/thpl-data-api\n```\n\nRun using Docker Image\n====================\n\n```\ndocker run -it -p 5000:5000 -e API_KEY=whatever -e THPL_API_DATABASE_URL=postgres://user:password@dbhost:5432/dbname projectweekend/thpl-data-api\n```\n\n\nRoutes\n====================\n\n### Get a latest reading\n\n**GET:**\n```\n/v1/sensor/{sensor}\n```\n\n**Response:**\n```json\n{\n    \"id\": 272488,\n    \"sensor\": \"home\",\n    \"temp_f\": 71.0600,\n    \"temp_c\": 21.7000,\n    \"humidity\": 28.7000,\n    \"pressure\": 1003.7500,\n    \"luminosity\": 18.0000,\n    \"logged_at\": \"2015-12-28T03:31:42.800839\"\n}\n```\n\n**Status Codes:**\n* `200` if successful\n* `400` if invalid query parameters\n* `401` if invalid credentials\n* `404` if not found\n\n\n### Get a list of daily stats\n\n**GET:**\n```\n/v1/stats/daily/{sensor}\n```\n\n**Query Parameters:**\n\n* `start` - Start day - Example: `2015-12-19`\n* `end` - End day - Example: `2015-12-20`\n\n**Response:**\n```json\n[\n    {\n        \"id\": 7,\n        \"sensor\": \"home\",\n        \"day\": \"2015-12-21T00:00:00\",\n        \"avg_temp\": 73.3439,\n        \"avg_humidity\": 35.1585,\n        \"avg_pressure\": 982.4764,\n        \"min_temp\": 71.9600,\n        \"min_humidity\": 30.9000,\n        \"min_pressure\": 981.3000,\n        \"max_temp\": 75.9200,\n        \"max_humidity\": 37.9400,\n        \"max_pressure\": 984.2600\n    }\n]\n```\n\n**Status Codes:**\n* `200` if successful\n* `400` if invalid query parameters\n* `401` if invalid credentials\n* `404` if not found\n\n\n### Get a list of hourly stats\n\n**GET:**\n```\n/v1/stats/hourly/{sensor}\n```\n\n**Query Parameters:**\n\n* `start` - Start day - Example: `2015-12-19`\n* `end` - End day - Example: `2015-12-20`\n\n**Response:**\n```json\n[\n    {\n        \"id\": 107,\n        \"sensor\": \"home\",\n        \"hour\": \"2015-12-19T23:00:00\",\n        \"avg_temp\": 68.7323,\n        \"avg_humidity\": 19.4587,\n        \"avg_pressure\": 1004.5114,\n        \"min_temp\": 68.1800,\n        \"min_humidity\": 19.1000,\n        \"min_pressure\": 1004.3200,\n        \"max_temp\": 69.4400,\n        \"max_humidity\": 19.7100,\n        \"max_pressure\": 1004.7200\n    }\n]\n```\n\n**Status Codes:**\n* `200` if successful\n* `400` if invalid query parameters\n* `401` if invalid credentials\n* `404` if not found\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectweekend%2Fthpl-data-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprojectweekend%2Fthpl-data-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectweekend%2Fthpl-data-api/lists"}