Skip to main content

History Project API Generator

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.

Endpoints

Usage

From source

  • Ensure you have uv installed.
  • Run uv sync.
  • 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 git@github.com:newtheatre/history-project content.
  • Run ./nthp load to generate the sqlite database from the content files.
  • Run ./nthp dump to generate the API from the database into the dist/ directory.

From PyPi

  • 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 run nthp.
  • Within the history-project repo run nthp load to generate the sqlite database from the content files.
  • Run nthp dump to generate the API from the database into the dist/ directory.

Alternatively you can run nthp build to run both steps in one go.

The content schema

The ingest models are the authority on what a content file may contain, and the dump publishes them: dist/content-schema/{show,person,venue,committee,history,roles,link-types}.json as draft 2020-12 JSON Schema, alongside index.html, the same tables written for people to read. Both sit beside openapi.json and are versioned with it.

Command What it does
nthp schema [type] [--format json|markdown] Print a schema, or all of them
nthp validate <path>… Check files or directories; nonzero exit on a problem
nthp new show|person|venue [--id ID] Print a skeleton with every field described

nthp validate runs the same models and the same per-document checks as nthp load, so what it accepts is what a build accepts. Anything needing the whole repository to see belongs to nthp lint below.

Linting the content

nthp lint <path> loads the content into an in-memory database and reports what the archive tolerates but an editor might want to fix: venues referenced without a document, credits with no name, people who may be one person twice, roles and link types matching no definition, and so on.

The report is written for whoever edits the content, not for whoever wrote the generator. Each check gets a heading with its count, a line saying what the check means and how to fix it, and a table of what it found — the file to open, the value at fault, and what it costs. A summary table closes the report, with each check coloured by severity: amber for what is worth fixing, cyan for the merely advisory.

Option What it does
--check NAME Run one check; repeat the option for several. Names are in the report
--verbose List every finding, rather than the first few
--format plain No colour and no boxes, for a CI log; the default when not a terminal

Linting never fails: these are expectations, not defects. Defects are reported as errors by nthp load and nthp build instead, in the plain logging both use.

Contributing

Git hooks

Git hooks are used to lint and format the source code using ruff

  • Ensure you have prek installed.
  • Run prek install to install the hooks.
  • Run prek run --all-files to check everything.

Tests

Run uv run pytest.

Release

See the bin/release.sh script for the release process. This assumes that your local machine has the correct credentials to publish to PyPi.

Metadata

Release files for nthp_api 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nthp_api 0.4.4
File Size Uploaded
nthp_api-0.4.4.tar.gz 91.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nthp_api 0.4.4
File Interpreter ABI Platform
nthp_api-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 202.5 kB

Release files / nthp_api-0.4.4.tar.gz

Download URL nthp_api-0.4.4.tar.gz
Size 91.4 kB
Tags Source
SHA-256 checksum
How to use checksums
be1afb7fea8ff011bbf4c3a1cf5ed7328dc4ee302c846e54c9f8300084e02aa5
BLAKE2b-256 checksum
How to use checksums
e5dd38dfa13a11e8e5f4f885586f0de3be7de11a4b8a0334989088c0242c3f71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / nthp_api-0.4.4-py3-none-any.whl

Download URL nthp_api-0.4.4-py3-none-any.whl
Size 111.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96f0da1e76dfc21b78a6443a15dfb6b064a412e75f13046ce79c14048c0d6035
BLAKE2b-256 checksum
How to use checksums
64f5f832a0ad06a92b293c1fe709ed35845540f4adba5a1a06717dcb6688714a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page