prawcore follows semantic versioning.
Changed
- Make every public parameter either keyword-only or positional-only. The
requestor,authenticator, andauthorizersubjects of the authenticator and authorizer classes, the parameters of :class:`.Requestor`, :meth:`.Session.request`, and :meth:`.BaseAuthenticator.authorize_url`, theonly_accessargument of :meth:`.Authorizer.revoke`, and thesessionfactory are now keyword-only, while the single obvious operand of a method (such as thetokenargument of :meth:`.BaseAuthenticator.revoke_token`, thecodeargument of :meth:`.Authorizer.authorize`, and theresponseargument of the exception classes) is positional-only.
Added
- Add Sphinx-based documentation, published at https://prawcore.readthedocs.io/.
Changed
- Improve source docstrings and type annotations so that references render cleanly in the new documentation.
Added
- Add an
__all__to theprawcorepackage to explicitly define its public API. - Add a
py.typedmarker (PEP 561) so that downstream projects can type check against prawcore's inline annotations. - Add read-only :attr:`.Session.authorizer`, :attr:`.Session.rate_limiter`, and :attr:`.Session.requestor` properties, a :attr:`.BaseAuthorizer.authenticator` property, and a :attr:`.BaseAuthenticator.requestor` property, so that downstream code can reach these objects without accessing protected attributes.
Changed
- Widen the
authorizerparameter of :func:`.session` toBaseAuthorizerto match :class:`.Session`, so that passing an :class:`.ImplicitAuthorizer` or :class:`.DeviceIDAuthorizer` type checks. - Widen the
data,files,json, andparamsparameter annotations of :meth:`.Session.request` to reflect the values it already accepts at runtime (for example a non-dictdatabody, alistjsonpayload, and anyIOfile object), so that callers no longer need to cast these arguments.
Added
- Add support for Python 3.14.
Changed
- Drop support for Python 3.9, which was end-of-life on 2025-10-31.
- Migrate the test suite from Betamax to VCR.py, enabling urllib3 2.x in the test environment. Existing cassettes were converted without re-recording.
Changed
- Improved type hinting.
Fixed
- Increase half-second delay introduced in
3.0.0to a full second delay.
Changed
- Drop support for Python 3.8, which was end-of-life on 2024-10-07.
- :class:`.RateLimiter` attribute
next_request_timestamphas been removed and replaced withnext_request_timestamp_ns.
Fixed
- Add a half-second delay when there are no more requests in the rate limit window and the window has zero seconds remaining to avoid a semi-rare case where Reddit will return a 429 response resulting in a :class:`.TooManyRequests` exception.
Removed
- Remove :class:`.RateLimiter` attribute
reset_timestamp.
Changed
- Drop support for Python 3.6, which was end-of-life on 2021-12-23.
- Updated rate limit algorithm to better handle Reddit's new rate limits.
- Drop support for Python 3.7, which was end-of-life on 2023-06-27.
Added
- 301 redirects result in a
Redirectexception. - :class:`.Requestor` is now initialized with a
timeoutparameter. - :class:`.ScriptAuthorizer`, :class:`.ReadOnlyAuthorizer`, and
:class:`.DeviceIDAuthorizer` have a new parameter,
scopes, which determines the scope of access requests. - Retry 408 "Request Timeout" HTTP responses.
Changed
- :class:`.DeviceIDAuthorizer` can be now used with :class:`.TrustedAuthenticator`.
Added
- Support 202 "Accepted" HTTP responses.
Fixed
- The expected HTTP response status code for a request made with the proper credentials to api/v1/revoke_token has been changed from 204 to 200.
Added
- Add a :class:`.URITooLong` exception.
- :class:`.ScriptAuthorizer` has a new parameter
two_factor_callbackthat supplies OTPs (One-Time Passcodes) when :meth:`.ScriptAuthorizer.refresh` is called. - Add a :class:`.TooManyRequests` exception.
Added
- :class:`.Authorizer` optionally takes a
pre_refresh_callbackkeyword argument. If provided, the function will called with the instance of :class:`.Authorizer` prior to refreshing the access and refresh tokens. - :class:`.Authorizer` optionally takes a
post_refresh_callbackkeyword argument. If provided, the function will called with the instance of :class:`.Authorizer` after refreshing the access and refresh tokens.
Changed
- The
refresh_tokenargument to :class:`.Authorizer` must now be passed by keyword, and cannot be passed as a positional argument.
Changed
- Drop support for Python 3.5, which was end-of-life on 2020-09-13.
Added
- When calling :meth:`.Session.request`, we add the key-value pair
"api_type": "json"to thejsonparameter, if it is adict.
Changed
- (Non-breaking) Requests to
www.reddit.comuse theConnection: closeheader to avoid warnings when tokens are refreshed after their one-hour expiration.
Added
- All other requestor methods, most notably :meth:`.Session.request`, now contain a
timeoutparameter.
Added
- :meth:`.Requestor.request` can be given a timeout parameter to control the amount of time to wait for a request to succeed.
Changed
- Updated rate limit algorithm to more intelligently rate limit when there are extra requests remaining.
- Drop python 2.7 support.
Fixed
- :class:`.RateLimiter` will not sleep longer than
next_request_timestamp.
I am releasing 1.0.0 as prawcore is quite stable and it's unlikely that any breaking changes will need to be introduced in the near future.
Added
- Log debug messages for all sleep times.
Added
SpecialErroris raised on HTTP 415.
Added
ReadTimeoutis automatically retried like the server errors.
Changed
- Drop support for Python 3.3 as it is no longer supported by requests.
Added
UnavailableForLegalReasonsexception raised when HTTP Response 451 is encountered.
Added
BadJSONexception for the rare cases that a response that should contain valid JSON has unparsable JSON.
Added
Conflictexception is raised when response status 409 is returned.
Fixed
InvalidTokenis again raised on 401 when a non-refreshable application is in use.
Added
ConnectionErrorexceptions are automatically retried. This handlesConnection Reset by Peerissues that appear to occur somewhat frequently when running on Amazon EC2.
Changed
- Calling
RateLimiternow requires a second positional argument,set_header_callback. - In the event a 401 unauthorized occurs, the access token is cleared and the request is retried.
Fixed
- Check if the access token is expired immediately before every authorized request,rather than just before the request flow. This new approach accounts for failure retries, and rate limiter delay.
Added
- Add
sessionparameter to Requestor to ease support of custom sessions (e.g. caching or mock ones).
Added
- Handle 413 Request entity too large responses.
reset_timestamptoRateLimiter.
Fixed
- Avoid modifying passed in
dataandparamstoSession.request.
Added
ChunkedEncodingError is automatically retried like the server errors.
Added
- Handle 500 responses.
- Handle Cloudflare 520 responses.
Added
All network requests now have a 16 second timeout by default. The environment variable
prawcore_timeout can be used to adjust the value.
Changed
- Prevent '(None)' from appearing in OAuthException message.
Added
- Add
filesparameter toSession.requestto support image upload operations. - Add
durationandimplicitparameters toUntrustedAuthenticator.authorization_urlso that the method also supports the code grant flow.
Fixed
- :class:`.Authorizer` class can be used with :class:`.UntrustedAuthenticator`.
Fixed
sessionworks with :class:`.DeviceIDAuthorizer` and :class:`.ImplicitAuthorizer`.
Added
Changed
- Split
Authenticatorinto :class:`.TrustedAuthenticator` and :class:`.UntrustedAuthenticator`.
Added
- Add :class:`.DeviceIDAuthorizer` that permits installed application access to the API.
Added
RequestExceptionwhich wraps all exceptions that occur fromrequests.requestin aprawcore.RequestException.
Changed
- What was previously
RequestExceptionis nowResponseException.
Added
- Handle Cloudflare 522 responses.
Added
- Add
ServerErrorexception for 502, 503, and 504 HTTP status codes that is only raised after three failed attempts to make the request. - Add
jsonparameter toSession.request.
Added
- Automatically attempt to refresh access tokens when making a request if the access token is expired.
Fixed
- Consider access tokens expired slightly earlier than allowed for to prevent InvalidToken exceptions from occuring.
Added
- Handle 0-byte HTTP 200 responses.
Added
- Add a
NotFoundexception. - Support 404 "Not Found" HTTP responses.
Added
- Add a
BadRequestexception. - Support 400 "Bad Request" HTTP responses.
- Support 204 "No Content" HTTP responses.
Added
- Support 201 "Created" HTTP responses used in some v1 endpoints.
Added
- Sort
Session.requestdatavalues. Sorting the values permits betamax body matcher to work as expected.
Added
- Added
dataparameter toSession.request.
Fixed
- prawcore objects can be pickled.
Added
- 302 redirects result in a
Redirectexception.
Added
- Add a generic
Forbiddenexception for 403 responses without thewww-authenticateheader.
Added
- Added
paramsparameter toSession.request. - Log requests to the
prawcorelogger in debug mode.
Fixed
- README.rst for display purposes on pypi.
Added
- Dynamic rate limiting based on reddit's response headers.
- Authorization URL generation.
- Retrieval of access and refresh tokens from authorization grants.
- Access and refresh token revocation.
- Retrieval of read-only access tokens.
- Retrieval of script-app tokens.
- Three examples in the
examples/directory.