Client for interacting with the SingStat APIs.

Example usage:

# list all available packages
from singstat import Client
client = Client()
resources = client.resource_id()


class singstat.client.Client

Bases: object

Interact with SingStat’s API to access its catalogue of datasets.



Return the metadata of a resource.


resource_id (str) – ID of the resource.


(dict) Metadata of the requested resource.

resource_id(keyword='%', search_option='All')

Search for a list of resources.

  • keyword (str) – (optional) Keyword to search resources by. Default: “%”, i.e. don’t search by any specific keyword.

  • search_option (str) –

    (optional) Where to search the keyword in.
    • ”All”: search in all resources.

    • ”Title”: search in resource titles only.

    • ”Variable”: search in resource variables only.

    Default: “All”.


(dict) List of resources.

tabledata(resource_id, variables=[], between=[], sort_by=None, offset=0, limit=2000, time_filter=[], search=None)

Retrieve data in a resource.

  • resource_id (str) – ID of the resource.

  • variables (list) – (optional) variables to retrieve. Example: [“variableCode 1”, “variableCode 2”, …].

  • between (list) – (optional) Data value range to be returned. Example: [1560, 1677].

  • sort_by (str) – (optional) Comma-separated field names with ordering. Example: “variableCode,level desc”.

  • offset (int) – (optional) Offset this number of records. Default: 0.

  • limit (int) – (optional) Number of records to return. Maximum is 2,000. Default: 2000.

  • time_filter (list) –

    (optional) Time points for the selected table. Examples:
    • Monthly table: [“2018 Mar”]

    • Quarterly table: [“2017 4Q”, “2018 1Q”]

    • Half yearly table: [“2018 H1”]

    • Annual table: [“2017”, “2018”]

  • search (str) – (optional) Text to search for records.


(dict) Records of data that match the search criteria.