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/method
import 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_key will be set in the response message until all matching data for the query is returned. If the pagination_key is not set in the response message, it means that all matching data for the query has been returned.
  • The value of pagination_key changes each time pagination occurs.

Was this page helpful?