{"id":48924028,"url":"https://github.com/ebrahimakbari/api_price","last_synced_at":"2026-04-17T06:03:07.158Z","repository":{"id":315277721,"uuid":"1058809454","full_name":"Ebrahimakbari/API_PRICE","owner":"Ebrahimakbari","description":"RESTful API designed to fetch and manage real-time price data","archived":false,"fork":false,"pushed_at":"2025-10-06T19:06:57.000Z","size":1117,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-06T21:08:27.534Z","etag":null,"topics":["api","celery","django-rest-framework","docker-compose","scraping-websites"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ebrahimakbari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-17T15:20:10.000Z","updated_at":"2025-10-06T19:07:00.000Z","dependencies_parsed_at":"2025-09-19T17:39:56.416Z","dependency_job_id":null,"html_url":"https://github.com/Ebrahimakbari/API_PRICE","commit_stats":null,"previous_names":["ebrahimakbari/api_car","ebrahimakbari/api_price"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ebrahimakbari/API_PRICE","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebrahimakbari%2FAPI_PRICE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebrahimakbari%2FAPI_PRICE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebrahimakbari%2FAPI_PRICE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebrahimakbari%2FAPI_PRICE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ebrahimakbari","download_url":"https://codeload.github.com/Ebrahimakbari/API_PRICE/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ebrahimakbari%2FAPI_PRICE/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31917372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","celery","django-rest-framework","docker-compose","scraping-websites"],"created_at":"2026-04-17T06:03:04.687Z","updated_at":"2026-04-17T06:03:07.140Z","avatar_url":"https://github.com/Ebrahimakbari.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# API_PRICE\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python Version](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)\n\n## Description\n\nA public API to track the daily prices of cars, motorcycles, electronic-devices(like: mobiles, laptops, gadgets, ...) and financial assets like currencies and precious metals. This project periodically scrapes data from external sources, stores it, and exposes it through a clean, documented RESTful API.\n\nThe entire application is containerized with Docker for easy setup, development, and deployment.\n\n## Target Scraping APIs\n\n[Cars](https://khodro45.com/api/v1/pricing/dailycars/)\n\n[Motorcycles](https://bama.ir/mad/api/price/hierarchy)\n\n[Assets](https://call3.tgju.org/ajax.json)\n\n[Mobiles-List](https://api.digikala.com/v1/categories/mobile-phone/search/?page=1)\n\n[Console-List](https://api.digikala.com/v1/categories/station-gaming-consoles/search/?page={page})\n\n[Gadget-List](https://api.digikala.com/v1/categories/wearable-gadget/search/?page={page})\n\n[HeadPhone-List](https://api.digikala.com/v1/categories/headphone/search/?page={page})\n\n[PC-List](https://api.digikala.com/v1/categories/notebook-netbook-ultrabook/search/?page=20184035)\n\n[Personal-List](https://api.digikala.com/v1/categories/sexual-hygiene-health/search/?page=73186661)\n\n[Digital-devices-Detail](https://api.digikala.com/v2/product/19347047/)\n\n## Features\n\n  * **RESTful API**: Provides endpoints for cars, motorcycles, digital-devices(like: mobiles, laptops, gadgets, ...) and financial assets.\n  * **User Authentication**: Secure JWT-based authentication for user registration and login.\n  * **Automated Data Scraping**: Celery workers and Celery Beat periodically fetch the latest price data from external sources.\n  * **Containerized Environment**: Fully containerized with Docker and Docker Compose for consistent environments and easy deployment.\n  * **Production-Ready**: Includes Nginx as a reverse proxy and Gunicorn as the WSGI application server.\n  * **API Documentation**: Automatic, interactive API documentation available via Swagger UI and Redoc, generated by `drf-spectacular`.\n  * [cite\\_start]**Custom User Model**: A flexible custom user model for managing application users[cite: 1].\n  * **Rate Limiting**: API throttling is in place to prevent abuse from anonymous and authenticated users.\n\n## Technology Stack\n\n  * **Backend**: Django, Django REST Framework\n  * **Database**: PostgreSQL\n  * **Asynchronous Tasks**: Celery, Redis (as message broker)\n  * **Containerization**: Docker, Docker Compose\n  * **Web Server / Gateway**: Nginx, Gunicorn\n  * **API Documentation**: drf-spectacular\n\n## API Endpoints\n\nThe base URL for the API is `/api/v1/`.\n\n| Endpoint                                       | Method | Description                                                |\n| ---------------------------------------------- | ------ | ---------------------------------------------------------- |\n| `/accounts/register/`                          | `POST`   | Register a new user.                               |\n| `/accounts/token/`                             | `POST`   | Obtain JWT access and refresh tokens.              |\n| `/accounts/token/refresh/`                     | `POST`   | Refresh an access token.                             |\n| `/api/v1/car-brands/`                          | `GET`    | List all car brands.                                |\n| `/api/v1/cars/`                                | `GET`    | List all cars with their price history.           |\n| `/api/v1/motorcycle-brands/`                   | `GET`    | List all motorcycle brands.                       |\n| `/api/v1/motorcycles/`                         | `GET`    | List all motorcycles with their price history.    |\n| `/api/v1/assets/`                              | `GET`    | List all currencies.                              |\n| `/api/v1/assets/?category=precious_metals`     | `GET`    | List all precious metals.                         |\n| ...                                            | `...`    | ...                         |\n\n**API Documentation:**\n\n  * **Swagger UI**: `http://localhost/api/docs/`\n  * **Redoc**: `http://localhost/api/redoc/`\n\n## Setup and Installation\n\n### Prerequisites\n\n  * Docker\n  * Docker Compose\n\n### Steps\n\n1.  **Clone the Repository**\n\n    ```bash\n    git clone \u003cyour-repository-url\u003e\n    cd \u003crepository-directory\u003e\n    ```\n\n2.  **Create Environment File**\n    Create a file named `.env` in the project root and populate it with the necessary environment variables. Use the following template:\n\n    ```env\n    # Django Core\n    SECRET_KEY=your-super-secret-key-here\n\n    # PostgreSQL Database\n    POSTGRES_DB=price_api_db\n    POSTGRES_USER=user\n    POSTGRES_PASSWORD=password\n    POSTGRES_HOST=db\n    POSTGRES_PORT=5432\n\n    # Celery (using Redis)\n    CELERY_BROKER_URL=redis://redis:6379/0\n    CELERY_RESULT_BACKEND=redis://redis:6379/0\n\n    # Bama Scraper API URL\n    BASE_API_URL_CAR=\n    BASE_API_URL_MOTORCYCLE=\n    BASE_API_URL_ASSETS=\n    LIST_API_URL_MOBILE=\n    LIST_API_URL_PC=\n    DETAIL_API_URL_MOBILE=\n    DETAIL_API_URL_PC=\n\n    # Email (Optional, for future features)\n    EMAIL_HOST_USER=your-email@gmail.com\n    EMAIL_HOST_PASSWORD=your-gmail-app-password\n    DEFAULT_FROM_EMAIL=your-email@gmail.com\n    ```\n\n3.  **Build and Run with Docker Compose**\n    From the project root, run the following command to build the images and start the containers:\n\n    ```bash\n    docker-compose up --build -d\n    ```\n\n    This will start the `nginx`, `app`, `db`, `redis`, `celery_worker`, and `celery_beat` services.\n\n4.  **Apply Database Migrations**\n    Once the containers are running, apply the Django database migrations:\n\n    ```bash\n    docker-compose exec app python manage.py migrate\n    ```\n\n5.  **Create a Superuser**\n    To access the Django admin panel, create a superuser:\n\n    ```bash\n    docker-compose exec app python manage.py createsuperuser\n    ```\n\n    Follow the prompts to set up your admin account.\n\n## Usage\n\nRun the development server:\n```bash\nuvicorn main:app --reload\n```\n* **API**: The API will be accessible at `http://localhost/`.\n* **Django Admin**: Access the admin panel at `http://localhost/admin/`.\n* **Flower (Celery Monitor)**: Monitor Celery tasks at `http://localhost:5555/`.\n\n\nThe API will be available at `http://localhost:8000`. Access the interactive API documentation at `http://localhost:8000/docs`.\n\nThe scrapers are scheduled to run automatically via Celery Beat. However, you can trigger them manually for testing:\n\n```bash\n# Scrape car prices\ndocker-compose exec celery_worker celery -A core call cars.tasks.scrape_car_prices\n\n# Scrape motorcycle prices\ndocker-compose exec celery_worker celery -A core call motorcycles.tasks.scrape_motorcycle_prices\n\n# Scrape asset prices\ndocker-compose exec celery_worker celery -A core call assets.tasks.scrape_assets_prices\n```\n\n\n### Example Requests\n\n#### Get Current Price\n```bash\nGET /api/v1/assets/\n```\nExample: `GET /api/v1/assets/zinc`  \nResponse:\n```json\n    {\n        \"symbol\": \"zinc\",\n        \"name_fa\": \"روی\",\n        \"name_en\": \"Zinc\",\n        \"category\": \"METAL\",\n        \"latest_price\": {\n            \"price\": \"2575.6000\",\n            \"high\": \"2575.6000\",\n            \"low\": \"2575.6000\",\n            \"timestamp\": \"2021-06-28T15:00:00+04:30\"\n        }\n```\n\n#### Get Historical Prices\n```bash\nGET /api/v1/assets/{asset_id}/history/?start_date=2025-01-01\u0026end_date=2025-09-24\n```\nResponse:\n```json\n[\n    {\n        \"price\": \"2575.6000\",\n        \"high\": \"2575.6000\",\n        \"low\": \"2575.6000\",\n        \"timestamp\": \"2021-06-28T15:00:00+04:30\"\n    }\n]\n```\n\n## Configuration\n\nAll sensitive data and environment-specific settings are managed through environment variables loaded from the `.env` file. Key variables include `SECRET_KEY`, database credentials (`POSTGRES_*`), and Celery broker URLs (`CELERY_*`).\n\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n\n1. Fork the project.\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`).\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).\n4. Push to the branch (`git push origin feature/AmazingFeature`).\n5. Open a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contact\n\nEbrahim Akbari - [Email](mailto:y560mia3@gmail.com)  \nProject Link: [https://github.com/Ebrahimakbari/API_PRICE](https://github.com/Ebrahimakbari/API_PRICE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febrahimakbari%2Fapi_price","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Febrahimakbari%2Fapi_price","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Febrahimakbari%2Fapi_price/lists"}