Download or Upload 'Socrata' Data Sets

Provides easier interaction with 'Socrata' open data portals <>. Users can provide a 'Socrata' data set resource URL, or a 'Socrata' Open Data API (SoDA) web query, or a 'Socrata' "human-friendly" URL, returns an R data frame. Converts dates to 'POSIX' format and manages throttling by 'Socrata'. Users can upload data to 'Socrata' portals directly from R.

Gitter Stories in Ready downloads cran version


Stable beta branch. Test about-to-be-released features in a stable pre-release build before it is submitted to CRAN.

Linux build - MasterWindows build - MasterCoverage - Master


"Nightly" alpha branch. Test the latest features and bug fixes -- enjoy at your own risk.

Linux build - DevWindows build - DevCoverage - Dev

A tool for downloading and uploading Socrata datasets

Provided with a URL to a dataset resource published on a Socrata webserver, or a Socrata SoDA (Socrata Open Data Application Program Interface) web API query, or a Socrata "human-friendly" URL, read.socrata() returns an R data frame. Converts dates to POSIX format. Supports CSV and JSON download file formats from Socrata. Manages the throttling of data returned from Socrata and allows users to provide an application token. Supports SoDA query parameters in the URL string for further filtering, sorting, and queries. Upload data to Socrata data portals using "upsert" and "replace" methods.

Use ls.socrata() to list all datasets available on a Socrata webserver.

testthat test coverage.

To get the current released version from CRAN:


The most recent beta with soon-to-be-released changes can be installed from GitHub:

# install.packages("devtools")

The "nightly" version with the most recent bug fixes and features is also available. This version is always an alpha and may contain significant bugs. You can install it from the dev branch from GitHub:

# install.packages("devtools")
devtools::install_github("Chicago/RSocrata", ref="dev")


Reading SoDA valid URLs

earthquakesDataFrame <- read.socrata("")
nrow(earthquakesDataFrame) # 1007 (two "pages")
class(earthquakesDataFrame$Datetime[1]) # POSIXlt

Reading "human-readable" URLs

earthquakesDataFrame <- read.socrata("")
nrow(earthquakesDataFrame) # 1007 (two "pages")
class(earthquakesDataFrame$Datetime[1]) # POSIXlt

Using API key to read datasets

token <- "ew2rEMuESuzWPqMkyPfOSGJgE"
earthquakesDataFrame <- read.socrata("", app_token = token)

Download private datasets from portal

# Store user email and password
socrataEmail <- Sys.getenv("SOCRATA_EMAIL", "[email protected]")
socrataPassword <- Sys.getenv("SOCRATA_PASSWORD", "7vFDsGFDUG")
privateResourceToReadCsvUrl <- "" # dataset
read.socrata(url = privateResourceToReadCsvUrl, email = socrataEmail, password = socrataPassword)

List all datasets on portal

allSitesDataFrame <- ls.socrata("")
nrow(allSitesDataFrame) # Number of datasets
allSitesDataFrame$title # Names of each dataset

Upload data to portal

# Store user email and password
socrataEmail <- Sys.getenv("SOCRATA_EMAIL", "[email protected]")
socrataPassword <- Sys.getenv("SOCRATA_PASSWORD", "7vFDsGFDUG")
datasetToAddToUrl <- "" # dataset
# Generate some data
x <- sample(-1000:1000, 1)
y <- sample(-1000:1000, 1)
df_in <- data.frame(x,y)
# Upload to Socrata


Please report issues, request enhancements or fork us at the City of Chicago github.


If you would like to contribute to this project, please see the contributing documentation and the product roadmap.


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.7.11-2 by Tom Schenk Jr., 4 months ago

Report a bug at

Browse source code at

Authors: Hugh Devlin , Ph. D. , Tom Schenk , Jr. , Gene Leynes , Nick Lucius , John Malc , Mark Silverberg , and Peter Schmeideskamp

Documentation:   PDF Manual  

Task views:

MIT + file LICENSE license

Imports httr, jsonlite, mime, plyr

Suggests testthat, roxygen2, readr

Imported by ARPALData.

See at CRAN