Skip to main content
Hatchmark reads files and databases, not the APIs of tools such as Stripe, HubSpot, Zendesk or GitHub. dlt, an open-source Python library (Apache-2.0), copies data from those APIs into a DuckDB file or Parquet files in your project, and a duckdb or parquet source reads them like any other table. Run the pipeline before hatchmark build, and the dashboards show the latest load. The steps load the issues and pull requests of a public GitHub repository, which needs no account. For your own tools, dlt has verified sources for many SaaS products and a REST API source for any other JSON API.

1. Install dlt

In the project folder, create a Python environment and install dlt with its DuckDB destination:
Add .venv/ to .gitignore.

2. Write the pipeline

  • add_limit(3) reads three pages, 300 rows, to try it out. Remove it to load every page.
  • merge on primary_key updates the rows that changed since the last run instead of adding them again, so the file holds one row per issue.
  • Name the file differently from dataset_name. In github.duckdb, the schema github and the database github share a name, and dlt’s load fails with Ambiguous reference to catalog or schema "github".
  • A source that needs a key reads it from an environment variable or .dlt/secrets.toml, never from the script; see credentials in dlt’s docs. Keep .dlt/secrets.toml out of git.

3. Run it

dlt writes the rows to the github schema of data/saas.duckdb: one table per resource, here issues, and its own bookkeeping tables, whose names start with _dlt.
  • Nested objects become columns joined with a double underscore: the author’s login is user__login, and a pull request’s URL is pull_request__url.
  • Lists become child tables, such as issues__labels, whose _dlt_parent_id matches the parent row’s _dlt_id.
  • A merge load also writes a github_staging schema, which no source needs.

4. Add the source

Timestamps arrive as TIMESTAMP WITH TIME ZONE and read as time, so they are bucketed in the project’s timezone. Run the pipeline and the build one after the other, not at the same time: the build reads the file read-only, and dlt holds it while it loads. See DuckDB files for how the file is read.

5. Define metrics on it

GitHub’s issues API returns pull requests too; a pull request is a row with a pull_request__url.
Put them on a page as in build a dashboard.

Keep it up to date

Run the pipeline and then the build in the same scheduled job, such as a cron entry or a CI workflow:
With merge, each run fetches the issues again and updates the ones that changed. For a large account, load only what changed since the last run with dlt’s incremental loading.

Parquet files instead

dlt’s filesystem destination writes Parquet files. A local parquet source reads one file, so name each table’s file after the table and replace it on every run:
Install it with .venv/bin/pip install "dlt[parquet]". The run writes data/github/issues.parquet:
To keep the rows of earlier runs, append or merge into DuckDB as above. Loading to a bucket instead, with the filesystem destination’s bucket_url set to s3://, gs:// or az://, works with a cloud storage source, whose path may be a glob that matches every file dlt writes for a table.