Loading...

How to use the Opendata API on this site

This site uses GraphQL to provide the Opendata API. This page shows how to use it.


Basic Specifications

  • It is provided under the a01sa01to.com domain without "www."
  • It is provided over HTTPS.
  • All dates and times are in Japan time (UTC+09:00).
  • The response header is set to the following header.
    • Access-Control-Allow-Origin: *
    • Access-Control-Allow-Methods: GET, POST, OPTIONS
    • Access-Control-Allow-Headers: Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization
  • If you have any questions or requests, please send them to info@a01sa01to.com .

Get the raw data.

This site provides an API as the Opendata API, but you can also retrieve raw data without using the API.

The Opendata API using GraphQL allows you to retrieve only the data you need, but there may be times when you prefer the raw data for compatibility and other reasons. In such a case, the following procedure can be used to retrieve the data.

  1. Access the page of the open data you want to use.
  2. Read the information about the file and precautions for use carefully, and scroll down.
  3. Download screen

    Click "Copy" to copy the download link for the raw data. Click "Download" to download the raw data from the URL provided.

Use the Opendata API (recommended)

Endpoint

The Opendata API, using GraphQL, is a single endpoint for accessing any data. The data is returned in JSON format.

https://a01sa01to.com/api/opendata/

Communicating with the Opendata API

In GraphQL operations, you will be dealing with multi-line JSON. For this reason, I recommend using Playground(link in site) . In this Playground, you can see a description of each data query and copy the cURL code. Of course, you can also use various libraries, such as cURL, without using this Playground.

Basically, you will communicate with the Opendata API using the POST method. To send a query using cURL, send a POST request with a JSON payload. The format is as follows. Please escape newline characters as appropriate. Also, for the [YOUR QUERY HERE] part, replace it with the query listed on each page.
curl 'https://a01sa01to.com/api/opendata/' -X POST -d '{"query": "[YOUR QUERY HERE]"}'

About queries

GraphQL returns only the data specified in the query. In other words, by deleting unnecessary data from the query, only the necessary data can be retrieved. As a result, it is expected to reduce data traffic and other effects. For details on the data returned, please refer to the respective data page.

About pagination

This API supports the "Pagination" function, which returns a large amount of data in multiple pages for some data.

The pagination function is used by specifying one of the following four arguments. Basically, you can use a combination of [before] and [last], or a combination of [first] and [after].
  • before Return the data before the specified cursor (without the cursor's data)
  • after Return data after the specified cursor (without the cursor's data)
  • first Count forwards and return the specified number of data.
  • last Count backwards and return the specified number of data.
The cursor can be obtained from the pageinfo of the data; the data available in pageinfo is as follows
  • hasPreviousPage Whether or not there is a previous page
  • hasNextPage Whether there is a next page or not
  • startCursor The cursor of the top data of the currently displayed page.
  • endCursor The cursor of the last data on the currently displayed page.

In the corresponding query for each data, you may find a part that says [PAGINATION INFO]. Write that part as follows. However, you can change it as you see fit by deleting arguments that are not used, or replacing the [CURSOR] and [NUMBER] parts.
([PAGINATION INFO])
(before: [CURSOR], after: [CURSOR], first: [NUMBER], last: [NUMBER])
If you don't need the pagination function and want to get all the data at once, delete the ([PAGINATION INFO]) part entirely.

Image of the pagination function

Main uses of the pagination function