{"id":26348384,"url":"https://github.com/codeforafrica/sensors.africa-api","last_synced_at":"2025-03-16T08:14:44.990Z","repository":{"id":45123452,"uuid":"165050062","full_name":"CodeForAfrica/sensors.AFRICA-api","owner":"CodeForAfrica","description":"The sensors.AFRICA API receiving, storing, and processing data received from sensors across the continentent. Accessible at https://api.sensors.africa/","archived":false,"fork":false,"pushed_at":"2025-02-17T08:13:05.000Z","size":335,"stargazers_count":18,"open_issues_count":13,"forks_count":6,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-04T08:02:13.945Z","etag":null,"topics":["africa","air-quality","air-quality-data","api-rest","code-for-africa","django-rest-framework","open-data","sensor","sensors-africa","sensors-api","sensors-data"],"latest_commit_sha":null,"homepage":"https://api.sensors.africa/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodeForAfrica.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-01-10T11:45:07.000Z","updated_at":"2025-02-17T08:13:07.000Z","dependencies_parsed_at":"2025-02-17T07:25:29.719Z","dependency_job_id":"5e284daf-f80a-45d2-a39c-75b6bcb55419","html_url":"https://github.com/CodeForAfrica/sensors.AFRICA-api","commit_stats":{"total_commits":121,"total_committers":7,"mean_commits":"17.285714285714285","dds":0.2727272727272727,"last_synced_commit":"d8d6abaaec02de54f07e7181138cbb4b603c12c1"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeForAfrica%2Fsensors.AFRICA-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeForAfrica%2Fsensors.AFRICA-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeForAfrica%2Fsensors.AFRICA-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeForAfrica%2Fsensors.AFRICA-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeForAfrica","download_url":"https://codeload.github.com/CodeForAfrica/sensors.AFRICA-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841191,"owners_count":20356446,"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":["africa","air-quality","air-quality-data","api-rest","code-for-africa","django-rest-framework","open-data","sensor","sensors-africa","sensors-api","sensors-data"],"created_at":"2025-03-16T08:14:44.396Z","updated_at":"2025-03-16T08:14:44.982Z","avatar_url":"https://github.com/CodeForAfrica.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sensors.AFRICA API\n\nAPI to save and access data from deployed sensors in cities all around Africa.\n\n## Documentation\n\nThe API is documented [here.](https://github.com/CodeForAfricaLabs/sensors.AFRICA-api/wiki/API-Documentation)\n\n## Development\n\nGitignore is standardized for this project using [gitignore.io](https://www.gitignore.io/) to support various development platforms.\nTo get the project up and running:\n\n- Clone this repo\n\n### Virtual environment\n\n- Use virtualenv to create your virtual environment; `virtualenv venv`\n- Activate the virtual environment; `source venv/bin/activate`\n- Install feinstaub; `pip install git+https://github.com/opendata-stuttgart/feinstaub-api`\n- Install the requirements; `pip install .`\n- Create a sensorsafrica database with the following sql script:\n\n```sql\nCREATE DATABASE sensorsafrica;\nCREATE USER sensorsafrica WITH ENCRYPTED PASSWORD 'sensorsafrica';\nGRANT ALL PRIVILEGES ON DATABASE sensorsafrica TO sensorsafrica;\n```\n\n- Migrate the database; `python manage.py migrate`\n- Run the server; `python manage.py runserver`\n- Create super user for admin login; `python manage.py createsuperuser`\n\n  username: `\u003cusername\u003e`\n  email: blank\n  password: `\u003cpassword\u003e`\n\n### Docker\n\nUsing docker compose:\n\n- Create a `.env` file using `.env.template` . ***docker-compose has some default values for these variables***\n- Build the project; `docker-compose build` or `make build`\n- Run the project; `docker-compose up -d` or `make up`\n\nDocker compose make commands:\n\n- `make build`\n- `make up` - run docker and detach\n- `make log` - tail logs\n- `make test` - run test\n- `make migrate` - migrate database\n- `make createsuperuser` - create a super user for admin\n- `make compilescss`\n- `make enter` - enter docker shell\n- `make django` - enter docker django shell\n\n**NOTE:**\n`docker-compose` is strictly for development and testing purposes.\nThe Dockerfile is written for production since dokku is being used and it will look for Dockerfile.\n\n### Tests\n\n- Virtual Environment; `pytest --pylama`\n- Docker; `docker-compose run api pytest --pylama`\n\n**NOTE:**\nIf entrypoint and start scripts are changed, make sure they have correct/required permissions since we don't grant permissions to the files using the Dockerfile.\nRun the commands:\n\n```bash\nchmod +x contrib/entrypoint.sh\nchmod +x contrib/start.sh\n```\n\n## Deployment\n\n### Dokku\n\nOn your local machine run:\n\n```bash\ngit remote add dokku dokku@dokku.me:sensorsafrica-api\ngit push dokku master\n```\n\nFor more information read [Deploying to Dokku](http://dokku.viewdocs.io/dokku/deployment/application-deployment/#deploying-to-dokku).\n\n### Cronjob\n\nThis project uses celery to create cronjobs and flower to monitor the cron jobs as a web admin.\nTo create your jobs, add the task to the `tasks.py` and `CELERY_BEAT_SCHEDULE` in `settings.py`.\n\nEverything starts automatically as setup in the `contrib/start.sh`:\n\n```bash\ncelery -A sensorsafrica beat -l info \u0026\u003e /src/logs/celery.log  \u0026\ncelery -A sensorsafrica worker -l info \u0026\u003e /src/logs/celery.log  \u0026\ncelery -A sensorsafrica flower --basic_auth=$SENSORSAFRICA_FLOWER_ADMIN_USERNAME:$SENSORSAFRICA_FLOWER_ADMIN_PASSWORD \u0026\u003e /src/logs/celery.log  \u0026\n```\n\nNote: If you run the project in the virtualenv you will have to start rabbitmq and pass that link to settings by the env variable `SENSORSAFRICA_RABBITMQ_URL`\n\n\n## Monitoring\n\n### Flower\n\nIt starts up in in the `contrib/start.sh`:\n\n```bash\n...\ncelery -A sensorsafrica flower --basic_auth=$SENSORSAFRICA_FLOWER_ADMIN_USERNAME:$SENSORSAFRICA_FLOWER_ADMIN_PASSWORD \u0026\u003e /src/logs/celery.log  \u0026\n```\n\n### Slack\n\nProvide channel webhook as an enivronment variable `SENSORSAFRICA_CELERY_SLACK_WEBHOOK`. The default options are used:\n\n```\nDEFAULT_OPTIONS = {\n    \"slack_beat_init_color\": \"#FFCC2B\",\n    \"slack_broker_connect_color\": \"#36A64F\",\n    \"slack_broker_disconnect_color\": \"#D00001\",\n    \"slack_celery_startup_color\": \"#FFCC2B\",\n    \"slack_celery_shutdown_color\": \"#660033\",\n    \"slack_task_prerun_color\": \"#D3D3D3\",\n    \"slack_task_success_color\": \"#36A64F\",\n    \"slack_task_failure_color\": \"#D00001\",\n    \"slack_request_timeout\": 1,\n    \"flower_base_url\": None,\n    \"show_celery_hostname\": False,\n    \"show_task_id\": True,\n    \"show_task_execution_time\": True,\n    \"show_task_args\": True,\n    \"show_task_kwargs\": True,\n    \"show_task_exception_info\": True,\n    \"show_task_return_value\": True,\n    \"show_task_prerun\": False,\n    \"show_startup\": True,\n    \"show_shutdown\": True,\n    \"show_beat\": True,\n    \"show_broker\": False,\n    \"use_fixed_width\": True,\n    \"include_tasks\": None,\n    \"exclude_tasks\": None,\n    \"failures_only\": False,\n    \"webhook\": None,\n    \"beat_schedule\": None,\n    \"beat_show_full_task_path\": False,\n}\n```\n\n### Sentry\n\nSet the enivronment variable `SENSORSAFRICA_SENTRY_DSN`.\n\n### Archiving\n\nArchives are sent to CKAN and require environment configuration:\n\n```\n- CKAN_ARCHIVE_API_KEY=..\n- CKAN_ARCHIVE_OWNER_ID=...\n- CKAN_ARCHIVE_URL=\u003curl that supports bulk uploads\u003e\n```\n\n## Contributing\n\n[opendata-stuttgart/feinstaub-api](https://github.com/opendata-stuttgart/feinstaub-api) prefer generating and applying migration to the database at the point of deployment (probably to reduce the number of changes to be applied).\nWe, on the other hand, prefer the Django recommended approach of creating and reviewing migration files at the development time, and then applying the same migration files to different environments; dev, staging and eventually production.\n\nHence, with any contribution, include both `sensors.AFRICA-api` and `opendata-stuttgart/feinstaub-api` migration files by running `python manage.py makemigrations` command before creating a PR.\n\n## License\n\nGNU GPLv3\n\nCopyright (C) 2018 Code for Africa\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforafrica%2Fsensors.africa-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeforafrica%2Fsensors.africa-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeforafrica%2Fsensors.africa-api/lists"}