https://github.com/ashander/scram
scram: sacramento county retriever and munger
https://github.com/ashander/scram
Last synced: about 1 year ago
JSON representation
scram: sacramento county retriever and munger
- Host: GitHub
- URL: https://github.com/ashander/scram
- Owner: ashander
- License: bsd-2-clause
- Created: 2016-03-12T20:47:01.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-21T17:31:16.000Z (about 10 years ago)
- Last Synced: 2025-03-02T11:44:43.472Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/scram
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
scram: sacramento county retriever and munger
wrapping the Sacramento County Open Data api
[](https://nodei.co/npm/scram/)
Use:
- `$ npm install scram`
- visit http://data.saccounty.net/developers/ and obtain an API key
```js
var scram = import(scram)
scram.apiKey = '21235avalidapikey142' //note the quotes
//scram.resouce = 'datastreams' // the default value, but change it...
// a stream of guids
scram.available()
//stream info to stdout by default, or pass custom callback as last arg
scram.info(guid)
// stream 3 results from data to stdout by default, or pass custom callback as last arg
scram.data(guid, 3)
```
The API provides several types of resources (datastreams, datasets,
visualizations, and dashboards). By default, the only looks at datastreams.
This can be changed by modifying the `RESOURCES` variable in `.env`.
## Module
The module provides three functions:
- available() :
stream the guids available in datastreams to process.stdout
- info(guid, infoProcessor):
print info about a guid (or process with a custom callback function
infoProcessor)
- data(guid, limit=50, streamProcessor):
stream data from guid to process.stdout (or process with a custom
callback function streamProcessor)
## Command line
The module also provides a wrapper for command-line interaction, `scram-cli`.
It's set up to populate api key and default resource from a .env file.
### Setup
- `npm install scram` and `npm link scram`, which will put `scram-cli` in your
path (and install scram globally)
- copy or simlink bin/.env to the working directory where you
will use the script
```sh
$ ln -s $(npm prefix -g)/lib/node_modules/scram/bin/.env .
```
- open .env and edit the line below so after the = is the API key
obtained from http://data.saccounty.net/developers/. Note no quotes here.
```sh
SAC_API_KEY=21235avalidapikey142
```
### Use
Interact with the api from the command line!
Print help,
```sh
$ scram-cli -h
```
List all GUIDs in the current resource (defined in `.env`),
```sh
$ scram-cli
```
Query info (metadata) on a GUID
```sh
$ scram-cli info GUID
```
Stream data from a GUID
```sh
$ scram-cli data GUID
```
## Contributing
- Fork on github ( https://github.com/ashander/scram/fork )
- Create a branch with a good name (`git checkout -b my-new-feature`)
- Commit your changes (`git commit -am 'Add some feature'`)
- Push the branch (`git push origin -u my-new-feature`)
- Create a new Pull Request on github
## Errata
Note: versions before 0.3.0 mistakenly contained an api key and have been
unpublished.