A generic toolkit for token-authenticated REST API retrieval.
Project description
apifetch (Python)
apifetch is a small, dependency-light toolkit for talking to
token-authenticated REST APIs. It handles three recurring chores:
- Token management — store/get/remove/list tokens in process environment variables (never written to disk), namespaced per service.
- Request building — pluggable authentication and pagination
strategies, bundled into a reusable
Apiprofile. - Data retrieval — fetch one page, or fetch everything in chunks.
This is the Python sibling of the R package
apifetch. Both were extracted
from the BigDataPE package,
which is now one use case (see examples/bigdatape.py).
Installation
pip install apifetch
Usage
import apifetch as af
# 1. Describe the API once: where, how to authenticate, how to paginate.
api = af.Api(
endpoint="https://api.example.com/v1/search",
service="Example",
auth=af.AuthBearer(), # "Authorization: Bearer <token>"
pagination=af.PaginateOffset(where="query"),
)
# 2. Store a token (kept only in this process's environment).
af.store_token("reports", "my-secret-token", service="Example")
# 3. Fetch.
one_page = af.fetch(api, "reports", limit=50)
everything = af.fetch_all(api, "reports", chunk_size=1000)
# Optional: turn it into a DataFrame.
# import pandas as pd; df = pd.DataFrame(everything)
Strategies
Authentication: AuthBearer, AuthRaw, AuthHeader, AuthQuery.
Pagination: PaginateOffset(where="header" | "query"), PaginateNone.
License
MIT © André Leite
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file apifetch-0.1.1.tar.gz.
File metadata
- Download URL: apifetch-0.1.1.tar.gz
- Upload date:
- Size: 49.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a87c73bad21b89939c1944032a3f218b30a47e54a9325fa86f7b90d081970f39
|
|
| MD5 |
b7a7e378e45f02d35761f4a70dd48831
|
|
| BLAKE2b-256 |
81201695aaa2a3fed16e3e2f6976678ef66420d945b0dbd0e9a946186d9b4419
|
Provenance
The following attestation bundles were made for apifetch-0.1.1.tar.gz:
Publisher:
release.yml on StrategicProjects/apifetch-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apifetch-0.1.1.tar.gz -
Subject digest:
a87c73bad21b89939c1944032a3f218b30a47e54a9325fa86f7b90d081970f39 - Sigstore transparency entry: 1971211177
- Sigstore integration time:
-
Permalink:
StrategicProjects/apifetch-py@02acc159cdf239b2d581a9d4a08b80f25fff9084 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/StrategicProjects
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@02acc159cdf239b2d581a9d4a08b80f25fff9084 -
Trigger Event:
release
-
Statement type:
File details
Details for the file apifetch-0.1.1-py3-none-any.whl.
File metadata
- Download URL: apifetch-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d27387d04950683c73d7b4edeca45ae1cadae3e288610d09d74431c37c04649
|
|
| MD5 |
cff52a7728c50634e9ac119861bb800e
|
|
| BLAKE2b-256 |
c7b0adc72a2684b7e7f809fe65c8c69b9b76cb0143cf467a08d1bf8fb1482f6c
|
Provenance
The following attestation bundles were made for apifetch-0.1.1-py3-none-any.whl:
Publisher:
release.yml on StrategicProjects/apifetch-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
apifetch-0.1.1-py3-none-any.whl -
Subject digest:
3d27387d04950683c73d7b4edeca45ae1cadae3e288610d09d74431c37c04649 - Sigstore transparency entry: 1971211252
- Sigstore integration time:
-
Permalink:
StrategicProjects/apifetch-py@02acc159cdf239b2d581a9d4a08b80f25fff9084 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/StrategicProjects
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@02acc159cdf239b2d581a9d4a08b80f25fff9084 -
Trigger Event:
release
-
Statement type: