Skip to content

Adds proxy support #890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Adds proxy support #890

wants to merge 1 commit into from

Conversation

justinpolygon
Copy link
Contributor

This PR introduces a new proxy feature to the Polygon API client. Previously, the base parameter was used mostly for internal testing, allowing us to switch between development and production endpoints (e.g., changing the base host to point to something else). However, it was never intended to be used as a proxy, which caused confusion or limitations for users needing proxy support.

To better serve your use-case, we’ve added a dedicated proxy parameter to the BaseClient constructor. This new feature allows users to route API requests through a proxy server while keeping the base parameter focused on specifying the API endpoint.

Here's what changed:

  • Added an optional proxy parameter to the BaseClient constructor.
  • When a proxy is specified, the client uses urllib3.ProxyManager to route requests through the proxy.
  • The base parameter retains its original purpose for defining the API endpoint (e.g., https://api.polygon.io for production).

This feature is designed for users like you who need to access the Polygon API through a proxy, whether for network security, monitoring, or organizational policies. It provides a clear and supported way to handle proxy configurations without misusing the base parameter.

Here’s how you can use the new proxy feature:

from polygon import RESTClient

# Initialize the client with a proxy
client = RESTClient(
    api_key="your_api_key",
    base="https://api.polygon.io",  # API endpoint
    proxy="http://proxy.example.com:8080",  # Proxy server
    trace=True
)

I'm checking to make sure this addition meets your needs for proxy support. By separating base (for endpoints) and proxy (for routing), the client remains flexible and intuitive. Let us know if this aligns with your use-case or if there’s anything else we can adjust.

@justinpolygon justinpolygon added the don't merge Not ready to be merged at this time label Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
don't merge Not ready to be merged at this time
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant