HowTo>API Structure Tutorial

API Structure

API structures to pull your data


Base URL

https://api.psdata.un.org/public


Data API (/data)

The API supports a URL based call structure in the following format:

Structure format

https://api.psdata.un.org/public/data/{datasetid}/{outputformat}?{optionalparameters}

Dataset ID (required)

Dataset ID can be found under each dataset on the dataset home page

Output format (required)

  1. JSON
  2. XML
  3. CSV

Examples

https://api.psdata.un.org/public/data/DPO-QIP/json

https://api.psdata.un.org/public/data/DPO-UCLATEST/xml

Parameters (Optional)

Following optional parameters can be added to the URL. Multiple optional parameters can be added separated by an ampersand(&). The optional parameters can be added in any order.

1. Pagination

For paging through a large dataset, you can add the following two parameters :

  1. per_page=: for determining the number of results per page. The default setting is all the data points
  2. page_num=: the page number requested from the data

Example

https://api.psdata.un.org/public/data/DPPADPOSS-FATALITIES/xml?page_num=2&per_page=30

2. Filtering

The dataset can be filtered based on the column name(s) and value(s). To perform filtering, follow the following structure:

filter={column1Name}:{val1},{val2},{val3}...;{column2Name}:{val1}....;.....

Example

https://api.psdata.un.org/public/data/DPPADPOSS-PKO/xml?filter=Mission_Acronym:MINUSMA,MONUSCO


Metadata (/metadata)

The Metadata API supports a URL based call structure in the following format:

Structure format

https://api.psdata.un.org/public/metadata/{datasetid}?{optionalparameters}

Dataset ID (required)

Dataset IDs can be found under each dataset page. Pass 'all' to fetch metadata for all datasets

Example

https://api.psdata.un.org/public/metadata/DPO-QIP

Parameters (Optional)

Following optional parameters can be added to the URL. Multiple optional parameters can be added separated by an ampersand(&). The optional parameters can be added in any order.

1. Columns

To get particular column from the dataset, you can add an optional parameter

Structure format

column={comma separated column name}

Example

https://api.psdata.un.org/public/metadata/all/columns=Dataset ID,Tags

2. Type

By default the API will give internal publically released datasets. Use the following query for the list of external datasets.

Structure format

type=external

Example

https://api.psdata.un.org/public/metadata/all?type=external

3. Themes Search

To return datasets with particular themes, add:

Structure format

themes={comma separated values}

Example

https://api.psdata.un.org/public/metadata/all?columns=Themes&themes=Peackeeping,Peacebuilding