Automatic pagination in PubChemAPI.get_data
#21
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PubChemAPI.get_dataclaims to fetch all data whenpage=None, but it doesn't actually paginate. It makes a single request without a page parameter, and PubChem returns only page 1 by default. The response includesPageandTotalPagesfields that tell you exactly how many pages exist. We're ignoring them.Scope
When
page=None, fetch page 1, readTotalPagesfrom the response, then fetch pages 2 throughTotalPagesand concatenate the annotation lists. Respect rate limits (Issue 13). Add amax_pagesparameter to cap pagination for testing and for large annotations. Log progress:"Fetching page {n}/{total} for {annotation}".Definition of done
PubChemAPI.get_data(Annotation.DISSOCIATION_CONSTANTS)with no page argument returns all pages.max_pagesworks. Tested with mock responses simulating multi-page results.