CLI tool for fetching paginated JSON from a URL
Project description
paginate-json
CLI tool for retrieving JSON from paginated APIs.
Currently works against APIs that use the HTTP Link header for pagination. The GitHub API is the most obvious example.
$ paginate-json --help
Usage: paginate-json [OPTIONS] URL
Fetch paginated JSON from a URL
Options:
--version Show the version and exit.
--nl Output newline-delimited JSON
--jq TEXT jq transformation to run on each page
--help Show this message and exit.
The --jq
option only works if you install the optional pyjq dependency.
Works well in conjunction with sqlite-utils. For example, here's how to load all of the GitHub issues for a project into a local SQLite database.
paginate-json \
"https://api.github.com/repos/simonw/datasette/issues?state=all&filter=all" \
--nl | \
sqlite-utils upsert /tmp/issues.db issues - --nl --pk=id
You can then use other features of sqlite-utils to enhance the resulting database. For example, to enable full-text search on the issue title and body columns:
sqlite-utils enable-fts /tmp/issues.db issues title body
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file paginate_json-0.2-py3-none-any.whl
.
File metadata
- Download URL: paginate_json-0.2-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52ed5365894fafa29e982bd5799d9333df29a64b7b6fa21fbe5e4fd8a6abb4c4 |
|
MD5 | 3bcbfa98318e906b810c559b63f8cf87 |
|
BLAKE2b-256 | 93e065fe87a4fbf1b5346de5fad7fe9beedbbba9e80aa3184849fd95c72f462e |