Skip to content

Argument limit not working when using list_ticker_news #865

@AirswitchAsa

Description

@AirswitchAsa

Describe the bug

I found that the argument limit is not working when I query for news using list_ticker_news.

To Reproduce

Steps to reproduce the behavior:

  1. Create a polygon python client
  2. Use list_ticker_news with limit
  3. Iterate the query results
  4. Check how many items were fetched

Expected behavior

Exactly limit number of results are displayed

Screenshots

Image

Additional context

I think it may be related to #858

Activity

justinpolygon

justinpolygon commented on Jul 7, 2025

@justinpolygon
Contributor

Hey @AirswitchAsa,

Thanks for reporting this. The behavior you're seeing is due to the client automatically paginating results behind the scenes. In this mode, the limit parameter controls the page size, not the total number of results. The good news is that we just release v1.15.0, and we’ve added a new top-level pagination flag you can use when creating the RESTClient. If you set pagination=False, it disables auto-pagination and treats limit as a hard cap on the number of results returned.

Here’s an example:

from polygon import RESTClient

client = RESTClient(api_key="YOUR_API_KEY", trace=True, pagination=False)

news = []
for item in client.list_ticker_news("AAPL", limit=3):
    news.append(item)

print(news)

To use this, make sure you're on the latest client:

pip install -U polygon-api-client

You can read more about the pagination behavior and how it works in the docs.

Let me know if that helps or if you run into anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @AirswitchAsa@justinpolygon

      Issue actions

        Argument limit not working when using list_ticker_news · Issue #865 · polygon-io/client-python