The Socrata module provides a Drupal integration point for the Socrata open government data service.

Results from relevant Socrata APIs (see below) can be used as a Views data source. The data can then be output in any format that Views can render including tables, charts, maps, CSV files, JSON, etc.

The module also includes an input filter that allows you to embed a Socrata data widget within a text field.

Relevant Socrata APIs

  • The SODA2 API queries rows of data within a specific Socrata dataset (e.g. give me all rows in the Seattle Building Permits dataset)
  • The Search Catalog API (beta status as of June, 2016) queries the catalog of all existing Socrata assets (e.g. give me all datasets at the data.seattle.gov domain)

Requirements

Installation

  1. Download the module from https://www.drupal.org/project/socrata or use drush pm-download socrata.
  2. Enable the base socrata module and:
    • The socrata_views module for Views integration
    • The socrata_catalog_search module for Views integration with the Catalog Search API
    • The socrata_filter module for the input filter

Configuration

For most uses of the module, start by creating Socrata endpoints in Drupal. (This is not necessary if you only plan to use the socrata_catalog_search module to query the Catalog Search API.)

Get at least one SODA2 API endpoint URL from the Socrata service and use it to create a Socrata endpoint in Drupal at admin/structure/socrata . Once created, endpoints can then be exported or saved to Features.

To find your SODA2 API endpoint, if you know where to find the default Socrata visualization of the relevant dataset on the web, you can easily get it from there. For example, the default visualization for the "Seattle schools" dataset is here:
https://data.seattle.gov/Education/Seattle-schools/uanm-dxsk

From there, you can click the Export button in the toolbar, then the SODA API link in the upper right. Then copy and paste the URL for the API Endpoint.

Input Filter

For the input filter, configure the relevant text format from admin/config/content/formats and check the box to enable the "Embed Socrata dataset views" filter.

Then, on a textarea using that text format, add code like this to enable a Socrata data widget:

[socrata source=source_name width=600 height=400]

Replace "my_dataset" with the (machine) Name from the Socrata endpoint you created above.

Save the content with your textarea and view it to see the Socrata widget.

Socrata Views Configuration

  1. Go to admin/structure/views/add to add a new view.
    • Choose one of the endpoints you created above, with a "Socrata: " prefix from the 'Show' drop-down.
  2. Choose whatever display and format you need.
  3. Sorting, filtering, and aggregation are all available to use on the data including as exposed filters and using AJAX.
    • To provide a CSV or JSON export, add a "Socrata Data Export" display. You can display it on its own or attach the export display to another display.

Socrata Catalog Search Views Configuration

  1. Go to admin/structure/views/add to add a new view.
    • Choose "Socrata Catalog Search" from the 'Show' drop-down.
  2. Choose whatever display and format you need.
  3. Sorting and filtering are available to use on the data.
    • In order to display results from just one domain, filter by that domain’s URL without the http:// or https://, e.g. "data.austin.gov".
    • Note that because of a current limitation in the Catalog Search API, results can only be sorted within the paged output instead of the entire result set.

Recommended Modules

  • Features allows the saving of endpoints to features modules.
  • Charting and mapping can be done with several modules using Socrata Views. (The d3.js module offers a particularly flexible set of visualizations if appropriate for your project.)

See the how-to documentation pages for specific examples.