Simple REST API based social network in Django. Implements User registration, JWT authentication, Posts and Likes.
- Open /tcapp/settings.py Add
HUNTER_API_KEY
andCLEARBIT_API_KEY
keys. - Set python path:
export PYTHONPATH=`pwd`
- Run migrations:
python manage.py migrate
- Start application
python manage.py runserver
POST users/signup
http://127.0.0.1:8000/social_network/users/signup/
BODY email: [email protected] password: test
Example Request:
curl --location --request POST "http://127.0.0.1:8000/social_network/users/signup/" \
--form "[email protected]" \
--form "password=test"
POST token
http://127.0.0.1:8000/social_network/token/
BODY email: [email protected] password: test
Example Request:
curl --location --request POST "http://127.0.0.1:8000/social_network/token/" \
--form "[email protected]" \
--form "password=test"
GET posts
http://127.0.0.1:8000/social_network/posts/
Example Request:
curl --location --request GET "http://127.0.0.1:8000/social_network/posts/"
POST posts
http://127.0.0.1:8000/social_network/posts/
Example Request:
curl --location --request POST "http://127.0.0.1:8000/social_network/posts/" \
--data "content=Lorem ipsum..."
GET posts/1
http://127.0.0.1:8000/social_network/posts/1
Example Request:
curl --location --request GET "http://127.0.0.1:8000/social_network/posts/1"
GET posts/1/like
http://127.0.0.1:8000/social_network/posts/1/like
Example Request:
curl --location --request GET "http://127.0.0.1:8000/social_network/posts/1/like"
GET posts/1/unlike
http://127.0.0.1:8000/social_network/posts/1/unlike
Example Request:
curl --location --request GET "http://127.0.0.1:8000/social_network/posts/1/unlike"
Bot settings are stored in bot_settings.yaml
:
base_url: 'http://127.0.0.1:8000/social_network/'
number_of_users: 3
max_posts_per_user: 3
max_likes_per_user: 4
- Set python path:
export PYTHONPATH=`pwd`
- Check bot options:
python bot.py --help
- Run bot to test API functionalities:
python bot.py [-s bot_settings.yaml]
It will create some users (number_of_users
) and random number of posts for each user but no more then max_posts_per_user
.
After sorting users by number of posts, Bot sends likes for other posts no more then max_likes_per_user
.