Skip to content

🕸️ Async HTTP request batcher with connection pooling and rate limiting.

License

Notifications You must be signed in to change notification settings

davidgasquez/abatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

abatcher

Simple parallel HTTP request batcher with rate limiting, retries, connection pooling, and more. The entire API is only 1 function.

🛠️ Usage

Using abatcher should be as simple as:

import abatcher

requests = [
    # Simple URL GET request
    "https://httpbin.org/anything",
    # Custom request
    {
        "url": "https://httpbin.org/post",
        "method": "POST",
        "params": {"name": "Test"},
        "headers": {"X-Custom": "value"},
    },
]

results = abatcher.run(requests)

print(f"Batch requests results: {results}")

If you need more control, you can also send a custom client.

import httpx
import abatcher

custom_client = httpx.AsyncClient(
    auth=("user", "pass"),
    timeout=httpx.Timeout(45.0),
    limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
)

results = abatcher.run(
    requests,
    client=custom_client,
    max_concurrent=20,
    max_per_second=10,
    cache=True,
    cache_dir="custom_cache",
    cache_ttl=3600,
)

print(f"Batch requests results: {results}")

About

🕸️ Async HTTP request batcher with connection pooling and rate limiting.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages