# Collection APIs

### Collections listing

This API returns a list of all the collections on data.gov.sg

## GET /v2/public/api/collections

> Get collections

```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":{"get":{"summary":"Get collections","tags":["collections"],"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":{"collections":{"type":"array","items":{"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"}},"managedByAgencyName":{"type":"string"},"childDatasets":{"type":"array","items":{"type":"string"}}}}},"pages":{"type":"integer"}}},"errorMsg":{"type":"string"}}}}}}}}}}}
```

### Collection metadata

This API returns the metadata of a single collection and the datasets within it

## GET /v2/public/api/collections/{collectionId}/metadata?withDatasetMetadata=true

> Get metadata for a collection

```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"}}}}}}}}}}}
```

{% hint style="info" %}
To find the collectionId, refer to the URL of collection.\
\
For this collection:\
<https://beta.data.gov.sg/collections/522/view>\
\
The collectionId is:\
`522`
{% endhint %}
