A light REST API designed for the Open Food Facts Folksonomy Engine.
- Design documents: https://wiki.openfoodfacts.org/Folksonomy_Engine
- API endpoint: https://api.folksonomy.openfoodfacts.org/
- API Documentation with interactive "try-out": https://api.folksonomy.openfoodfacts.org/docs
- Browser extension to try it live: https://github.com/openfoodfacts/folksonomy_frontend
- Moderators can access it on Open Food Facts without any extension. The UI has not yet been deployed on Open Products Facts, Open Pet Food Facts or Open Beauty Facts, but has been proven to work, thanks to the extension
The code is written in Python 3.x and uses FastAPI framework.
PostgreSQL is used as the backend database.
You should create unit tests for each new feature or API change (see test_main.py). To run tests just launch:
PYTHONASYNCIODEBUG=1 pytest tests/ folksonomy/
The PYTHONASYNCIODEBUG
is important to check we have no pending asyncio tasks that are not executed
(sign of a potential problem).
FastAPI is based on OpenAPI (previously known as Swagger) and JSON Schema. FastAPI allows to generate an OpenAPI document (JSON) that you can reuse in various services (to automatically generate client libraries for example). To generate an OpenAPI document you can either:
- download it at https://api.folksonomy.openfoodfacts.org/openapi.json
- or generate it:
./generate_openapi_json.py
- Install Python 3.8+
- Install pip
- Install PostgreSQL 13+
- Follow the steps in INSTALL.md to install requirements and for creating a db user
- Make a copy of local_settings_example.py and rename it to local_settings.py
- Change parameters accordingly in local_settings.py
- That's all!