Code Monkey home page Code Monkey logo

soda-js's Introduction

soda-js

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

Important Note

In order to access the SODA API via HTTPS, clients must now support the Server Name Indication 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:

Supported Operations

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

Usage

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

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

Consumer API

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

var consumer = new soda.Consumer('explore.data.gov');

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); });

Using ‘like’ in a where clause:

.where("namelast like '%MITH'")

Producer API

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

Note: This library uses the Socrata Open Data API (SODA), which differs in functionality from the Socrata Data Management API. When automating updates to Socrata datasets that utilize one or more on-platform Data Transforms, use the Data Management API to consistently apply those specified transforms. For more on the difference between SODA and the Data Management API, see the latter API’s documentation.

var producer = new soda.Producer('sandbox.demo.socrata.com', 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); })

License

Provided under the MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.