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 lobbyist_summary table in this repository, by referencing it like:


or in a full query, like:

    ":id", -- Socrata column ID
    "lobbyist_name", -- The lobbyist's name as registered. The name will be consistent across all records for the same filer id and election year but may differ across years due to a lobbyist changing their name.
    "year", -- The year of registration for the lobbyist. A lobbyist can be registered in multiple years.
    "firm_city", -- The city of the registered lobbyist.
    "firm_country", -- The country where the lobbyist firm resides.
    "temp_state", -- The temporary state of the lobbyist during legislative session.
    "firm_state", -- The state of the registered lobbyist.
    "filer_id", -- The unique id assigned to a lobbyist. The filer id is consistent across year.  
    "temp_country", -- The temporary country of the lobbyist during legislative session.
    "net_total", -- This column is the total of all expenses and compensation, minus sub lobbyist compensation.
    "political_ads", -- The total amount of all political advertising expenses incurred by the lobbyist, from all employers for a given year.  Political advertising expenses are expenditures for political advertising supporting or opposing a state or local candidate or ballot measure; or public relations, telemarketing, polling or similar activities that directly or indirectly are lobbying-related.
    "advertising", -- The total amount of all advertising expenses incurred by the lobbyist, from all employers for a given year.  Advertising expenses include advertising costs, printing costs, and the cost of informational literature.
    "personal_expenses", -- The total amount of all personal expenses for travel, food and refreshments incurred by the lobbyist, from all employers for a given year.
    "sub_lobbyist_compensation", -- Payments to other lobbyists hired by the lobbyist or paid by the lobbyist from a portion of the funds received from the employer.
    "compensation", -- The total amount of compensation received, by the lobbyist, from all employers for a given year.
    "temp_city", -- The temporary city of the lobbyist during legislative session.
    "temp_address", -- The temporary address of the lobbyist during legislative session.
    "lobbyist_email", -- The e-mail address of the lobbyist per their registration.
    "entertainment", -- The total amount of all entertainment expenses incurred by the lobbyist, from all employers for a given year. Expenditures that were incurred by lobbyist or lobbyist employer(s) for legislators, state officials, state employees and members of their immediate families. • Entertainment expenditures exceeding $50 per occasion (including lobbyist’s expense) for meals, beverages, tickets, passes, or for other forms of entertainment. • Travel, lodging and subsistence expenses in connection with a speech, presentation, appearance, trade mission, seminar or educational program. • Enrollment and course fees in connection with a seminar or educational program.
    "contributions", -- The total amount of all contributions transmitted by the lobbyist, from all employers for a given year. Contributions include monetary or in-kind contributions, exceeding $25, given or transmitted by the lobbyist to local and state candidates or elected officials; local and state officers or employees; political committees supporting or opposing any candidate, elected official, officer or employee or any local or state ballot proposition a caucus political committee; a political party; or a grass roots lobbying campaign.
    "firm_zip", -- The zip code of the registered lobbyist.
    "lobbyist_phone", -- The permanent telephone number of the lobbyist.
    "temp_zip", -- The temporary zip code of the lobbyist during legislative session.
    "total_expenses", -- This column is a total of all "expenses" incurred by the lobbyist for all employers for a given year. NOTE: this total does not include compensation.  It is the sum of "personal expenses" + "entertainment" + "contributions" + "advertising" + "political advertising" + "other expenses".
    "other", -- The total amount of other expenses incurred by the lobbyist, from all employers for a given year. Other expenses are: Payments by the lobbyist for other lobbying expenses and services, including payments to subcontract lobbyists, expert witnesses and others retained to provide lobbying services or assistance in lobbying and payments for grass roots lobbying campaigns.  Advertising and printing costs are not included in other expenses.
    "id", -- PDC internal identifier that corresponds to a lobbyist's unique filer id combined with the year of registration.  For example an id of 17239-2017 represents a record  for a lobbyist whose filer id is 17239 for calendar year 2017. 
    "net_compensation", -- The compensation the lobbyist received after paying any subcontracted lobbyists.
    "firm_address", -- The street address of the lobbyist, usually a mailing address.
    "temp_phone", -- The temporary telephone number of the lobbyist during legislative session. This is usually a cell phone or the number of the "Third House".
    "pac_contributions" -- The total amount of all monetary or in-kind contribution exceeding $25 that were given by the employers PAC and transmitted by the lobbyist
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 wa-gov/lobbyist-summary-c4ag-3cmj with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.wa.gov. When you querywa-gov/lobbyist-summary-c4ag-3cmj: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.wa.gov, 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 \
  "wa-gov/lobbyist-summary-c4ag-3cmj" \
  --handler-options '{
    "domain": "data.wa.gov",
    "tables": {
        "lobbyist_summary": "c4ag-3cmj"

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, wa-gov/lobbyist-summary-c4ag-3cmj is just another Postgres schema.