A simple node library for accessing the National Agriculture Service QuickStats database.
  • JavaScript 100%
Find a file
2017-02-01 08:06:08 -06:00
.gitignore Initial commit 2016-03-08 21:15:30 -06:00
LICENSE Initial commit 2016-03-08 21:15:30 -06:00
nas.js Add files via upload 2017-01-24 12:32:38 -05:00
package.json Added initial files. 2016-03-08 21:25:04 -06:00
README.md Fixed syntax highlighting. 2016-03-09 22:05:26 -06:00
test.js Cleaned up. Moved test function into test.js 2016-03-09 21:38:35 -06:00

nas-quickstats

A simple node library for accessing the National Agriculture Service QuickStats database.

For a quick example...

$node test

API

  1. Add the library into your file

    var nas = require('nas-quickstats');
    
  2. Declare your key that you obtained from the nas site.

    nas.key = 'asldfaj-sadfas-adsf-asdfsdf';
    
  3. Create a query using the variables from the nas site.

    var q = nas.query({
      commodity_desc: 'BEETS',
      statisticcat_desc: 'YIELD'
    });
    

    'query' takes an options object which can contain any number of key value pairs describing the query.

  4. Create a request declaring a type and passing in your query and a callback.

    Available types are: get, params, and counts.

    var r = nas.request(nas.type.get, q, function(data){
      console.log(data);
    });
    
  5. Send the request, and be on your merry way.

    r.send();
    

More details about the NAS api itself can be found @ http://quickstats.nass.usda.gov/api. Be sure to obtain an API key (it's instant) and read the terms and conditions of use.