This is a REST api made with django Rest Framework that tracks the prices of the products in daraz.com.np. This api uses Django Rest framework for serialization of input and output to transfer through the API endpoint.
It uses Celery-Beat in order to periodically update and track the prices of the products and flag them inactive if they're not tracked by any User. Redis server has been used as a backend for Celery worker.
Django-Rest-Knox has been used for authentication.
A Basic frontend implementation of this API: https://github.com/yubint/darazscrape-frontend
POST /api/login| key | Type | Description |
|---|---|---|
email |
string |
Required. Email of the User |
password |
string |
Required. Password |
POST /api/register| key | Type | Description |
|---|---|---|
email |
string |
Required. Email of the User |
password |
string |
Required. Password |
Authtoken are returned in response during Login or Registration. These need to be send as header in the following format
| key | value |
|---|---|
Authorization |
Token {Auth Token Provided in Response} |
So if the Authtoken is abcd then the value of Authorization should be Token abcd
Endpoints provided below require authorization through authtoken to be accessed.
POST /api/logout GET /api/user POST /api/products/create| key | Type | Description |
|---|---|---|
url |
string |
Required. Url of the Daraz Product to be added |
POST /api/products/delete | key | Type | Description |
|---|---|---|
productId |
integer |
Required. Product Id of the product being deleted |
{
id : userId,
email: userEmail,
products : [
{
id : productId,
title : productTitle,
url : productUrl,
image_url : productImageUrl,
prices: [
{ date : dateWhenThisPriceWasTracked,
price : price
},
...
]
},
...
]
}
{
expiry : expiryDateofToken,
token : authToken,
user : UserObject
} {
user : UserObject,
token : authToken
} {
id : productId,
title : productTitle,
url : productUrl,
image_url : productImageUrl,
prices: [
{ date : dateWhenThisPriceWasTracked,
price : price
},
...
]
}Clone the project
git clone https://github.com/yubint/darazscrape-apiGo to the project directory
cd darazscarape-apiInstall requirements.txt
pip install -r requirements.txtStart the Django server
python manage.py runserverStart redis server
sudo service redis-server startStart celery backend
celery -A backend worker -l INFOStart Celery Beat Scheduler
celery -A backend beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler