Sessions¶
A Session ties an authorizer to a requestor and exposes the
Session.request() method that PRAW uses to communicate with Reddit. The
session() helper is the recommended way to construct one.
- prawcore.sessions.session(authorizer=None, window_size=600)¶
Return a
Sessioninstance.- Parameters:
authorizer (
BaseAuthorizer|None) – An instance ofBaseAuthorizer.window_size (
int) – The size of the rate limit reset window in seconds.
- Return type:
- class prawcore.sessions.Session(authorizer, window_size=600)¶
The low-level connection interface to Reddit’s API.
- Parameters:
authorizer (BaseAuthorizer | None)
window_size (int)
- property authorizer: BaseAuthorizer¶
Return the
BaseAuthorizerused to authorize requests.
- property rate_limiter: RateLimiter¶
Return the
RateLimiterthat throttles requests.
- request(method, path, data=None, files=None, json=None, params=None, timeout=16.0)¶
Return the json content from the resource at
path.- Parameters:
method (
str) – The request verb. E.g.,"GET","POST","PUT".path (
str) – The path of the request. This path will be combined with theoauth_urlof the Requestor.data (
dict[str,object] |bytes|IO[Any] |str|None) – Dictionary, bytes, or file-like object to send in the body of the request.files (
dict[str,IO[Any]] |None) – Dictionary, mappingfilenameto file-like object.json (
dict[str,object] |list[object] |None) – Object to be serialized to JSON in the body of the request.params (
Mapping[str,object] |None) – The query parameters to send with the request.timeout (
float) – Specifies a particular timeout, in seconds.
- Return type:
Automatically refreshes the access token if it becomes invalid and a refresh token is available.
- Raises:
InvalidInvocationin such a case if a refresh token is not available.- Parameters:
- Return type: