feat: surface Poly-RateLimit state on rate-limit errors and via on_rate_limit_update - #221
Merged
kartojal merged 4 commits intoAug 13, 2026
Conversation
…ed-python-sdk-clob-rate-limit-headers-poly-ratelimit # Conflicts: # src/polymarket/clients/async_secure.py # src/polymarket/clients/secure.py
kartojal
marked this pull request as ready for review
August 12, 2026 07:33
naruto11eth
approved these changes
Aug 13, 2026
naruto11eth
left a comment
Contributor
There was a problem hiding this comment.
Approved. One consumer-facing note: the listener type is sync and runs inline on the response path, so on AsyncSecureClient a slow callback blocks the event loop. Fine as a contract, just worth a line in the docstring saying callbacks must stay fast and non-blocking. And a small test gap if you're touching it again: the async transport has no 429/listener-isolation tests and the header parser has no malformed-value cases (Poly-RateLimit-Remaining: abc).
# Conflicts: # src/polymarket/clients/async_secure.py # src/polymarket/clients/secure.py
kartojal
deleted the
feature/dev-481-unified-python-sdk-clob-rate-limit-headers-poly-ratelimit
branch
August 13, 2026 17:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements DEV-481.
RateLimitErrornow carriesretry_after(fromRetry-After, matchingRequestRejectedError) andrate_limit, thePoly-RateLimit-*state reported with a 429 rejection.on_rate_limit_updateoption onSecureClient.create/AsyncSecureClient.create: a listener invoked whenever a response reports per-signer rate-limit state (remaining,reset,tier,warning), including warning-mode monitoring before live enforcement.https://linear.app/polymarket/issue/DEV-481
Note
Low Risk
Additive API and optional callback; RateLimitError gains optional fields with defaults, so existing catch/retry logic should remain compatible.
Overview
Adds per-signer rate-limit visibility from Polymarket
Poly-RateLimit-*response headers.HTTP transports parse those headers on every response and optionally invoke an
on_rate_limit_updatecallback with aRateLimitUpdate(remaining,reset,tier,warning). Listener failures are logged and do not fail the request.SecureClient.create/AsyncSecureClient.createaccept this listener and wire it to the CLOB transports used for trading.RateLimitErroron HTTP 429 now includesretry_after(fromRetry-After, aligned withRequestRejectedError) andrate_limitparsed from the same headers. New public typesRateLimitUpdateandRateLimitUpdateListenerare exported from the package root.Reviewed by Cursor Bugbot for commit 2c9cda3. Bugbot is set up for automated code reviews on this repo. Configure here.