导航菜单
首页 >  datagovmy  > Data Catalogue

Data Catalogue

Static APIsData Catalogue APIData Catalogue API EndpointGET https://api.data.gov.my/data-catalogueWhat does Data Catalogue API do?

The Data Catalogue API is designed to allow users to access data from the data catalogue programmatically.It provides a set of endpoints that can be used to query the data based on various parameters and filters.The API is meant for use by developers and data scientists who want to programmatically access the data catalogue, although users who want to download data directly can also refer to the Data Catalogue page.

How to Find Available Datasets

To access specific data catalogue, you need to specify the id parameter in your request URL.It's a required parameter, here's an example of how to use it:

GET https://api.data.gov.my/data-catalogue?id=fuelprice

To discover the available datasets, visit the Data Catalogue page (opens in a new tab), where datasets are categorised and listed.To find out more about each dataset, click on the dataset page. On each dataset page, there is a section at the bottom titled "Sample OpenAPI query," which contains the necessary id for each data catalogue.If a data catalogue is not available through the API, it will be explicitly mentioned.

Request Query & Response Format

To filter and request data, use the standard filtering operations in the Request Query.You can find information about the available filterable columns in the Metadata section under each Data Catalogue page.For information on how the API responds to your requests, refer to the Response Format section.

Example Request

Let's walk through an example using the fuelprice resource:

1. Finding the Resource

Go to the Data Catalogue page and find the Diesel Price dataset (opens in a new tab).Alternatively, you can also use the same id for two other fuel prices, RON95 (opens in a new tab) and RON97 (opens in a new tab), which are part of the same dataset.You'll find the id value, "fuelprice," in the "Sample OpenAPI query" section at the bottom of the page. We will use this id for our example.

2. Sending the API Request

To fetch data from the API, use the following curl command. Open your terminal and enter this command:

curl --location 'http://api.data.gov.my/data-catalogue?id=fuelprice&limit=3'

Executing this command will send a request to the API, specifically targeting the fuelprice dataset, and limiting the response to the first 3 records.For more available filters, please refer to Request Query section.

3. Understanding the Response

To make sense of the API's response, you can refer to the Response Format section.It provides a detailed explanation of what the API response means.In this example, the total length of this list will be 3, as specified by the limit parameter.

相关推荐: