ForexFactoryScrapper is a small Flask-based API that exposes scraping logic for several economic-calendar sources (ForexFactory, CryptoCraft, EnergyExch, MetalsMine).
What this repository provides:
- Flask HTTP API endpoints returning JSON (or HTML for the root page)
- Per-site scrapers under
src/scrapper/(site-specific logic) - Simple test-suite using
pytestundertests/ - A minimal OpenAPI spec (served at
/openapi.json) and a Swagger UI at/swagger
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Run the app locally:
python main.py
# or
python src/app.pyBy default the app listens on 0.0.0.0:5000. You can configure HOST, PORT and DEBUG via environment variables or a .env file (the app uses python-dotenv if present).
Open the welcome page in your browser: http://localhost:5000/
Open API docs: http://localhost:5000/swagger
Open raw OpenAPI JSON: http://localhost:5000/openapi.json
- GET
/— Welcome HTML page (quick links) - GET
/api/hello— simple hello response - GET
/api/health— quick health check - GET
/api/forex/daily— ForexFactory daily events (query params:day,month,year, optionallimit,offset) - GET
/api/cryptocraft/daily— CryptoCraft daily events (same parameters) - GET
/api/energyexch/daily— EnergyExch daily events (same parameters) - GET
/api/metalsmine/daily— MetalsMine daily events (same parameters)
All /.../daily endpoints follow the same validation and paging semantics:
- Required query parameters:
day,month,year(integers) - Optional
limitandoffset(integers, >= 0) - On success, list results are wrapped in a pagination object:
{ total, offset, limit, results }. - On parameter validation error, endpoints return HTTP 400 with JSON:
{ "error": "..." }.
- The OpenAPI document is available at
/openapi.jsonand is generated fromsrc/openapi_spec.py. - The interactive Swagger UI is served at
/swaggerand uses the OpenAPI JSON. If your environment blocks external CDN assets, the UI falls back to an inline minimal page.
If you update endpoints or schemas, please update src/openapi_spec.py accordingly so the docs stay accurate.
HOST— host to bind (default0.0.0.0)PORT— port to bind (default5000)DEBUG— debug mode (defaultTrue)DOTENV_PATH— optional path to a.envfile
Run tests with:
python -m pytest -qTests are under tests/ and use pytest and the Flask test client. Many tests monkeypatch src.app and main to avoid network calls.
A Dockerfile is provided for convenience; if you prefer to run inside Docker, build and run the image as usual (adjust ports as needed).
Contributions welcome. Suggested workflow:
- Create a branch for your change
- Add tests for any behavior you modify
- Run the full test suite
- Open a pull request describing the change
If you modify or add a new scraper under src/scrapper/, try to keep the get_records(url) and get_url(day, month, year, timeline) function signatures so the route helpers can call them interchangeably.
Code of Conduct: Please read CODE_OF_CONDUCT.md before contributing — it describes expected behaviour and reporting contacts.
Maintainer: Ata Can — atacanymc@gmail.com
If you want, I can also generate a short CONTRIBUTING.md or add CI steps to run lint/tests automatically on PRs. Let me know what else to update.