### HTTP GET Request Example for Querying Documentation Source: https://guide.data.gov.sg/developer-guide/dataset-apis/get-dataset-metadata.md This example demonstrates how to query the documentation dynamically by performing an HTTP GET request to the page URL with an 'ask' query parameter. This is useful for retrieving specific information or clarifications not explicitly present on the page. ```http GET https://guide.data.gov.sg/developer-guide/dataset-apis/get-dataset-metadata.md?ask= ``` -------------------------------- ### Querying Documentation Dynamically Source: https://guide.data.gov.sg/user-guide/for-data-owners/getting-started-onboarding.md Perform an HTTP GET request with the 'ask' query parameter to get direct answers and relevant excerpts from the documentation. ```http GET https://guide.data.gov.sg/user-guide/for-data-owners/getting-started-onboarding.md?ask= ``` -------------------------------- ### Query Documentation with GET Request Source: https://guide.data.gov.sg/developer-guide/api-overview/how-to-use-your-api-key.md To ask questions about the documentation, perform an HTTP GET request to the page URL with the `ask` query parameter. The question should be specific and in natural language. ```http GET https://guide.data.gov.sg/developer-guide/api-overview/how-to-use-your-api-key.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific, self-contained, and written in natural language. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. ```http GET https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://guide.data.gov.sg/user-guide/content-quality-guidelines.md Use this GET request to ask questions about the documentation. The response includes direct answers and relevant excerpts. ```http GET https://guide.data.gov.sg/user-guide/content-quality-guidelines.md?ask= ``` -------------------------------- ### Dynamic Documentation Query Source: https://guide.data.gov.sg/developer-guide/dataset-apis/search-and-filter-within-dataset.md Perform an HTTP GET request to query documentation dynamically. Include your question as the 'ask' query parameter. ```http GET https://guide.data.gov.sg/developer-guide/dataset-apis/search-and-filter-within-dataset.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://guide.data.gov.sg/introduction-to-data.gov.sg.md To get information not explicitly on the page, make an HTTP GET request to the page URL with an 'ask' query parameter. The question should be specific and in natural language. ```HTTP GET https://guide.data.gov.sg/introduction-to-data.gov.sg.md?ask= ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://guide.data.gov.sg/developer-guide To get specific information not directly on a page, make an HTTP GET request to the page URL with the 'ask' query parameter. The question should be in natural language. ```HTTP GET https://guide.data.gov.sg/developer-guide.md?ask= ``` -------------------------------- ### Query Documentation Source: https://guide.data.gov.sg/developer-guide/api-overview/deleting-and-expiring-api-keys.md To ask questions about the documentation or retrieve additional information, perform an HTTP GET request on the current page URL with the `ask` query parameter. ```http GET https://guide.data.gov.sg/developer-guide/api-overview/deleting-and-expiring-api-keys.md?ask= ``` -------------------------------- ### Querying Documentation Dynamically Source: https://guide.data.gov.sg/user-guide/for-data-consumers/how-to-embed-the-dataset-explorer-on-your-site.md Perform an HTTP GET request to query the documentation. The question should be specific and in natural language. The response includes a direct answer and relevant excerpts. ```http GET https://guide.data.gov.sg/user-guide/for-data-consumers/how-to-embed-the-dataset-explorer-on-your-site.md?ask= ``` -------------------------------- ### Ask a Question via HTTP GET Request Source: https://guide.data.gov.sg/llms.txt Use this method to query the documentation index for specific information. Append your question as a parameter to the documentation URL. ```HTTP GET https://guide.data.gov.sg/whats-new.md?ask= ``` -------------------------------- ### Example Dataset ID Extraction Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Demonstrates how to extract the datasetId from a dataset URL. This ID is required for constructing the API endpoints. ```text Example URL: https://data.gov.sg/datasets/d_07c63be0f37e6e59c07a4ddc2fd87fcb/view Dataset ID: d_07c63be0f37e6e59c07a4ddc2fd87fcb Constructed Endpoint: https://api-production.data.gov.sg/v2/admin/api/datasets/d_07c63be0f37e6e59c07a4ddc2fd87fcb/upload-link ``` -------------------------------- ### Make an API Request with Curl Source: https://guide.data.gov.sg/developer-guide/api-overview/how-to-use-your-api-key.md Use this command to make a GET request to the collections endpoint, including your API key in the `x-api-key` header. ```bash curl -X GET "https://api-production.data.gov.sg/v2/public/api/collections" \ -H "x-api-key: YOUR_API_KEY" ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://guide.data.gov.sg/developer-guide/dataset-apis.md To ask questions about the documentation and receive direct answers with relevant excerpts, perform an HTTP GET request to the page URL with the 'ask' query parameter. The question should be specific and self-contained. ```HTTP GET https://guide.data.gov.sg/developer-guide/dataset-apis.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://guide.data.gov.sg/user-guide/for-data-owners/making-datasets-easy-to-find.md Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. Use this when the answer is not explicitly present, you need clarification, or want to retrieve related sections. ```HTTP GET https://guide.data.gov.sg/user-guide/for-data-owners/making-datasets-easy-to-find.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://guide.data.gov.sg/developer-guide/dataset-apis/download-dataset.md Use this method to ask specific questions about the documentation when the answer is not explicitly present on the page. The question should be self-contained and in natural language. ```http GET https://guide.data.gov.sg/developer-guide/dataset-apis/download-dataset.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://guide.data.gov.sg/user-guide/for-data-consumers/how-to-raise-a-data-request.md Use this HTTP GET request to query the documentation when the answer is not explicitly present on the page, or when clarification or additional context is needed. The question should be specific, self-contained, and written in natural language. ```HTTP GET https://guide.data.gov.sg/user-guide/for-data-consumers/how-to-raise-a-data-request.md?ask= ``` -------------------------------- ### Get Collections Source: https://guide.data.gov.sg/developer-guide/api-overview/how-to-use-your-api-key.md This endpoint retrieves a list of available collections from the API. You need to include your API key in the request header for authentication. ```APIDOC ## GET /v2/public/api/collections ### Description Retrieves a list of available collections from the API. ### Method GET ### Endpoint /v2/public/api/collections ### Parameters #### Header Parameters - **x-api-key** (string) - Required - Your generated API key. ### Request Example ```curl curl -X GET "https://api-production.data.gov.sg/v2/public/api/collections" \ -H "x-api-key: YOUR_API_KEY" ``` ### Response #### Success Response (200) - **collections** (array) - A list of collections. ### Response Example ```json { "collections": [ { "id": "collection-id-1", "name": "Collection Name 1" }, { "id": "collection-id-2", "name": "Collection Name 2" } ] } ``` ``` -------------------------------- ### Verify API Connectivity Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Use this GET request to verify your API connectivity. Ensure your admin API key is included in the header. A 200 response indicates successful connection. ```http GET https://api-production.data.gov.sg/v2/admin/api/auth/whoami Host: api-production.data.gov.sg Authorization: Bearer YOUR_API_KEY ``` -------------------------------- ### Get Create Upload URL API Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Use this API to generate a pre-signed URL for uploading a new dataset or replacing an existing one entirely. The generated URL expires after 1 hour. ```bash GET /v2/admin/api/datasets/{datasetId}/upload-link ``` -------------------------------- ### Get Create Upload URL Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Generates a pre-signed URL to upload a new file for a dataset. This is used when replacing an existing dataset completely. The URL expires after 1 hour and the maximum file size is 1GB. ```APIDOC ## GET /v2/admin/api/datasets/{datasetId}/upload-link ### Description Generates a pre-signed URL for uploading a file to replace an existing dataset. ### Method GET ### Endpoint /v2/admin/api/datasets/{datasetId}/upload-link ### Parameters #### Path Parameters - **datasetId** (string) - Required - The ID of the dataset to upload to. ### Request Example (No request body for GET method) ### Response #### Success Response (200) - **upload_url** (string) - The pre-signed URL for uploading the file. - **expiry_timestamp** (string) - The timestamp when the URL expires. #### Response Example { "upload_url": "https://example.com/upload-url", "expiry_timestamp": "2024-02-20T10:00:00Z" } ``` -------------------------------- ### OpenAPI Specification for Datasets Listing Source: https://guide.data.gov.sg/developer-guide/dataset-apis/list-all-datasets.md This OpenAPI 3.0.3 specification defines the GET /v2/public/api/datasets endpoint, which allows retrieval of all available datasets. It includes details on parameters, responses, and data schemas. ```json { "openapi": "3.0.3", "info": { "title": "beta.data.gov.sg Public API", "version": "1.0.11" }, "tags": [ { "name": "datasets" } ], "servers": [ { "url": "https://api-production.data.gov.sg" } ], "paths": { "/v2/public/api/datasets": { "get": { "summary": "Get datasets", "tags": [ "datasets" ], "parameters": [ { "in": "query", "name": "page", "schema": { "type": "integer", "minimum": 1 }, "description": "Page number (optional, must be 1 or more)" } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object", "properties": { "datasets": { "type": "array", "items": { "type": "object", "properties": { "datasetId": { "type": "string" }, "createdAt": { "type": "string" }, "name": { "type": "string" }, "status": { "type": "string" }, "format": { "type": "string" }, "lastUpdatedAt": { "type": "string" }, "managedByAgencyName": { "type": "string" }, "coverageStart": { "type": "string" }, "coverageEnd": { "type": "string" } } } }, "pages": { "type": "integer" } } }, "errorMsg": { "type": "string" } } } } } } } } } } } ``` -------------------------------- ### Get Create Append URL API Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Use this API to generate a pre-signed URL for appending rows to an existing dataset. Ensure that the column data types and names match the existing dataset and that no new columns are added. The generated URL expires after 1 hour. ```bash GET /v2/admin/api/datasets/{datasetId}/append-link ``` -------------------------------- ### Get Create Append URL Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Generates a pre-signed URL for appending rows to an existing dataset. This method requires that the column data types and names are identical to the existing dataset, and no new columns are added. The URL expires after 1 hour and each uploaded file must be less than 1GB. ```APIDOC ## GET /v2/admin/api/datasets/{datasetId}/append-link ### Description Generates a pre-signed URL for appending rows to an existing dataset. Ensures column consistency. ### Method GET ### Endpoint /v2/admin/api/datasets/{datasetId}/append-link ### Parameters #### Path Parameters - **datasetId** (string) - Required - The ID of the dataset to append data to. ### Request Example (No request body for GET method) ### Response #### Success Response (200) - **append_url** (string) - The pre-signed URL for appending data. - **expiry_timestamp** (string) - The timestamp when the URL expires. #### Response Example { "append_url": "https://example.com/append-url", "expiry_timestamp": "2024-02-20T10:00:00Z" } ``` -------------------------------- ### Get Dataset Metadata Source: https://guide.data.gov.sg/developer-guide/dataset-apis/get-dataset-metadata.md Retrieves the metadata for a single dataset using its unique identifier. ```APIDOC ## GET /v2/public/api/datasets/{datasetId}/metadata ### Description Get metadata for a dataset ### Method GET ### Endpoint /v2/public/api/datasets/{datasetId}/metadata ### Parameters #### Path Parameters - **datasetId** (string) - Required - The unique identifier of the dataset ### Response #### Success Response (200) - **code** (integer) - **data** (object) - **datasetId** (string) - **createdAt** (string) - **name** (string) - **format** (string) - **lastUpdatedAt** (string) - **managedBy** (string) - **coverageStart** (string) - **coverageEnd** (string) - **columnMetadata** (object) - **order** (array of strings) - **map** (object with additional string properties) - **metaMapping** (object with additional object properties, each containing name (string), columnTitle (string), dataType (integer), index (string)) - **errorMsg** (string) ``` -------------------------------- ### GET /v2/public/api/collections Source: https://guide.data.gov.sg/developer-guide/collection-apis.md Retrieves a list of all collections available on data.gov.sg. Supports pagination via the 'page' query parameter. ```APIDOC ## GET /v2/public/api/collections ### Description This API returns a list of all the collections on data.gov.sg. ### Method GET ### Endpoint /v2/public/api/collections ### Parameters #### Query Parameters - **page** (integer) - Optional - Page number (must be 1 or more) ### Response #### Success Response (200) - **code** (integer) - **data** (object) - **collections** (array of objects) - **collectionId** (string) - **createdAt** (string) - **name** (string) - **description** (string) - **lastUpdatedAt** (string) - **coverageStart** (string) - **coverageEnd** (string) - **frequency** (string) - **sources** (array of strings) - **managedByAgencyName** (string) - **childDatasets** (array of strings) - **pages** (integer) - **errorMsg** (string) ``` -------------------------------- ### Get collection metadata Source: https://guide.data.gov.sg/developer-guide/collection-apis.md Retrieve metadata for a specific collection, optionally including dataset metadata. The collection ID is required. ```json { "openapi": "3.0.3", "info": { "title": "beta.data.gov.sg Public API", "version": "1.0.11" }, "tags": [ { "name": "collections" } ], "servers": [ { "url": "https://api-production.data.gov.sg" } ], "paths": { "/v2/public/api/collections/{collectionId}/metadata?withDatasetMetadata=true": { "get": { "summary": "Get metadata for a collection", "tags": [ "collections" ], "parameters": [ { "in": "path", "name": "collectionId", "required": true, "schema": { "type": "number" }, "description": "The unique identifier of the collection (number)" }, { "in": "query", "name": "withDatasetMetadata", "schema": { "type": "boolean" }, "description": "Include dataset metadata (true or false, default is false)" } ], "responses": { "200": { "description": "Successful response", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer" }, "data": { "type": "object", "properties": { "collectionMetadata": { "type": "object", "properties": { "collectionId": { "type": "string" }, "createdAt": { "type": "string" }, "name": { "type": "string" }, "description": { "type": "string" }, "lastUpdatedAt": { "type": "string" }, "coverageStart": { "type": "string" }, "coverageEnd": { "type": "string" }, "frequency": { "type": "string" }, "sources": { "type": "array", "items": { "type": "string" } }, "managedBy": { "type": "string" }, "childDatasets": { "type": "array", "items": { "type": "string" } } } }, "datasetMetadata": { "type": "array", "items": { "type": "object", "properties": { "datasetId": { "type": "string" }, "createdAt": { "type": "string" }, "name": { "type": "string" }, "format": { "type": "string" }, "lastUpdatedAt": { "type": "string" }, "managedBy": { "type": "string" }, "coverageStart": { "type": "string" }, "coverageEnd": { "type": "string" } } } } } }, "errorMsg": { "type": "string" } } } } } } } } } } } ``` -------------------------------- ### Query Documentation Dynamically Source: https://guide.data.gov.sg/user-guide/for-data-consumers/how-to-search-for-real-time-apis.md Use this method to ask questions about the documentation when the answer is not explicitly present on the page, or when you need clarification or additional context. ```http GET https://guide.data.gov.sg/user-guide/for-data-consumers/how-to-search-for-real-time-apis.md?ask= ``` -------------------------------- ### Make an API Request with Python Source: https://guide.data.gov.sg/developer-guide/api-overview/how-to-use-your-api-key.md This Python script demonstrates how to set the `x-api-key` header for an API request and print the JSON response. ```python import requests headers = {"x-api-key": "YOUR_API_KEY"} response = requests.get("https://api-production.data.gov.sg/v2/public/api/collections", headers=headers) print(response.json()) ``` -------------------------------- ### Initiate Dataset Download Source: https://guide.data.gov.sg/developer-guide/dataset-apis/download-dataset.md Initiates the download process for a specified dataset. This API can also accept optional filters for columns and rows to retrieve a subset of the dataset. ```APIDOC ## GET /v1/public/api/datasets/{datasetId}/initiate-download ### Description Initiate download for a dataset. This endpoint is used to start the download process for a given dataset ID. It supports optional filtering of columns and rows. ### Method GET ### Endpoint /v1/public/api/datasets/{datasetId}/initiate-download ### Parameters #### Path Parameters - **datasetId** (string) - Required - ID of the dataset #### Request Body - **columnNames** (array[string]) - Optional - List of selected columns in filtered dataset. - **filters** (array[object]) - Optional - Filters define how users want to filter their dataset. Filters is an array of objects which have `columnName`, `type` and `value` attributes. - `columnName` (string) - The column where the filter is to be applied. - `type` (string) - Can be `EQ`, `LIKE`, or `ILIKE`: - **EQ**: Direct comparison for filter and is case sensitive. - **LIKE**: Similar to EQ but includes partial matching. Any words containing the string in the `value` attribute will be matched. - **ILIKE**: Case-insensitive version of LIKE. ### Request Example ```json { "columnNames": [ "column1", "column2" ], "filters": [ { "columnName": "status", "type": "EQ", "value": "active" } ] } ``` ### Response #### Success Response (201) - **code** (integer) - Response code - **data** (object) - Contains the message of the response. - **message** (string) - Success message - **errorMsg** (string) - Error message (if any) #### Response Example ```json { "code": 200, "data": { "message": "Download initiated successfully." }, "errorMsg": null } ``` #### Error Response (400) - **code** (integer) - Response code - **name** (string) - Error type - **errorMsg** (string) - Error Message #### Error Response (429) - **code** (number) - **name** (string) - **data** (object) - **errorMsg** (string) - Rate limit exceeded ``` -------------------------------- ### Get Dataset Ingestion Status Source: https://guide.data.gov.sg/user-guide/for-data-owners/write-apis.md Retrieves the current status of the validation and ingestion process for a specific dataset. This is useful for monitoring the asynchronous data processing pipeline. ```APIDOC ## GET /v2/admin/api/datasets/{datasetId}/ingestion-status ### Description Retrieves the current status of the validation and ingestion process for a specific dataset. ### Method GET ### Endpoint /v2/admin/api/datasets/{datasetId}/ingestion-status ### Parameters #### Path Parameters - **datasetId** (string) - Required - The unique identifier of the dataset. ### Response #### Success Response (200) - **status** (string) - The current status of the ingestion process. Possible values include: Pending, Pending Validation, Validation Failed, Validation Passed, Pending Ingestion, Ingestion Failed, Ingestion Success. - **message** (string) - A descriptive message about the current status. ``` -------------------------------- ### GET /v2/public/api/collections/{collectionId}/metadata Source: https://guide.data.gov.sg/developer-guide/collection-apis.md Retrieves the metadata for a single collection, including details about the datasets within it. The `withDatasetMetadata` query parameter can be used to include dataset-specific metadata. ```APIDOC ## GET /v2/public/api/collections/{collectionId}/metadata ### Description This API returns the metadata of a single collection and the datasets within it. ### Method GET ### Endpoint /v2/public/api/collections/{collectionId}/metadata ### Parameters #### Path Parameters - **collectionId** (number) - Required - The unique identifier of the collection #### Query Parameters - **withDatasetMetadata** (boolean) - Optional - Include dataset metadata (true or false, default is false) ### Response #### Success Response (200) - **code** (integer) - **data** (object) - **collectionMetadata** (object) - **collectionId** (string) - **createdAt** (string) - **name** (string) - **description** (string) - **lastUpdatedAt** (string) - **coverageStart** (string) - **coverageEnd** (string) - **frequency** (string) - **sources** (array of strings) - **managedBy** (string) - **childDatasets** (array of strings) - **datasetMetadata** (array of objects) - **datasetId** (string) - **createdAt** (string) - **name** (string) - **format** (string) - **lastUpdatedAt** (string) - **managedBy** (string) - **coverageStart** (string) - **coverageEnd** (string) - **errorMsg** (string) ```