A Django api to display items and their current up-to-date prices from different online retailers in one platform.

Overview

Price Tracker Backend

A Django api to display items and their current up-to-date prices from different online retailers in one platform. Utilizing scrapy to periodically scrape the latest prices from different online retailers. Store in a PostgreSQL database and make available via an API.

forthebadge made-with-python

Note: This project is a work in progress.

Setup Instructions / Installation

Getting Started

Prerequisites

  • Python and pip (I am currently using 3.9.7) Any version above 3.7 should work.
  • Git installed on your machine
  • Code editor/ IDE
  • PostgreSQL installed on your machine

Installation and Running the App

  1. Clone GitHub repository

    git clone 
  2. Change into the folder

    cd price_tracker_backend
  3. Create a virtual environment

    python3 -m venv venv 
    • Activate the virtual environment
    source ./bin/activate
  • If you are using pyenv:

    3a. Create a virtualenv

    pyenv virtualenv price_tracker_backend

    3b. Activate the virtualenv

    pyenv activate price_tracker_backend
  1. Create a .env file and add your credentials

    touch .env 
    

    OR Copy the included example

    cp .env-example .env 
    
  2. Create a PostgreSQL Database

    psql -U postgres
    
    • Create a database
    CREATE DATABASE price_tracker_db;
    
    • Create a user
    CREATE USER price_tracker_user WITH PASSWORD 'password';
    
    • Grant privileges to the user
    GRANT ALL PRIVILEGES ON DATABASE price_tracker_db TO price_tracker_user;
    
    • Exit the psql session
    \q
    
  3. Add your credentials to the .env file

    5a. export db credentials to your environment variables

    export DATABASE_URL=postgres://user:password@localhost:5432/price_tracker
    
  4. Migrate your database

    python manage.py migrate
  5. Install the required dependencies

    pip install -r requirements.txt
  6. Make the shell script executable

    chmod a+x ./run.sh
  7. Run the app

    ./run.sh

    app should be available on http://127.0.0.1:8081/

    OR run with python

    python manage.py runserver

To run the scrapy spider

 cd price_scraper 
 scrapy crawl jumia_spider

To Run Scrapd and use a web interface

cd price_scraper 
scrapyd

To run ScrapyRT and get a real time API

cd price_scraper 
scrapyrt
  • Test out the api:
 curl "http://localhost:9080/crawl.json?spider_name=jumia_spider&url=https://jumia.co.ke/"

Technologies used

  • Python-3.9.7
  • Django web framework
  • PostgreSQL
  • Scrapy
You might also like...
A Django-powered API with various utility apps / endpoints.
A Django-powered API with various utility apps / endpoints.

A Django-powered API Includes various utility apps / endpoints. Demos These web apps provide a frontend to the APIs in this project. Issue API Explore

Build a Backend REST API with Python & Django

Build a Backend REST API with Python & Django Skills Python Django djangorestframework Aws Git Use the below Git commands in the Windows Command Promp

A minimalistic manga reader for desktop built with React and Django
A minimalistic manga reader for desktop built with React and Django

smanga A minimalistic manga reader/server for serving local manga images on desktop browser. Provides a two-page view layout just as reading a physica

Generate Views, Serializers, and Urls for your Django Rest Framework application

DRF Generators Writing APIs can be boring and repetitive work. Don't write another CRUDdy view in Django Rest Framework. With DRF Generators, one simp

Web APIs for Django. 🎸
Web APIs for Django. 🎸

Django REST framework Awesome web-browsable Web APIs. Full documentation for the project is available at https://www.django-rest-framework.org/. Fundi

Django app for handling the server headers required for Cross-Origin Resource Sharing (CORS)

django-cors-headers A Django App that adds Cross-Origin Resource Sharing (CORS) headers to responses. This allows in-browser requests to your Django a

Authentication for Django Rest Framework

Dj-Rest-Auth Drop-in API endpoints for handling authentication securely in Django Rest Framework. Works especially well with SPAs (e.g React, Vue, Ang

Authentication Module for django rest auth

django-rest-knox Authentication Module for django rest auth Knox provides easy to use authentication for Django REST Framework The aim is to allow for

REST implementation of Django authentication system.
REST implementation of Django authentication system.

djoser REST implementation of Django authentication system. djoser library provides a set of Django Rest Framework views to handle basic actions such

Owner
Kennedy Ngugi Mwaura
Technical writer --> Python, Django, Flask, Docker,Vue and all things Tech. Backend Developer. Actively looking for remote opportunities
Kennedy Ngugi Mwaura
RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

RESTler is the first stateful REST API fuzzing tool for automatically testing cloud services through their REST APIs and finding security and reliability bugs in these services.

Microsoft 1.8k Jan 4, 2023
Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

?? Fast, Async-ready, Openapi, type hints based framework for building APIs

Vitaliy Kucheryaviy 3.8k Jan 4, 2023
Country-specific Django helpers, to use in Django Rest Framework

django-rest-localflavor Country-specific serializers fields, to Django Rest Framework Documentation (soon) The full documentation is at https://django

Gilson Filho 19 Aug 30, 2022
Django-rest-auth provides a set of REST API endpoints for Authentication and Registration

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

Tivix 2.4k Dec 29, 2022
BloodDonors: Built using Django REST Framework for the API backend and React for the frontend

BloodDonors By Daniel Yuan, Alex Tian, Aaron Pan, Jennifer Yuan As the pandemic raged, one of the side effects was an urgent shortage of blood donatio

Daniel Yuan 1 Oct 24, 2021
Django REST API with React BoilerPlate

This is a setup of Authentication and Registration Integrated with React.js inside the Django Templates for web apps

Faisal Nazik 91 Dec 30, 2022
JSON:API support for Django REST framework

JSON:API and Django REST framework Overview JSON:API support for Django REST framework Documentation: https://django-rest-framework-json-api.readthedo

null 1k Dec 27, 2022
simple api build with django rest framework

Django Rest API django-rest-framework Employees management simple API in this project wrote test suites for endpoints wrote simple doc string for clas

OMAR.A 1 Mar 31, 2022
Simple Crud Api With Django Rest Framework

SIMPLE CRUD API WITH DJANGO REST FRAMEWORK Django REST framework is a powerful and flexible toolkit for building Web APIs. Requirements Python 3.6 Dja

kibet hillary 1 May 3, 2022