cityofchicago/building-permits-ydr8-5enu
Icon for Socrata external plugin

Query the Data Delivery Network

Query the DDN

The easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432 and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.

For example, you can query the building_permits table in this repository, by referencing it like:

"cityofchicago/building-permits-ydr8-5enu:latest"."building_permits"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "contact_5_name", -- Contact 5's full name
    "pin10", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "pin2", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "contact_12_city", -- Contact 12's primary address city
    "contact_8_zipcode", -- Contact 8's primary address ZIP code
    "contact_7_type", -- Contact 7's relationship to permit
    "contact_6_name", -- Contact 6's full name
    "contact_6_type", -- Contact 6's relationship to permit
    "contact_5_type", -- Contact 5's relationship to permit
    "contact_4_zipcode", -- Contact 4's primary address ZIP code
    "contact_12_type", -- Contact 12's relationship to permit
    "contact_12_state", -- Contact 12's primary address state
    "contact_13_city", -- Contact 13's primary address city
    "contact_5_city", -- Contact 5's primary address city
    "building_fee_waived", -- Amount of building permit fees waived
    "xcoordinate", -- The east-west coordinate of the property's primary address, defined in feet, based on NAD 83 - State Plane Eastern IL
    "processing_time", -- Number of days between APPLICATION_START_DATE and ISSUE_DATE.
    "subtotal_unpaid", -- Sum of BUILDING_FEE_UNPAID, ZONING_FEE_UNPAID and OTHER_FEE_UNPAID
    "subtotal_waived", -- Sum of BUILDING_FEE_WAIVED, ZONING_FEE_WAIVED and OTHER_FEE_WAIVED
    "contact_4_state", -- Contact 4's primary address state
    "census_tract", -- The census tract of the property's primary address. The census tract map is available in a separate dataset.
    "contact_13_zipcode", -- Contact 13's primary address ZIP code
    ":@computed_region_awaf_s7ux",
    "pin1", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "contact_2_state", -- Contact 2's primary address state
    "contact_11_type", -- Contact 11's relationship to permit
    "contact_14_city", -- Contact 14's primary address city
    "review_type", -- Process used to review permit application
    "contact_4_city", -- Contact 4's primary address city
    "contact_14_zipcode", -- Contact 14's primary address ZIP code
    "contact_5_state", -- Contact 5's primary address state
    "contact_6_state", -- Contact 6's primary address state
    "contact_1_city", -- Contact 1's primary address city
    "contact_1_state", -- Contact 1's primary address state
    "contact_11_city", -- Contact 11's primary address city
    "contact_8_state", -- Contact 8's primary address state
    "contact_14_name", -- Contact 14's full name
    ":@computed_region_43wa_7qmu",
    "contact_14_state", -- Contact 14's primary address state
    "contact_7_city", -- Contact 7's primary address city
    "contact_7_zipcode", -- Contact 7's primary address ZIP code
    "contact_8_name", -- Contact 8's full name
    "contact_15_type", -- Contact 15's relationship to permit
    "contact_15_name", -- Contact 15's full name
    "contact_3_state", -- Contact 3's primary address state
    "contact_10_type", -- Contact 10's relationship to permit
    "contact_2_name", -- Contact 2's full name
    "contact_2_city", -- Contact 2's primary address city
    "contact_3_city", -- Contact 3's primary address city
    "contact_2_type", -- Contact 2's relationship to permit
    "street_name", -- Street name
    "pin9", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "contact_9_zipcode", -- Contact 9's primary address ZIP code
    "contact_11_name", -- Contact 11's full name
    "reported_cost", -- Estimated cost of work provided by applicant
    "contact_15_city", -- Contact 15's primary address city
    "contact_15_state", -- Contact 15's primary address state
    "contact_15_zipcode", -- Contact 15's primary address ZIP code
    "contact_9_state", -- Contact 9's primary address state
    "id", -- Unique database record identifier
    "contact_13_type", -- Contact 13's relationship to permit
    "street_direction", -- Street direction
    "contact_14_type", -- Contact 14's relationship to permit
    "building_fee_paid", -- Amount of building permit fees received
    "other_fee_waived", -- Amount of other permit-related fees waived
    "contact_3_type", -- Contact 3's relationship to permit
    "contact_6_city", -- Contact 6's primary address city
    "contact_6_zipcode", -- Contact 6's primary address ZIP code
    "contact_1_name", -- Contact 1's full name
    "ward", -- The ward (city council district) of the property's primary address at the time of permit issuance. The ward map is available in a separate dataset.
    "contact_8_type", -- Contact 8's relationship to permit
    "contact_8_city", -- Contact 8's primary address city
    "contact_9_type", -- Contact 9's relationship to permit
    "pin7", -- Property index number(s) are assigned to parcels of land for property tax purposes
    ":@computed_region_bdys_3d7i",
    "contact_10_zipcode", -- Contact 10's primary address ZIP code
    ":@computed_region_6mkv_f3dw",
    ":@computed_region_vrxf_vc4k",
    "contact_7_name", -- Contact 7's full name
    "work_description", -- Description of work authorized by the permit
    "other_fee_paid", -- Amount of other permit-related fees received
    "subtotal_paid", -- Sum of BUILDING_FEE_PAID, ZONING_FEE_PAID and OTHER_FEE_PAID
    "building_fee_unpaid", -- Amount of building permit fees due
    "other_fee_unpaid", -- Amount of other permit-related fees due
    "zoning_fee_waived", -- Amount of zoning review fees waived
    "contact_3_name", -- Contact 3's full name
    "contact_3_zipcode", -- Contact 3's primary address ZIP code
    ":@computed_region_rpca_8um6",
    "contact_9_city", -- Contact 9's primary address city
    "latitude", -- The latitude of the property's primary address
    "application_start_date", -- Date when City began reviewing permit application
    "issue_date", -- Date when City determined permit ready to issue, subject to payment of permit fees
    "contact_4_name", -- Contact 4's full name
    "contact_11_state", -- Contact 11's primary address state
    "contact_11_zipcode", -- Contact 11's primary address ZIP code
    "contact_5_zipcode", -- Contact 5's primary address ZIP code
    "contact_12_name", -- Contact 12's full name
    "contact_12_zipcode", -- Contact 12's primary address ZIP code
    "contact_13_state", -- Contact 13's primary address state
    "total_fee", -- Sum of SUBTOTAL_PAID, SUBTOTAL_UNPAID and SUBTOTAL_WAIVED
    "pin8", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "contact_10_city", -- Contact 10's primary address city
    "contact_10_state", -- Contact 10's primary address state
    "contact_1_type", -- Contact 1's relationship to permit
    "pin3", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "contact_1_zipcode", -- Contact 1's primary address ZIP code
    "contact_13_name", -- Contact 13's full name
    "pin5", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "contact_10_name", -- Contact 10's full name
    "pin6", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "longitude", -- The longitude of the property's primary address
    "contact_7_state", -- Contact 7's primary address state
    "location", -- The location of the property's primary address in a format that allows for creation of maps and other geographic operations on this data portal
    "pin4", -- Property index number(s) are assigned to parcels of land for property tax purposes
    "ycoordinate", -- The north-south coordinate of the property's primary address, defined in feet, based on NAD 83 - State Plane Eastern IL
    "community_area", -- The Chicago community area of the property's primary address. The community area map is available in a separate dataset.
    "street_number", -- Address number - for buildings with address ranges, primary address is used
    "contact_9_name", -- Contact 9's full name
    "zoning_fee_unpaid", -- Amount of zoning review fees due
    "zoning_fee_paid", -- Amount of zoning review fees received
    "permit_type", -- Type of permit
    "suffix", -- Street name suffix
    "permit_", -- Tracking number assigned at beginning of permit application process
    "contact_2_zipcode", -- Contact 2's primary address ZIP code
    "contact_4_type" -- Contact 4's relationship to permit
FROM
    "cityofchicago/building-permits-ydr8-5enu:latest"."building_permits"
LIMIT 100;

Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query cityofchicago/building-permits-ydr8-5enu with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.cityofchicago.org. When you querycityofchicago/building-permits-ydr8-5enu:latest on the DDN, we "mount" the repository using the socrata mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).

We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT is only guaranteed for subsequent queries that land on the same node.

Query Your Local Engine

Install Splitgraph Locally
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
 

Read the installation docs.

Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.

It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgrcan manage the image, container and volume for you.

There are a few ways to ingest data into the local engine.

For external repositories (like this repository), the Splitgraph Engine can "mount" upstream data sources by using sgr mount. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.

For hosted datasets, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.cityofchicago.org, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone to get the data. Instead, you can use the socrata adapter with the sgr mount command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.

First, install Splitgraph if you haven't already.

Mount the table with sgr mount

sgr mount socrata \
  "cityofchicago/building-permits-ydr8-5enu" \
  --handler-options '{
    "domain": "data.cityofchicago.org",
    "tables": {
        "building_permits": "ydr8-5enu"
    }
}'

That's it! Now you can query the data in the mounted table like any other Postgres table.

Query the data with your existing tools

Once you've loaded the data into your local Splitgraph engine, you can query it with any of your existing tools. As far as they're concerned, cityofchicago/building-permits-ydr8-5enu is just another Postgres schema.