fastreq_async()¶
fastreq.client.fastreq_async
async
¶
fastreq_async(
urls: str | list[str],
*,
backend: BackendName | str = "auto",
concurrency: int = 20,
max_retries: int = 3,
rate_limit: float | None = None,
rate_limit_burst: int = 5,
http2: bool = True,
impersonate: str | None = None,
follow_redirects: bool = True,
verify_ssl: bool = True,
timeout: float | None = None,
cookies: dict[str, str] | None = None,
random_user_agent: bool = True,
random_proxy: bool = False,
proxies: list[str] | None = None,
proxy_selection: ProxySelection
| str = ProxySelection.ROUND_ROBIN,
proxy_cooldown: float = 60.0,
webshare_file: str | None = None,
headers: dict[str, str] | None = None,
debug: bool = False,
verbose: bool = True,
return_none_on_failure: bool = False,
method: str = "GET",
params: dict[str, Any] | None = None,
data: Any = None,
json: Any = None,
proxy: str | None = None,
return_type: ReturnType | str = ReturnType.JSON,
parse_func: Callable[[Any], Any] | None = None,
stream_callback: Callable[[bytes], Any] | None = None,
progress: ProgressOption = None,
progress_callback: ProgressCallback | None = None,
keys: list[str] | None = None,
) -> Any
Async convenience function for parallel requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urls
|
str | list[str]
|
Single URL or list of URLs to request |
required |
backend
|
BackendName | str
|
Backend to use ("auto", "niquests", "httpx") |
'auto'
|
concurrency
|
int
|
Maximum number of concurrent requests |
20
|
max_retries
|
int
|
Maximum retry attempts per request |
3
|
rate_limit
|
float | None
|
Requests per second (None for no limit) |
None
|
rate_limit_burst
|
int
|
Burst size for rate limiter |
5
|
http2
|
bool
|
Enable HTTP/2 (if supported by backend) |
True
|
follow_redirects
|
bool
|
Follow HTTP redirects |
True
|
verify_ssl
|
bool
|
Verify SSL certificates |
True
|
timeout
|
float | None
|
Default timeout per request (seconds) |
None
|
cookies
|
dict[str, str] | None
|
Initial session cookies |
None
|
random_user_agent
|
bool
|
Rotate user agents |
True
|
random_proxy
|
bool
|
Enable proxy rotation |
False
|
proxies
|
list[str] | None
|
List of proxy URLs for rotation |
None
|
proxy_selection
|
ProxySelection | str
|
Selection strategy ("round_robin" or "random") |
ROUND_ROBIN
|
proxy_cooldown
|
float
|
Seconds before retrying a failed proxy |
60.0
|
webshare_file
|
str | None
|
Path to a Webshare proxy text file |
None
|
headers
|
dict[str, str] | None
|
Default headers applied to all requests |
None
|
debug
|
bool
|
Enable the fastreq loguru namespace (never touches global sinks) |
False
|
verbose
|
bool
|
Enable verbose output (stored; progress-bar control) |
True
|
return_none_on_failure
|
bool
|
Return None instead of raising on failure |
False
|
method
|
str
|
HTTP method (GET, POST, etc.) |
'GET'
|
params
|
dict[str, Any] | None
|
Query parameters |
None
|
data
|
Any
|
Request body data |
None
|
json
|
Any
|
JSON body (serialized automatically) |
None
|
proxy
|
str | None
|
Explicit proxy URL (overrides rotation) |
None
|
return_type
|
ReturnType | str
|
How to parse the response |
JSON
|
parse_func
|
Callable[[Any], Any] | None
|
Custom function to parse each response |
None
|
stream_callback
|
Callable[[bytes], Any] | None
|
Callback for streaming responses |
None
|
progress
|
ProgressOption
|
Optional |
None
|
progress_callback
|
ProgressCallback | None
|
Optional callback receiving |
None
|
keys
|
list[str] | None
|
Keys for dict return (must match urls length) |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
Single URL → single result |
Any
|
List of URLs → list of results |
Any
|
List of URLs with keys → dict mapping keys to results |
Source code in fastreq/client.py
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | |