A command line api request tool with caching and rate limiting.
Project description
api-request
api-request is an API-first Python project for executing batched HTTP requests with:
- async request orchestration
- optional SQLite-backed caching
- configurable rate limiting
- JSON in / JSON out workflows
It includes a simple CLI for running request batches from stdin or files, and a Python API for integrating the same behavior in application code.
Project Status
- Package manager:
uv - Distribution: source-only for now (no PyPI release yet)
- Python:
>=3.14
Installation
Clone the repository and sync dependencies with uv:
uv sync
This creates/updates the local .venv and installs app + dev dependencies.
Quick Start (CLI)
Show CLI help:
uv run api-request --help
Run a batch from stdin and print plain JSON to stdout:
cat requests.json | uv run api-request --from - --to - --plain --indent 2
Run from file and write to file:
uv run api-request --from requests.json --to responses.json --overwrite --indent 2
Show version and resolved runtime directories:
uv run api-request --version
Input JSON Shape
The CLI expects a JSON object keyed by request UUID. Each value is a request definition.
Minimal example:
{
"00000000-0000-0000-0000-000000000001": {
"url": "https://esi.evetech.net/status/",
"method": "GET"
}
}
Supported request fields include:
url(required)method(required)headers(optional map)body(optional)parameters(optional query param map)cache_key(optional UUID)rate_key(optional string)
Output JSON Shape
The CLI returns a JSON object with:
successful: map of request UUID -> responsefailed: map of request UUID -> failed response
Python API Usage
import asyncio
from uuid import uuid4
from api_request import ApiRequester, Request
from api_request.cache import InMemoryCache
from api_request.rate_limit import AiolimiterRateLimiterFactory
async def main() -> None:
request = Request(
request_key=uuid4(),
method="GET",
url="https://esi.evetech.net/status/",
cache_key=uuid4(),
rate_key="esi-status",
)
async with ApiRequester(
cache_factory=InMemoryCache,
rate_limiter_factory=AiolimiterRateLimiterFactory(
max_rate=50.0,
time_period=60.0,
),
) as requester:
responses = await requester.process_requests({request.request_key: request})
print(responses)
if __name__ == "__main__":
asyncio.run(main())
Configuration
Runtime settings use environment variables with the API_REQUEST_ prefix.
API_REQUEST_APPLICATION_DIRECTORY: overrides the app directory used for cache and logs.
You can also set this from the CLI with --application-directory.
Development
Common commands:
uv sync
uv run ruff format
uv run ruff check
uv run pytest
Repository Layout
src/api_request/: package sourcesrc/api_request/cli/: Typer CLI entrypointssrc/api_request/request/: request orchestration and modelssrc/api_request/cache/: cache implementations and protocolstests/: test suite
License
MIT. See LICENSE.
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 pfmsoft_api_request-0.1.3.tar.gz.
File metadata
- Download URL: pfmsoft_api_request-0.1.3.tar.gz
- Upload date:
- Size: 33.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e7a7ae89996ccf0e3a42775432ebfc151d6b4013c1474802121879217636e61
|
|
| MD5 |
6d6f31394dea7f95ab9891e4ef883c6e
|
|
| BLAKE2b-256 |
d0a6d8ac3df3e09e44652b7b51501f8687f18583995109330e6e0bf1c346f9ef
|
Provenance
The following attestation bundles were made for pfmsoft_api_request-0.1.3.tar.gz:
Publisher:
pypi-publish.yaml on DonalChilde/pfmsoft-api-request
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pfmsoft_api_request-0.1.3.tar.gz -
Subject digest:
6e7a7ae89996ccf0e3a42775432ebfc151d6b4013c1474802121879217636e61 - Sigstore transparency entry: 2203931244
- Sigstore integration time:
-
Permalink:
DonalChilde/pfmsoft-api-request@f3783881b9782b58882810129e373863f9507b68 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/DonalChilde
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@f3783881b9782b58882810129e373863f9507b68 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pfmsoft_api_request-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pfmsoft_api_request-0.1.3-py3-none-any.whl
- Upload date:
- Size: 49.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c48b02f5b4a2c7204bedb4d57ed0ca601e6b2485f2c7c67019d603a2c137216
|
|
| MD5 |
b787faaf85917d2a7ec25ddde93e53d2
|
|
| BLAKE2b-256 |
5c3c05c0f95522ee79771e71e987f3385e139eedf4e163a4c36c81cc81914484
|
Provenance
The following attestation bundles were made for pfmsoft_api_request-0.1.3-py3-none-any.whl:
Publisher:
pypi-publish.yaml on DonalChilde/pfmsoft-api-request
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pfmsoft_api_request-0.1.3-py3-none-any.whl -
Subject digest:
0c48b02f5b4a2c7204bedb4d57ed0ca601e6b2485f2c7c67019d603a2c137216 - Sigstore transparency entry: 2203931396
- Sigstore integration time:
-
Permalink:
DonalChilde/pfmsoft-api-request@f3783881b9782b58882810129e373863f9507b68 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/DonalChilde
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yaml@f3783881b9782b58882810129e373863f9507b68 -
Trigger Event:
release
-
Statement type: