Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including soda-js with all npm packages installed. Try it out:

var sodaJs = require("soda-js")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

soda-js v0.2.3

js library for accessing a soda2 api

h1. soda-js "!!":

A client implementation of the Socrata Open Data API in Coffeescript and Javascript.

h2. Important Note

In order to access the SODA API via HTTPS, clients must now "support the Server Name Indication (SNI)": extension to the TLS protocol. What does this mean? It means that if you're using @soda-js@, you must use a JavaScript VM that supports SNI:

  • "Internet Explorer 7+":
  • "Mozilla Firefox 2+":
  • "Apple Safari (all versions)":
  • "Google Chrome 6.0+":
  • "node.js 0.5.3+":

h2. Supported Operations

Supports both consumer and producer API, but does not currently support creating datasets or the import workflow.

h2. Usage

See the @sample/@ directory for sample code, but here's the general idea:

bc.. var soda = require('soda-js');

h3. Consumer API

You can query a dataset by SODA2 clauses, or supply a custom SoQL query to be run.

bc.. var consumer = new soda.Consumer('');

consumer.query() .withDataset('644b-gaut') .limit(5) .where({ namelast: 'SMITH' }) .order('namelast') .getRows() .on('success', function(rows) { console.log(rows); }) .on('error', function(error) { console.error(error); });

h3. Producer API

You can add, update, replace, delete, and upsert rows, as well as truncate a dataset.

bc.. var producer = new soda.Producer('', sodaConnectionOptions);

var data = { mynum : 42, mytext: "hello world" }

producer.operation() .withDataset('rphc-ayt9') .add(data) .on('success', function(row) { console.log(row); }) .on('error', function(error) { console.error(error); })

h2. License

Provided under the MIT license.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free