Skip to content
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

watchlists.v1.list_members only returns first 100 elements #129

Open
csanders-git opened this issue Jul 20, 2024 · 1 comment
Open

watchlists.v1.list_members only returns first 100 elements #129

csanders-git opened this issue Jul 20, 2024 · 1 comment

Comments

@csanders-git
Copy link

It appears that list_members returns by default 100 users. Watchlists may contain over 100 users. There is no pagination documented in the code or docs. The total_count parameter returns the proper number of users.

The API reference page for v1 doesn't indicate that pagination is supported, however the v2 version does. My guess is that during the update to support v2, developers broke v1 functionality. As a result, v2 endpoints should be supported to ensure functionality remains as the SDK is unable to fetch watchlist members given current functionality as a result.

@csanders-git
Copy link
Author

quick dirty little hack to make this type of this work (obviously could be used with all v2 APIs, though probably most haven't broken v1 APIs)

    url = f"{client._settings.url}/v2/watchlists/{watchlist_id}/members"
    headers = {
        "content-type": "application/json",
        "authorization": f"Bearer {client._session.auth.token_response.access_token._secret_value}"
    }
    # Initial request for length
    params = {"page": 1, "page_size": 1}
    watchlist_members = []
    total_count = requests.get(url, params=params, headers=headers).json()['totalCount']
    
    page_num = 1
    while len(watchlist_members) < total_count:
        params = {"page": page_num, "page_size": 1000}
        watchlist_members += requests.get(url, params=params, headers=headers).json()['watchlistMembers']
        page_num += 1

Obviously a bit ugly, but it'll do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant