Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rest stat vars union documentation #159

Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions api/rest/union.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
layout: default
title: Union of Place Statistical Variables
nav_order: 13
parent: REST
grand_parent: API
---

# Retrieve all statistical variables available for a particular place

Given a list of [`Place`](https://datacommons.org/browser/Place) DCIDs,
(e.g. any [`State`](https://datacommons.org/browser/State), [`Country`](https://datacommons.org/browser/Country), etc.), return a union of statistical variables available for the specified DCIDs.

## General information about this endpoint

**URL**: `/place/stat-vars/union`

**Methods available**: `POST`

**Required arguments**:

* [`dcids`](/glossary.html): A list of `Place` nodes, identified by their DCIDs.

## Example requests and responses

### Example 1: Retrieve a list of the union of statistical variables available for the countries of Bolivia and Bhutan.

<div>

{% tabs log %}

{% tab log GET Request %}

This endpoint does not support GET requests.

{% endtab %}

{% tab log POST Request %}

```bash
curl --request POST \
--url https://api.datacommons.org/place/stat-vars/union \
--header 'content-type: application/json' \
--data '{ "dcids": ["country/BTN", "country/BOL"]}'
```

{% endtab %}

{% tab log javascript %}

<iframe width="100%" height="300" src="//jsfiddle.net/datacommonsorg/tzowhea3/14/embedded/" allowfullscreen="allowfullscreen" allowpaymentrequest frameborder="0"></iframe>

{% endtab %}

{% endtabs %}

</div>

#### Response

```json
{
"statVars": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shifucun it would be nice not to have to double-unroll "statVars" to get to the list. since this doc isn't published yet, perhaps we could update this before publishing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent out a fix for this datacommonsorg/mixer#531

"statVars": [
"Amount_Consumption_Alcohol_15OrMoreYears_AsFractionOf_Count_Person_15OrMoreYears",
"Amount_Consumption_Electricity_PerCapita",
"Amount_Consumption_Energy_PerCapita",
"Amount_Consumption_RenewableEnergy_AsFractionOf_Amount_Consumption_Energy",
...
]
}
}
```

## Error Responses

If your request is malformed in some way, you will receive a 400 status code and an error message like the following:

```json
{
"code": 3,
"message": "Missing required arguments: dcid",
"details": [
{
"@type": "type.googleapis.com/google.rpc.DebugInfo",
"stackEntries": [],
"detail": "internal"
}
]
}
```