This project generates a JSON API from the history-project content repository. It does that in two steps:
- load: Generate a sqlite database from the source files.
- dump: Use that database to generate a JSON API.
- The API is currently hosted at https://nthp-api.wjdp.uk/v1.
- The specification is available at https://nthp-api.wjdp.uk/v1/master/openapi.json.
- To render the spec into human-readable docs use a tool such as:
- Ensure you have Poetry installed.
- Run
poetry install. - Clone the history project repository into the
content/directory. You can do a shallow clone for this:GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1 --branch master [email protected]:newtheatre/history-project content. - Run
./nthp loadto generate the sqlite database from the content files. - Run
./nthp dumpto generate the API from the database into thedist/directory.
- With pip installed run
pip install --user nthp-api. If you have your local bin folder on your path you should now be able to runnthp. - Within the history-project repo run
nthp loadto generate the sqlite database from the content files. - Run
nthp dumpto generate the API from the database into thedist/directory.
Alternatively you can run nthp build to run both steps in one go.
pre-commit hooks are used to lint the source code using Black and ruff
- Ensure you have pre-commit installed.
- Run
pre-commit installto install pre-commit hooks.
Run pytest or use the included PyCharm run configuration.
See the bin/release.sh script for the release process. This assumes that your local machine has the correct credentials to publish to PyPi.