SONetwork is a small RESTful API with the concept of a social network, where users can register and share posts that can be liked / disliked.
Used Technologies:
- Django Rest Framework 3.6.4 web framework
- Django Rest Framework JWT 1.11.0 as authentication mechanism
- Faker 0.8.3 for generating fake data
- SQLite
- Python 3.5 or upper
- Clone the repository and and
cd
into it
$ git clone [email protected]/dimmg/SONetwork.git
$ cd sonetwork
- Create a virtual environment and activate it
$ virtualenv -p python3 env
$ source env/bin/activate
- Install dependencies
(env) $ pip install -r requirements.txt
- Generate migrations and apply them
(env) $ python manage.py makemigrations
(env) $ python manage.py migrate
- Export the environment variables and run the server that will run by default on port
:8000
(env) $ HUNTER_API_KEY={{API_KEY}} CLEARBIT_API_KEY={{API_KEY}} python manage.py runserver
The result is a minimalistic RESTful API with the following features:
Authentication
- User login POST /api-token-auth/
Users Management
- User registration POST /api/users/
- User retrieval GET /api/users/
GET /api/users{id}
- User update PUT /api/users/{id}
PATCH /api/users/{id}
Posts Management
- Post creation POST /api/posts/
- Post retrieval GET /api/posts?author={id}
GET /api/posts/
- Post update PUT /api/posts/{id}
PATCH /api/posts/{id}
- Post deletion DELETE /api/posts/{id}
- Post like POST /api/posts/{id}/like
- Post dislike POST /api/posts/{id}/dislike
In order to run tests, execute the following command:
(env) $ python manage.py tests
To demonstrate that the API is properly working, there is a bot that creates Users, Posts and likes them randomly.
To populate the database entries do:
(env) $ cd /autobot
(env) $ python run.py