Skip to main content

afetch

CI codecov PyPI Version Supported Python Versions License

A simple asynchronous HTTP client with just the essentials.

Features

  • Rate Limiting - Automatically limits requests per domain to avoid overwhelming servers
  • Automatic Retries - Built-in exponential backoff retry mechanism for failed requests
  • Response Caching - Cache responses to reduce redundant network calls
  • Concurrent Fetching - Fetch multiple URLs in parallel with fetch_all()

Installation

pip install afetch

Or using uv:

uv add afetch

Quick Start

import asyncio
from afetch import Fetcher

async def main():
    urls = [
        "https://example.com/page1",
        "https://example.com/page2",
        "https://example2.com",
    ]
    async with Fetcher() as fetcher:
        responses = await fetcher.fetch_all(urls)
    for response in responses:
        print(response)

asyncio.run(main())

Usage

Fetching a Single URL

async with Fetcher() as fetcher:
    content = await fetcher.fetch("https://example.com")
    print(content)

Fetching Multiple URLs

async with Fetcher() as fetcher:
    urls = ["https://example.com/a", "https://example.com/b"]
    responses = await fetcher.fetch_all(urls)

Custom Configuration

from afetch import Fetcher, FetcherConfig

config = FetcherConfig(
    max_rate_per_domain=2,      # Allow 2 requests per time period
    time_period_per_domain=1,   # Time period in seconds
    retry_attempts=5,           # Number of retry attempts
    cache_enabled=True,         # Enable response caching
)

async with Fetcher(config) as fetcher:
    content = await fetcher.fetch("https://example.com")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Setup

  1. Clone the repository:
git clone https://github.com/okayama-daiki/afetch.git
cd afetch
  1. Install dependencies with uv:
uv sync

Testing

uv run pytest -v

Formatting and Linting

uv run ruff check .

Acknowledgments

This project is built on top of these excellent libraries:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for afetch 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for afetch 0.2.0
File Size Uploaded
afetch-0.2.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for afetch 0.2.0
File Interpreter ABI Platform
afetch-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.6 kB

Release files / afetch-0.2.0.tar.gz

Download URL afetch-0.2.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
394a25f724c0bf22e1a9dbcd6e66a5b9f8fb9f3a06b26cb07ce248b4442d6828
BLAKE2b-256 checksum
How to use checksums
6531abca6d8095a37a369c91c117e45fefd99b7232ed5339783181bf710bd1b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release files / afetch-0.2.0-py3-none-any.whl

Download URL afetch-0.2.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff0fe7e1e056406cd2e694ecdc75ef7c3e26f6760b4fdc4ba70f5280db0adaf4
BLAKE2b-256 checksum
How to use checksums
e387c8b95f5517202b4477c66ff62eaba5c2c7203c9e55f40972c08c6acdd29e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release 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