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. - There is no fixed maximum number of records per response. When the data volume of a response reaches a certain size (equivalent to 5,000,000 bytes), the response is split and a
pagination_keyis returned. - The number of records per response (page size) varies depending on internal processing, so it is not disclosed and is not guaranteed.
- The value of
pagination_keychanges each time pagination occurs. - No field returning the total number of records is provided. To retrieve all data, repeat requests until the
pagination_keyis no longer returned. - If no data matches the query, a response with HTTP 200 and an empty
dataarray is returned, and nopagination_keyis set. - If the data is updated while paginating, full consistency across the retrieved results is not guaranteed.