observatory-extension/doc/API.md

111 lines
4.2 KiB
Markdown
Raw Normal View History

2016-04-12 03:49:53 +08:00
# Data Observatory Access
This file is for reference purposes only. It is intended for tracking the Data Observatory API functions that should be displayed from the Docs site. Like all API doc, the golden source of the code will live in this repo. I will pull the list of files below into the docs for the output.
2016-04-12 03:56:01 +08:00
## Documentation
2016-04-12 03:49:53 +08:00
## OBS_GetDemographicSnapshot
2016-04-12 04:19:32 +08:00
The Demographic Snapshot API call enables you to collect demographic details around a point location. For example, you can take the coordinates of a bus stop and find the average population characteristics in that location. If you need help creating coordinates from addresses, [see our geocoding documentation].
2016-04-12 04:02:57 +08:00
Fields returned include information about income, education, transportation, race, and more. Not all fields will have information for every coordinate queried.
### API Syntax
```html
https://{{account name}}.cartodb.com/api/v2/sql?q=SELECT * FROM
OBS_GetDemographicSnapshot({{point geometry}})
2016-04-12 03:49:53 +08:00
```
2016-04-12 04:02:57 +08:00
#### Parameters
2016-04-12 03:49:53 +08:00
2016-04-12 04:02:57 +08:00
| Parameter | Description | Example |
|---|:-:|:-:|
| account name | The name of your CartoDB account where the Data Observatory has been enabled | example_account |
2016-04-12 04:07:01 +08:00
| point geometry | A WKB point geometry. You can use the helper function, CDB_LatLng to quickly generate one from latitude and longitude | CDB_LatLng(40.760410,-73.964242) |
2016-04-12 03:49:53 +08:00
2016-04-12 05:16:34 +08:00
#### Geographic Scope
The Demographic Snapshot API is available for the following countries:
* United States
2016-04-12 04:15:32 +08:00
### API Examples
__Get the Demographic Snapshot at Camp David__
2016-04-12 03:49:53 +08:00
2016-04-12 03:54:42 +08:00
```text
2016-04-12 04:02:57 +08:00
https://example_account.cartodb.com/api/v2/sql?q=SELECT * FROM
2016-04-12 04:15:32 +08:00
OBS_GetDemographicSnapshot(CDB_LatLng(39.648333, -77.465))
2016-04-12 04:02:57 +08:00
```
2016-04-13 05:18:17 +08:00
__Get the Demographic Snapshot in the Upper West Side__
2016-04-12 04:15:46 +08:00
```text
https://example_account.cartodb.com/api/v2/sql?q=SELECT * FROM
2016-04-13 05:18:17 +08:00
OBS_GetDemographicSnapshot(CDB_LatLng(40.80, -73.960))
2016-04-12 04:15:46 +08:00
```
2016-04-12 04:02:57 +08:00
### API Response
2016-04-12 03:49:53 +08:00
[Click to expand](https://gist.github.com/ohasselblad/c9e59a6e8da35728d0d81dfed131ed17)
2016-04-12 04:08:00 +08:00
2016-04-12 04:08:42 +08:00
### Available fields
2016-04-12 05:13:00 +08:00
The Demographic Snapshot contains a broad subset of demographic measures in the Data Observatory. Over 80 measurements are returned by a single API request.
2016-04-12 06:32:14 +08:00
__todo: turn this spreadsheet into a markdown table__
2016-04-12 04:08:42 +08:00
2016-04-12 06:32:14 +08:00
https://docs.google.com/spreadsheets/d/1U3Uajw_PsIy3_YgeujnJ7AiL2VREdT-ozdaulx07q2g/edit#gid=430723120
2016-04-12 04:08:42 +08:00
2016-04-12 05:13:00 +08:00
## OBS_GetSegmentationSnapshot
2016-04-12 04:08:00 +08:00
2016-04-12 05:13:00 +08:00
The Segmentation Snapshot API call enables you to determine the pre-calculated population segment for a location. For example, you can take the location of a store location and determine what classification of population exists around that location. If you need help creating coordinates from addresses, [see our geocoding documentation].
2016-04-12 04:17:38 +08:00
### API Syntax
```html
https://{{account name}}.cartodb.com/api/v2/sql?q=SELECT * FROM
OBS_GetSegmentationSnapshot({{point geometry}})
```
#### Parameters
| Parameter | Description | Example |
|---|:-:|:-:|
| account name | The name of your CartoDB account where the Data Observatory has been enabled | example_account |
| point geometry | A WKB point geometry. You can use the helper function, CDB_LatLng to quickly generate one from latitude and longitude | CDB_LatLng(40.760410,-73.964242) |
2016-04-12 05:16:34 +08:00
#### Geographic Scope
The Segmentation Snapshot API is available for the following countries:
* United States
2016-04-12 04:17:38 +08:00
### API Examples
2016-04-12 04:23:12 +08:00
__Get the Segmentation Snapshot around the MGM Grand__
2016-04-12 04:17:38 +08:00
```text
https://example_account.cartodb.com/api/v2/sql?q=SELECT * FROM
2016-04-12 04:23:12 +08:00
OBS_GetSegmentationSnapshot(CDB_LatLng(36.10222, -115.169516))
2016-04-12 04:17:38 +08:00
```
2016-04-12 04:23:12 +08:00
__Get the Segmentation Snapshot at CartoDB's NYC HQ__
2016-04-12 04:08:00 +08:00
```text
2016-04-12 04:17:38 +08:00
https://example_account.cartodb.com/api/v2/sql?q=SELECT * FROM
2016-04-12 04:23:12 +08:00
OBS_GetSegmentationSnapshot(CDB_LatLng(40.704512, -73.936669))
2016-04-12 04:08:00 +08:00
```
2016-04-12 04:17:38 +08:00
### API Response
__todo__
2016-04-12 05:16:34 +08:00
### Available segments
2016-04-12 04:17:38 +08:00
__todo__
2016-04-12 04:26:37 +08:00
### Methodology
2016-04-12 04:47:29 +08:00
Segmentation is a method that divides a target market into subgroups based on shared common traits. While we plan to make many different segmentation methods available, our first release includes a segmentation profile first defined in a paper, _Understanding America's Neighborhoods Using Uncertain Data from the American Community Survey: Output Data: US_tract_clusters_new_. [See here](http://www.tandfonline.com/doi/pdf/10.1080/00045608.2015.1052335) for further information on the work in that paper.