Skip to content

API Cube

neilfromcork edited this page Mar 27, 2020 · 50 revisions

Home / API / Cube

Cube APIs are used for reading data and metadata. The API Cube Methods list with Parameters, Return examples.

ReadCollection

Returns a Collection of JsonStat items. Please refer to JSON-stat documentation for a full explanation of the structure: https://json-stat.org/format/

Authentication: Anonymous

Privilege : N/A

Method: PxStat.Data.Cube_API.ReadCollection

Parameters:

Name Type Default Description
language String null or empty ISO Language Code
datefrom Date ('YYYY-MM-DD') null or empty Date from details

Return: json

The Json format follow the JSON-Stat schema. Please refer to JSON-stat documentation. An example (containing just one dataset) is shown below:

{
    "jsonrpc": "2.0",
    "data": {
        "class": "collection",
        "link": {
            "item": [
                {
                    "dimension": {
                        "STATISTIC": {
                            "category": {},
                            "label": "STATISTIC"
                        },
                        "TLIST(A1)": {
                            "category": {
                                "index": [
                                    "2011",
                                    "2016"
                                ],
                                "label": {
                                    "2011": "2011",
                                    "2016": "2016"
                                }
                            },
                            "label": "Census Year"
                        },
                        "C01": {
                            "category": {},
                            "label": "Electoral Division"
                        },
                        "C02": {
                            "category": {},
                            "label": "Age of youngest child"
                        }
                    },
                    "extension": {
                        "copyright": {
                            "name": "Central Statistics Office, Ireland",
                            "code": "CSO",
                            "href": "https://www.cso.ie"
                        },
                        "emergency": true,
                        "language": {
                            "code": "en",
                            "name": "English"
                        },
                        "matrix": "SAPTHM4TBL4"
                    },
                    "href": "https://dev-data.cso.ie/table/SAPTHM4TBL4",
                    "id": [
                        "TLIST(A1)"
                    ],
                    "label": "Families by age of youngest child",
                    "role": {
                        "metric": [
                            "STATISTIC"
                        ],
                        "time": [
                            "TLIST(A1)"
                        ]
                    },
                    "size": [],
                    "updated": "2020-01-22T14:54:39.680Z"
                },
                {
                    "dimension": {
                        "STATISTIC": {
                            "category": {},
                            "label": "STATISTIC"
                        },
                        "TLIST(A1)": {
                            "category": {
                                "index": [
                                    
                                    "2015",
                                    "2016",
                                    "2017",
                                    "2018"
                                ],
                                "label": {
                                    
                                    "2015": "2015",
                                    "2016": "2016",
                                    "2017": "2017",
                                    "2018": "2018"
                                }
                            },
                            "label": "Year"
                        },
                        "C02196V02652": {
                            "category": {},
                            "label": "State"
                        }
                    },
                    "extension": {
                        "copyright": {
                            "name": "Central Statistics Office, Ireland",
                            "code": "CSO",
                            "href": "https://www.cso.ie"
                        },
                        "emergency": true,
                        "language": {
                            "code": "en",
                            "name": "English"
                        },
                        "matrix": "CPA05"
                    },
                    "href": "https://dev-data.cso.ie/table/CPA05",
                    "id": [
                        "TLIST(A1)"
                    ],
                    "label": "Purchasing Power",
                    "role": {
                        "metric": [
                            "STATISTIC"
                        ],
                        "time": [
                            "TLIST(A1)"
                        ]
                    },
                    "size": [],
                    "updated": "2020-01-22T16:28:38.937Z"
                }
            ]
        },
        "version": "2.0"
    },
    "id": "2"
}

ReadDataset

Reads a live dataset based on specific criteria. Please refer to JSON-stat documentation for a full explanation of the structure: https://json-stat.org/format/

Authentication: Anonymous

Privilege : N/A

Method: PxStat.Data.Cube_API.ReadDataset

Parameters:

Parameters must conform to the JSON-stat query schema. See query schema Additionally PxStat requires the following structure in the extension object

Name Type Default Description
matrix string matrix code of the dataset being queried
language Object See language object below
format Object See format object below

An example request call with the parameter:

{
	"jsonrpc": "2.0",
	"method": "PxStat.Data.Cube_API.ReadDataset",
	"params": {
  "class": "query",
  "id": [ "STATISTIC", "TLIST(A1)", "C02199V02655", "C02466V02984" ],
  "dimension": {
    "STATISTIC": {
      "category": {
        "index": [ "752c208d80db697b2dc8fd2463a0c137" ]
      }
    },
    "TLIST(A1)": {
      "category": {
        "index": [ "2047", "2048", "2049", "2050", "2051" ]
      }
    },
    "C02199V02655": {
      "category": {
        "index": [ "1", "2" ]
      }
    },
    "C02466V02984": {
      "category": {
        "index": [ "03", "04", "05" ]
      }
    }
  },
  "extension": {
    "matrix": "LIAMTESTPEC18",
    "language": {
      "code": "en",
      "culture": "fr-CH"
    },
    "format": {
      "type": "XLSX",
      "version": "2007"
    }
  },
  "version": "2.0"
}
}

Return: JSON-stat or PX or csv depending on the chosen format input parameter


ReadMetadata

Reads the metadata for a live dataset based on specific criteria. Please refer to JSON-stat documentation for a full explanation of the structure: https://json-stat.org/format/

Authentication: Anonymous

Privilege : N/A

Method: PxStat.Data.Cube_API.ReadMetadata

Parameters:

Name Type Default Description
matrix String Matrix Code
release Int null Release Number
format format object null (see below)
language String en* LngIsoCode e.g. "en"
role JSON-stat role null See JSON-stat documentation
dimension JSON-stat dimension null See JSON-stat documentation
m2m boolean true m2m

Format object:

Name Type Default Description
type String JSON-stat* JSON-stat or PX or csv
version String x.y Version of the format, e.g 2.0
*This default may vary depending on API configuration

An example request call with the parameter:

{
    "jsonrpc": "2.0",
    "method": "PxStat.Data.Cube_API.ReadDataset",
    "params": {
       "matrix": "CPA05",
       "format": {
       "type": "JSON-stat",
       "version": "2.0"
      },
       "language": "en",
       "m2m": false
},
    "id": "2"
}

Return: Metadata in JSON-stat format. (JSON-stat or PX or csv)


ReadPreDataset

Reads any Dataset (including pre-release data) based on Release Code and other criteria. Please refer to JSON-stat documentation for a full explanation of the structure: https://json-stat.org/format/

Authentication: Windows

Privilege : N/A

Method: PxStat.Data.Cube_API.ReadPreDataset

Parameters:

Name Type Default Description
release Int null Release Code
format format object null (see below)
language String en* LngIsoCode e.g. "en"
role JSON-stat role null See JSON-stat documentation
dimension JSON-stat dimension null See JSON-stat documentation
m2m boolean true m2m

Format object:

Name Type Default Description
type String JSON-stat* JSON-stat or PX or csv
version String x.y Version of the format, e.g 2.0

*These defaults may vary depending on API configuration

An example request call with the parameter:

{
    "jsonrpc": "2.0",
    "method": "PxStat.Data.Cube_API.ReadPreDataset",
    "params": {
        "release": "4",
        "language": "en",
        "format": {
       "type": "JSON-stat",
       "version": "2.0"
      },
        "role": {
            "time": [
                "TLIST(M1)"
            ],
            "metric": [
                "Statistic"
            ]
        },
        "dimension": [
            {
                "id": "TLIST(M1)",
                "category": {
                    "index": [
                        "201403"
                    ]
                }
            },
            {
                "id": "C03056V03691",
                "category": {
                    "index": [
                        "03"
                    ]
                }
            }
        ],
        "m2m": false
    },
    "id": "2"
}

Return: JSON-stat or PX or csv depending on the chosen format input parameter


ReadPreMetadata

Reads the metadata for a non live dataset based on Release code and other criteria. Please refer to JSON-stat documentation for a full explanation of the structure: https://json-stat.org/format/

Authentication: Windows

Privilege : Administrator , Moderator , Power User

Method: PxStat.Data.Cube_API.ReadPreMetadata

Parameters:

Name Type Default Description
matrix String Matrix code
format format object null (see below)
release Int null Release Number
language String en* LngIsoCode e.g. "en"
role JSON-stat role null See JSON-stat documentation
dimension JSON-stat dimension null See JSON-stat documentation
m2m boolean true m2m

Format object:

Name Type Default Description
type String JSON-stat* JSON-stat or PX or csv
version String x.y Version of the format, e.g 2.0

*This default may vary depending on API configuration

An example request call with the parameter:

{
    "jsonrpc": "2.0",
    "method": "PxStat.Data.Cube_API.ReadPreMetadata",
    "params": {
        "release": "3",
       "format": {
       "type": "JSON-stat",
       "version": "2.0"
      },
       "language": "en",
       "m2m": false
},
    "id": "2"
}

Return: JSON-stat or PX or csv depending on the chosen format input parameter

Clone this wiki locally