ashraffouda / btc_exchange_rate

this is a django project for fetching BTC/USD exchange rate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

btc_exchange_rate

this is a django project for fetching BTC/USD exchange rate

Project Structure

The project consists of two main parts

  • Django project the Django part has two main functions
    • Cron Job which fetches the exchange rate for BTC/USD from alphavantage API every hour and saves it to the postgres database
    • API Endpoints
      • GET /api/v1/quotes fetches the latest exchange rate save in database
      • POST /api/v1/quotes which forces getting the realtime exchange rate from alphavantage API and saves it in the database
  • Postgres Database is the database where we save our models

Quick start

  • clone the project
git clone https://github.com/ashraffouda/btc_exchange_rate.git

The most easy/simple way to start is using docker-compose command find the .env.sample file and put your alphavantage token there then do and remove the .sample to be only .env and do the following from inside the root dir of the project which containing docker-compose.yaml

docker-compose up

then navigate to http://localhost:8000/admin and generate token the default username/password are admin/admin incase you didn't change them in .env you can use curl or http to interact with the api for example

  • To do GET /api/v1/quotes
sudo apt-get install httpie #if you are on ubuntu
http localhost:8000/api/v1/quotes/ 'Authorization: Token <token>' # replace <token> with your actual token

you should see something like this get request

  • To do POST /api/v1/quotes
sudo apt-get install httpie #if you are on ubuntu
http POST localhost:8000/api/v1/quotes/ 'Authorization: Token <token>' # replace <token> with your actual token

you should see something like this post request

or for sure you can use the browser to navigate to http://localhost:8000/api/v1/quotes and do the required stuff from the browser UI

Other options for deploying

you can build the docker image your self using the Dockerfile in the repo and do the required stuff exposing ports and stuff

Rebuild

In case for some reason you want to rebuild the whole stuff again from scratch

sudo rm -fr data && docker-compose up --build

Demo

Here is a demo showing things in action https://youtu.be/RQ7qMDKA-y0

About

this is a django project for fetching BTC/USD exchange rate

License:Apache License 2.0


Languages

Language:Python 94.2%Language:Shell 3.8%Language:Dockerfile 1.9%