Building a simple fake twitter rest api
prak_net- Django main project directorycore- This is the core module which used for putting models together.user- This app provides all the user related APIspost- This app provides all the post related APIs
- Please add API keys for Hunter and Clearbit -
fake_twitter/prak_net/settings.py - Create new python3.7 environment and install all dependencies from
requirements.txt
- I've created a bot script that tests the working of all APIs -
test_bot.py. You can use this to interact with it. - Run server in terminal 1 -
rm -rf db.sqlite3 && python manage.py makemigrations && python manage.py migrate && python manage.py runserver - In terminal 2, run -
test_bot.py
- Bot uploads all the data from
fake_twitter/bot/data/fake_twitter_test_data.json. And then performs operations mentioned in the assignment. - The
fake_twitter_test_data.jsoncontains dummy data for 9 different users. - You may want to add more data according to your need.
- There will be four files at the end -
all_users.json: This file contains output of/api/user/all/API. Which is not the complete information. For advance info collected from Clearbit, check file - 2.all_detailed_users.json: This file contains all the info we have collected on a user. This is file is created by querying -/api/user/<id>/API endpoint.all_posts.json: This file has minimum info regarding the posts created. Endpoint used -/api/post/all_detailed_posts.json: It contains all their is to a post. With all info on users that may have liked or disliked the post. Endpoint used -/api/post/<id>/
- The config that bot uses to operate can be found at -
fake_twitter/bot/config. - As there is limited data please consider following guidelines for assigning the values in
fake_twitter/bot/config/bot_config.json.
number_of_users <= 9,
max_posts_per_user <= 10,
max_likes_per_user <= 50
- The extreme cases are not tested, due to limitations on Clearbit's API usage. So, things might start breaking! :D
- Create Users (signup) :
/api/user/signup/(POST) - Login :
/api/user/login/(Returns the JWT token) (POST) - Get JWT token :
/api/user/login/(POST) - Renew JWT token :
/api/user/token/refresh/(POST) - Get Users list :
/api/user/all/(GET) - Get Details of a User :
/api/user/<id>/(GET) - Get Details of logged in user :
/api/user/me/(GET) - Create new post :
/api/post/(POST) - Show all the posts from all the users :
/api/post/(GET) - Show a post in detail :
/api/post/<id>/(GET) - Like a post :
/api/post/<id>/like/(PATCH) - Dislike a post :
/api/post/<id>/dislike/(PATCH) - Show posts made by current user :
/api/post/me/(GET)
- List of user emails -
anand@persistent.com
alex@clearbit.com
monaweng@google.com
miguelf@google.com
afried@google.com
kwalstra@google.com
bernardo.zamora@microsoft.com
sunil.kamath@microsoft.com
dmcmahon@microsoft.com
harrycal@microsoft.com
dana.scully@fbi.gov
lisa.fischer@cnn.com
sara.obrien@cnn.com
jeremy.herb@cnn.com
christopher.carbone@foxnews.com
suzanne.scott@foxnews.com
brian.wilson@foxnews.com
ashish.shetty@tcs.com