{"id":15433028,"url":"https://github.com/simonw/paginate-json","last_synced_at":"2025-08-26T07:08:42.142Z","repository":{"id":57450286,"uuid":"191592094","full_name":"simonw/paginate-json","owner":"simonw","description":"Command-line tool for fetching JSON from paginated APIs","archived":false,"fork":false,"pushed_at":"2024-01-05T09:21:04.000Z","size":46,"stargazers_count":67,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-31T21:14:52.642Z","etag":null,"topics":["json","sqlite"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-12T14:55:59.000Z","updated_at":"2025-04-19T07:14:24.000Z","dependencies_parsed_at":"2024-10-20T20:18:33.073Z","dependency_job_id":null,"html_url":"https://github.com/simonw/paginate-json","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"4b4f5e64423ea792bbd16b1d074a073267ee87b9"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/simonw/paginate-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fpaginate-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fpaginate-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fpaginate-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fpaginate-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonw","download_url":"https://codeload.github.com/simonw/paginate-json/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonw%2Fpaginate-json/sbom","scorecard":{"id":825256,"data":{"date":"2025-08-11","repo":{"name":"github.com/simonw/paginate-json","commit":"4b4f5e64423ea792bbd16b1d074a073267ee87b9"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/publish.yml:8","Info: topLevel 'contents' permission set to 'read': .github/workflows/test.yml:6","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/simonw/paginate-json/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/simonw/paginate-json/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/simonw/paginate-json/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/simonw/paginate-json/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/simonw/paginate-json/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/simonw/paginate-json/test.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:43","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:26","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:26","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:30","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T16:29:58.716Z","repository_id":57450286,"created_at":"2025-08-23T16:29:58.716Z","updated_at":"2025-08-23T16:29:58.716Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272187003,"owners_count":24888491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","sqlite"],"created_at":"2024-10-01T18:30:37.190Z","updated_at":"2025-08-26T07:08:42.108Z","avatar_url":"https://github.com/simonw.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# paginate-json\n\n[![PyPI](https://img.shields.io/pypi/v/paginate-json.svg)](https://pypi.python.org/pypi/paginate-json)\n[![Changelog](https://img.shields.io/github/v/release/simonw/paginate-json?include_prereleases\u0026label=changelog)](https://github.com/simonw/paginate-json/releases)\n[![Tests](https://github.com/simonw/paginate-json/workflows/Test/badge.svg)](https://github.com/simonw/paginate-json/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/paginate-json/blob/main/LICENSE)\n\nCLI tool for retrieving JSON from paginated APIs.\n\nThis tool works against APIs that use the HTTP Link header for pagination. The GitHub API is [one example of this](https://developer.github.com/v3/guides/traversing-with-pagination/).\n\nRecipes using this tool:\n\n- [Combined release notes from GitHub with jq and paginate-json](https://til.simonwillison.net/jq/combined-github-release-notes)\n- [Export a Mastodon timeline to SQLite](https://til.simonwillison.net/mastodon/export-timeline-to-sqlite)\n\n## Installation\n\n```bash\npip install paginate-json\n```\nOr use [pipx](https://pypa.github.io/pipx/):\n```bash\npipx install paginate-json\n```\n\n## Usage\n\nRun this tool against a URL that returns a JSON list of items and uses the `link:` HTTP header to indicate the URL of the next page of results.\n\nIt will output a single JSON list containing all of the records, across multiple pages.\n```bash\npaginate-json \\\n  https://api.github.com/users/simonw/events\n```\nYou can use the `--header` option to send additional request headers. For example, if you have a GitHub OAuth token you can pass it like this:\n```bash\npaginate-json \\\n  https://api.github.com/users/simonw/events \\\n  --header Authorization \"bearer e94d9e404d86...\"\n```\nSome APIs may return a root level object where the items you wish to gather are stored in a key, like this example from the [Datasette JSON API](https://docs.datasette.io/en/latest/json_api.html):\n```json\n{\n  \"ok\": true,\n  \"rows\": [\n    {\n      \"id\": 1,\n      \"name\": \"San Francisco\"\n    },\n    {\n      \"id\": 2,\n      \"name\": \"Los Angeles\"\n    },\n    {\n      \"id\": 3,\n      \"name\": \"Detroit\"\n    },\n    {\n      \"id\": 4,\n      \"name\": \"Memnonia\"\n    }\n  ]\n}\n```\nIn this case, use `--key rows` to specify which key to extract the items from:\n```bash\npaginate-json \\\n  https://latest.datasette.io/fixtures/facet_cities.json \\\n  --key rows\n```\nThe output JSON will be streamed as a pretty-printed JSON array by default.\n\nTo switch to newline-delimited JSON, with a separate object on each line, add `--nl`:\n```bash\npaginate-json \\\n  https://latest.datasette.io/fixtures/facet_cities.json \\\n  --key rows \\\n  --nl\n```\nThe output from that command looks like this:\n```\n{\"id\": 1, \"name\": \"San Francisco\"}\n{\"id\": 2, \"name\": \"Los Angeles\"}\n{\"id\": 3, \"name\": \"Detroit\"}\n{\"id\": 4, \"name\": \"Memnonia\"}\n```\n\n\n\n## Using this with sqlite-utils\n\nThis tool works well in conjunction with [sqlite-utils](https://github.com/simonw/sqlite-utils). For example, here's how to load all of the GitHub issues for a project into a local SQLite database.\n```bash\npaginate-json \\\n  \"https://api.github.com/repos/simonw/datasette/issues?state=all\u0026filter=all\" \\\n  --nl | \\\n  sqlite-utils upsert /tmp/issues.db issues - --nl --pk=id\n```\nYou can then use [other features of sqlite-utils](https://sqlite-utils.readthedocs.io/en/latest/cli.html) to enhance the resulting database. For example, to enable full-text search on the issue title and body columns:\n```bash\nsqlite-utils enable-fts /tmp/issues.db issues title body\n```\n## Using jq to transform each page\n\nIf you install the optional [jq](https://pypi.org/project/jq/) or [pyjq](https://pypi.org/project/pyjq/) dependency you can also pass `--jq PROGRAM` to transform the results of each page using a [jq program](https://stedolan.github.io/jq/). The `jq` option you supply should transform each page of fetched results into an array of objects.\n\nFor example, to extract the `id` and `title` from each issue:\n```bash\npaginate-json \\\n  \"https://api.github.com/repos/simonw/datasette/issues\" \\\n  --nl \\\n  --jq 'map({id, title})'\n```\nIf you installed `paginate-json` using `pipx` you can inject the extra dependency into the correct virtual environment like this:\n```bash\npipx inject paginate-json jq\n```\n\n## paginate-json --help\n\n\u003c!-- [[[cog\nimport cog\nfrom paginate_json import cli\nfrom click.testing import CliRunner\nrunner = CliRunner()\nresult = runner.invoke(cli.cli, [\"--help\"])\nhelp = result.output.replace(\"Usage: cli\", \"Usage: paginate-json\")\ncog.out(\n    \"```\\n{}\\n```\".format(help)\n)\n]]] --\u003e\n```\nUsage: paginate-json [OPTIONS] URL\n\n  Fetch paginated JSON from a URL\n\n  Example usage:\n\n      paginate-json https://api.github.com/repos/simonw/datasette/issues\n\nOptions:\n  --version                Show the version and exit.\n  --nl                     Output newline-delimited JSON\n  --key TEXT               Top-level key to extract from each page\n  --jq TEXT                jq transformation to run on each page\n  --accept TEXT            Accept header to send\n  --sleep INTEGER          Seconds to delay between requests\n  --silent                 Don't show progress on stderr - default\n  -v, --verbose            Show progress on stderr\n  --show-headers           Dump response headers out to stderr\n  --ignore-http-errors     Keep going on non-200 HTTP status codes\n  --header \u003cTEXT TEXT\u003e...  Send custom request headers\n  --help                   Show this message and exit.\n\n```\n\u003c!-- [[[end]]] --\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonw%2Fpaginate-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonw%2Fpaginate-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonw%2Fpaginate-json/lists"}