Skip to content

WPRDC/WPRDC-data-API-overview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 

Repository files navigation

WPRDC-data-API-overview

An overview of the Western Pennsylvania Regional Data Center's data API services

The Western Pennsylvania Regional Data Center's data portal (where you can get lots of open data) runs on CKAN. CKAN has an API that allows the user to do things like get a list of all datasets on the WPRDC data portal, get a list of all datasets with resources and dataset metadata, download the data from any data table on the portal, or even run SQL queries.

Click this link to get a JSON-formatted response with all dogs licensed in Allegheny County whose names start with "MR.".

We've done a workshop on using web APIs in general and the WPRDC's APIs in particular. The linked GitHub repository includes examples and documention on using our data API.

We've also written query-slinger - a bare-bones interactive query editor/launcher for running SQL queries against a CKAN data portal, written in Python and run in the Python REPL for easy query debugging. This includes documentation and scripts with comments to get you statred.

Documentation

The CKAN API documentation is here. Documenation for the datastore_search and datastore_search_sql endpoints (for querying data tables) are here and here.

FAQ

The number one most asked question: Why is my CKAN SQL query not working?

Usually the answer is because the query is not formatted to match the requirements of Postgres (which is the database behind our data portal). Specifically, it's best to surround all 1) field names and table names with double quotes and 2) string values with single quotes, as in this example:

https://data.wprdc.org/api/3/action/datastore_search_sql?sql=SELECT "PARID" FROM "f2b8d575-e256-4718-94ad-1e12239ddb92" WHERE "MUNICODE"='821' LIMIT 5

Click it to see it in action!

Wrappers

If you use Python or R, there are API wrappers that allow you to simplify the syntax needed to make API calls:

Some data API examples

Making SQL queries on WPRDC Data

CKAN API usage under R + debugging a broken SQL query

Tiny CKAN API examples

Finally

A long list of analyses done using WPRDC data and tools that can help you in using our data

About

An overview of the Western Pennsylvania Regional Data Center's data API services

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published