Skip to main content

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 -> response
  • failed: 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 source
  • src/api_request/cli/: Typer CLI entrypoints
  • src/api_request/request/: request orchestration and models
  • src/api_request/cache/: cache implementations and protocols
  • tests/: test suite

License

MIT. See LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pfmsoft_api_request-0.1.8.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pfmsoft_api_request-0.1.8-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file pfmsoft_api_request-0.1.8.tar.gz.

File metadata

  • Download URL: pfmsoft_api_request-0.1.8.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pfmsoft_api_request-0.1.8.tar.gz
Algorithm Hash digest
SHA256 5e1f19d0645a23fc5dfb140881758993161b97f3eb9c2859dcf6aabd0b82b4f8
MD5 59b5873a466f3b9dc29ebb3ca97df5fb
BLAKE2b-256 7723dbe591a58f67a472307d51f3f0b1eeef53f9a3cbd7e4219f933fb01f1ac0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pfmsoft_api_request-0.1.8.tar.gz:

Publisher: pypi-publish.yaml on DonalChilde/pfmsoft-api-request

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pfmsoft_api_request-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for pfmsoft_api_request-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7dc414e7ed38e082d037f7af0b0291015a02edbbb808d3fcc3b3375f4c0a2577
MD5 d22a06279f326aa5355ff520e6729ea2
BLAKE2b-256 55e3e18458cf62d0ff980ffa286f28b90392c713e8ed3a38d2d76811dbf3661e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pfmsoft_api_request-0.1.8-py3-none-any.whl:

Publisher: pypi-publish.yaml on DonalChilde/pfmsoft-api-request

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.9

2 files

This release

0.1.8 This release

2 files

0.1.7

2 files

0.1.6

2 files

0.1.3

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page