An error occured. Details Hide
You have unsaved pages. Restore Cancel

Get data (Pivot API)

This endpoint returns dataset's data in pivot table format.

Input

The input data should specify dataset id and pivot header/stub/filter components. For header/stub it should be arrays of header/stub items where dimension field is mandatory and members field is optional. If no members specified in header/stub item it means all dimension members should be included in the request. Filter request should be array of filter items. Each filter item should have dimension and members field. Only single member can be specified for filter item. The dimension cannot be included into header/stub/filter at the same time.

Result

The output of this endpoint is array of tuples. For each header/stub dimension there will be corresponding tuple field and also value field. Stub fields will be included in the order of their definition in request followed by header fields in the order of their definition in request. Tuples will follow the value order defined in request, i.e. tuples for values listed first will be followed by tuples for values listed later.

Name Type Description
Dataset string Unique dataset id
Header object Dimension details and members of header
Contains array of
  • Dimension: Dimension id
  • Members: Distinct sorted values of dimension members
Stub Object Dimension details and members of stub
Contains array of
  • Dimension: Dimension id
  • Members: Distinct sorted values of dimension members
Filter Object Dimension details of members which are used as a filter. This can
contain only one member.
Data object Tuples describing each data point.
consists
  • Time: Date of observation
  • Value : contains the significand/mantissa of observation value.
    Should be multiplied with scale for observation data.
  • Unit: Unit associated with value
  • Scale: Value's multiplication factor.
  • Frequency: Interval of time between which observation data is recorded. Values can be 'A' -Annual ,'Q' -Quarterly, 'M' -Monthly ,'W' -Weekly

Example

Post: http://knoema.com/api/1.0/data/pivot
 
{
   "Header": [
      {
         "DimensionId": "Time",
         "Members": [
            {
               "Key": "-318",
               "Name": "AvgA(1970,2012)",
               "Formula": [
                  "1970",
                  "2012",
                  "avga"
               ]
            },
            "2000",
            "2001",
            "2003"
         ],
         "DimensionName": "Time",
         "UiMode": "individualMembers"
      }
   ],
   "Stub": [
      {
         "DimensionId": "variable",
         "Members": [
            "1001770",
            {
               "Key": "-917",
               "Name": "% Change(Total Primary Energy Production (Quadrillion Btu))",
               "Formula": [
                  "1001790"
               ],
               "Transform": "pch"
            },
            {
               "Key": "-650",
               "Name": "Total Coal Consumption (Quadrillion Btu)/Total Coal Consumption (Thousand Short Tons)",
               "Formula": [
                  "1000100",
                  "1000110",
                  "/"
               ]
            }
         ],
         "DimensionName": "Variable"
      }
   ],
   "Filter": [
      {
         "DimensionId": "location",
         "Members": [
            "1002040"
         ],
         "DimensionName": "Location"
      }
   ],
   "Frequencies": [
      "A",
      "Q",
      "M"
   ],
   "FoldDimension": null,
   "Dataset": "EIAIES2012"
}
 
 
Result
 
 
{
   "header": [
      {
         "dimensionId": "Time",
         "members": [
            "AvgA(1970,2012)",
            "2000",
            "2001",
            "2003"
         ]
      }
   ],
   "stub": [
      {
         "dimensionId": "variable",
         "members": [
            "Total Primary Energy Consumption (Quadrillion Btu)",
            "% Change(Total Primary Energy Production (Quadrillion Btu))",
            "Total Coal Consumption (Quadrillion Btu)/Total Coal Consumption (Thousand Short Tons)"
         ]
      }
   ],
   "filter": [
      {
         "dimensionId": "location",
         "members": [
            "India"
         ]
      }
   ],
   "datasetName": "International Energy Statistics, 2012",
   "dataset": "EIAIES2012",
   "keys": {
      "header": [
         {
            "dimensionId": "Time",
            "members": [
               -318,
               "2000",
               "2001",
               "2003"
            ]
         }
      ],
      "stub": [
         {
            "dimensionId": "variable",
            "members": [
               "1001770",
               -917,
               -650
            ]
         }
      ],
      "filter": [
         {
            "dimensionId": "location",
            "members": [
               "1002040"
            ]
         }
      ]
   },
   "data": [
      {
         "Time": "AvgA(1970,2012)",
         "variable": "Total Primary Energy Consumption (Quadrillion Btu)",
         "location": "India",
         "Value": 10.8559006666667,
         "Unit": "",
         "Scale": 1,
         "Frequency": ""
      },
      {
         "Time": "2000-01-01T00:00:00Z",
         "variable": "Total Primary Energy Consumption (Quadrillion Btu)",
         "location": "India",
         "Value": 13.4619,
         "Unit": "Quadrillion Btu",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "2001-01-01T00:00:00Z",
         "variable": "Total Primary Energy Consumption (Quadrillion Btu)",
         "location": "India",
         "Value": 13.93706,
         "Unit": "Quadrillion Btu",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "2003-01-01T00:00:00Z",
         "variable": "Total Primary Energy Consumption (Quadrillion Btu)",
         "location": "India",
         "Value": 14.22798,
         "Unit": "Quadrillion Btu",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "AvgA(1970,2012)",
         "variable": "% Change(Total Primary Energy Production (Quadrillion Btu))",
         "location": "India",
         "Value": 5.62018280481226,
         "Unit": "",
         "Scale": 1,
         "Frequency": ""
      },
      {
         "Time": "2000-01-01T00:00:00Z",
         "variable": "% Change(Total Primary Energy Production (Quadrillion Btu))",
         "location": "India",
         "Value": 2.57806443804769,
         "Unit": "%",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "2001-01-01T00:00:00Z",
         "variable": "% Change(Total Primary Energy Production (Quadrillion Btu))",
         "location": "India",
         "Value": 4.67380879003967,
         "Unit": "%",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "2003-01-01T00:00:00Z",
         "variable": "% Change(Total Primary Energy Production (Quadrillion Btu))",
         "location": "India",
         "Value": 5.63927200041023,
         "Unit": "%",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "AvgA(1970,2012)",
         "variable": "Total Coal Consumption (Quadrillion Btu)/Total Coal Consumption (Thousand Short Tons)",
         "location": "India",
         "Value": 0.0000173576619465797,
         "Unit": "",
         "Scale": 1,
         "Frequency": ""
      },
      {
         "Time": "2000-01-01T00:00:00Z",
         "variable": "Total Coal Consumption (Quadrillion Btu)/Total Coal Consumption (Thousand Short Tons)",
         "location": "India",
         "Value": 0.0000180675924761611,
         "Unit": "",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "2001-01-01T00:00:00Z",
         "variable": "Total Coal Consumption (Quadrillion Btu)/Total Coal Consumption (Thousand Short Tons)",
         "location": "India",
         "Value": 0.0000180621128143399,
         "Unit": "",
         "Scale": 1,
         "Frequency": "A"
      },
      {
         "Time": "2003-01-01T00:00:00Z",
         "variable": "Total Coal Consumption (Quadrillion Btu)/Total Coal Consumption (Thousand Short Tons)",
         "location": "India",
         "Value": 0.0000168281974365255,
         "Unit": "",
         "Scale": 1,
         "Frequency": "A"
      }
   ]
}