Response Pagination
When an API response becomes large, a pagination_key may be set in the response. If a pagination_key is set, you can retrieve subsequent data by executing a request with the pagination_key set in the next query without changing the search conditions. Please refer to the sample code for each API for the response format.
Request
GET
/v2/methodimport requests
headers = {"x-api-key": "{loading}"}
r_get = requests.get(
"https://api.jquants.com/v2/method?query=param",
headers=headers,
)
data = r_get.json()["data"]
while "pagination_key" in r_get.json():
pagination_key = r_get.json()["pagination_key"]
r_get = requests.get(
f"https://api.jquants.com/v2/method?query=param&pagination_key={pagination_key}",
headers=headers,
)
data += r_get.json()["data"]- The
pagination_keywill be set in the response message until all matching data for the query is returned. If thepagination_keyis not set in the response message, it means that all matching data for the query has been returned. - The value of
pagination_keychanges each time pagination occurs.