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.

Download files

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

Source Distribution

afetch-0.2.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

afetch-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file afetch-0.2.0.tar.gz.

File metadata

  • Download URL: afetch-0.2.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for afetch-0.2.0.tar.gz
Algorithm Hash digest
SHA256 394a25f724c0bf22e1a9dbcd6e66a5b9f8fb9f3a06b26cb07ce248b4442d6828
MD5 3021cf4c4a811aae25b474a984f9b8c5
BLAKE2b-256 6531abca6d8095a37a369c91c117e45fefd99b7232ed5339783181bf710bd1b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for afetch-0.2.0.tar.gz:

Publisher: release.yml on okayama-daiki/afetch

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

File details

Details for the file afetch-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: afetch-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for afetch-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff0fe7e1e056406cd2e694ecdc75ef7c3e26f6760b4fdc4ba70f5280db0adaf4
MD5 bed89ae00190c86f80dc9326b5adefc1
BLAKE2b-256 e387c8b95f5517202b4477c66ff62eaba5c2c7203c9e55f40972c08c6acdd29e

See more details on using hashes here.

Provenance

The following attestation bundles were made for afetch-0.2.0-py3-none-any.whl:

Publisher: release.yml on okayama-daiki/afetch

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

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page