NOTE: Requires a subscription to X's, formerly Twitter, Basic or higher APIs to use.
This is an API that consumes Kenya Power's Tweets to check for scheduled/planned maintenance in Kenya. Information extracted includes the Region, County, Area, Specific places, time as well as date of the planned incidents. This API, consequently, makes the information publicly searchable, and analysable.
First, supply a .env file that will hold all configuration details to the application's root directory. Ensure all options and tokens are supplied as shown below (keys and tokens are generated from Twitter)
ENCODING = "utf-8"
API_KEY =
API_KEY_SECRET =
BEARER_TOKEN =
ACCESS_TOKEN =
ACCESS_TOKEN_SECRET =
SCREEN_NAME = "KenyaPower_Care"
TWEET_MODE = "extended"
TWEETS_COUNT = 1500
EXCLUDE_REPLIES = True
INCLUDE_RETWEETS = False
TIMEOUT = 120
POSTGRES_HOSTNAME =
POSTGRES_USER =
POSTGRES_PASSWORD =
POSTGRES_PORT = 5432
POSTGRES_DATABASE_NAME =
The application requires Tesseract-OCR to be installed and present in the path. Please review the Tesseract-OCR documentation for directions on how to configure for your environment.
Once all requisite configuration details are supplied accordingly, quickly run the project using docker and docker-compose:
$ docker-compose up -d
If docker is not available, you can run locally by activating the virtualenv as below, if on Windows
$ venv\Scripts\activate
$ python serve.py
or if on Linux
$ chmod +x init.sh
$ source/scripts/activate
$ init.sh
All endpoints can be accessed through localhost:8000/docs which is powered by Swagger UI as previewed below:
-/zohali/
init.sh
serve.py
README.md
docker-compose.yml
Dockerfile
requirements.txt
alembic.ini
nginx.conf
.dockerignore
.gitignore
-/api/
__ini__.py
auth.py
database.py
models.py
schemas.py
tasks.py
utils.py
-/app/
__init__.py
authenticators.py
exceptions.py
patterns.py
runner.py
tweetListeners.py
utils.py
-/images/
-/image_texts/
-/confs/
__init__.py
configs.py
-/migrations/
...
-/data/
db.sql
-/tests/
__init__.py
test_authenticator.py
test_tweet_listener.py
-/postman collection/
zohali.postman_collection.json