Reference API
The following classes are exposed to the user:
httpx_limiter
¶
Provide top level symbols.
Rate
¶
AsyncRateLimitedTransport
¶
Bases: AsyncBaseTransport
Define the asynchronous rate-limited transport.
This transport consists of a composed transport for handling requests and an implementation of a leaky bucket algorithm in order to rate-limit the number of requests.
__init__(*, limiter: AsyncLimiter, transport: httpx.AsyncBaseTransport, **kwargs) -> None
¶
create(*, rate: Rate, **kwargs: dict) -> AsyncRateLimitedTransport
classmethod
¶
Create an instance of asynchronous rate-limited transport.
This factory method constructs the instance with an underlying
httpx.AsyncHTTPTransport
.
That transport is passed any additional keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rate
|
Rate
|
The maximum rate per interval at which bucket capacity is restored. |
required |
**kwargs
|
dict
|
Additional keyword arguments are used in the construction of an
|
{}
|
Returns:
Type | Description |
---|---|
AsyncRateLimitedTransport
|
A default instance of the class created from the given arguments. |
handle_async_request(request: httpx.Request) -> httpx.Response
async
¶
Handle an asynchronous request with rate limiting.
AbstractRateLimiterRepository
¶
Bases: ABC
Define the abstract repository for rate limiters.
__init__(**kwargs) -> None
¶
get(request: httpx.Request) -> AsyncLimiter
¶
Return a request-specific rate limiter.
get_identifier(request: httpx.Request) -> str
abstractmethod
¶
Return a request-specific identifier.
get_rate(request: httpx.Request) -> Rate
abstractmethod
¶
Return a request-specific rate.
AsyncMultiRateLimitedTransport
¶
Bases: AsyncBaseTransport
Define the asynchronous multiple rate-limited transport.
This transport consists of a composed transport for handling requests and a repository for rate limiters that are selected based on the request.
__init__(*, repository: AbstractRateLimiterRepository, transport: httpx.AsyncBaseTransport, **kwargs) -> None
¶
create(*, repository: AbstractRateLimiterRepository, **kwargs: dict) -> AsyncMultiRateLimitedTransport
classmethod
¶
Create an instance of an asynchronous multiple rate-limited transport.
This factory method constructs the instance with an underlying
httpx.AsyncHTTPTransport
.
That transport is passed any additional keyword arguments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repository
|
AbstractRateLimiterRepository
|
The repository to use for rate limiters. |
required |
**kwargs
|
dict
|
Additional keyword arguments are used in the construction of an
|
{}
|
Returns:
Type | Description |
---|---|
AsyncMultiRateLimitedTransport
|
A default instance of the class created from the given arguments. |
handle_async_request(request: httpx.Request) -> httpx.Response
async
¶
Handle an asynchronous request with rate limiting.