itsarreguin / instagram-api

Django REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instagram API

Simple Instagram API clone built on Django.


Start up the project

The next steps are assistance to start using the instagram API clone.


Clone project repo

Clone the project using one of the next commands (using https or ssh).

git clone https://github.com/itsarreguin/instagram-api.git
git clone git@github.com:itsarreguin/instagram-api.git

Create a virtualenv

To create the Python virtual environment we will use the default python venv module.

python -m venv <virtualenv_name>

Virtualenv activation and deactivation

Activation on MacOS and Linux.

python source <virtualenv_name>/bin/activate

Activation on Windows using Powershell

python .\<vitualenv_name>\Scripts\activate

Deactivation

To defuse your virtualenv only use the next command, this works on the three operating systems.

deactivate

Installing dependencies

The project has the requirements folder and requirements.txt file, this last is just an extension of dev.txt file inside the requirements folder.

pip install -r requirements.txt

Run migrations

Before to start using the project run database migrations using the following command.

python manage.py migrate

Running the API

Once the dependencies are installed you can start running the API

python manage.py runserver

If the Django's default port is occupied on your computer change this in the same command

python manage.py runserver <port>

python manage.py runserver 8080

Create your superuser

If you wanna create an admin superuser run the next command and fill in all fields

python manage.py createsuperuser

After that, run the server again and visit admin site localhost:8000/admin/

Celery and RabbitMQ

The Instagram API project uses Celery and RabbitMQ to run background tasks, execute in new shell's the next commands

Running Celery

celery -A instagram.tasks:celery worker --loglevel=info -P threads

Add the broker url in your .env file

CELERY_BROKER_URL=amqp://localhost:5672

Running RabbitMQ

In my case, I use Docker to run a RabbitMQ instance using the following command

docker run --rm -it -p 5672:5672 rabbitmq

The previous command runs the latest version of RabbitMQ in Docker, when press Ctrl + C the container to be removed.

Using Redis for Celery

If you wanna use Redis to run tasks follow the next steps

  • Run a Redis docker container or install redis on your computer

    docker run --rm -it -p 6379:6379 redis
  • Add redis url in your .env file

    CELERY_BROKER_URL=redis://localhost:6379
    
  • Repeat the command to run Celery once again

Note: Redis client has already been included in this project

Dependencies links

  1. Django:

  2. Django REST Framework

  3. Celery:

  4. PyJWT

Credits

Made with <3 and code by <@itsarreguin>

Instagram is a Meta, Inc. trademark.

About

Django REST API

License:MIT License


Languages

Language:Python 99.1%Language:HTML 0.9%