0

I want to use the data of http://data.seattle.gov/api/views/kzjm-xkqj/rows.json with SODA API.

In the API DOCS, i found it using a language ruby, python, coffeescript, cURL. And it use require() function.
But I don't know how exactly the require() function is work. I found about the require. Isn't it something like the loader of a jscript file???

I think first line is maybe... using this way

require 'https://soda.demo.socrata.com/resource/earthquakes.json?source=uw'


request = require 'request'
options = uri: 'https://soda.demo.socrata.com/resource/earthquakes.json?
$$app_token=APP_TOKEN&recall_id=94'
request options, (err, response, body) ->  console.log body

I change the coffeescript into javascript, but i still don't know. var options, request;

request = require('request');
options = {uri: 'https://data.seattle.gov/Public-Safety/Seattle-Real-Time-Fire-911-
Calls/kzjm-xkqj/rows.json?$$app_token=APP_TOKEN&recall_id=94' };
request(options, function(err, response, body) {  return console.log(body); } );

And.. Sorry for my poor English.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
jayleaf
  • 29
  • 3

1 Answers1

0

Take a look at the API docs here: http://dev.socrata.com/consumers/getting-started

If you want to pull data in from the dataset's API use this endpoint: http://data.seattle.gov/resource/kzjm-xkqj.json

I think what you want to do is pull in the rows from that dataset and do something with them in JavaScript. I'd recommend using jQuery (a very common JavaScript library) to achieve this.

In jQuery all you need to do to get the data from the API is this:

$.get( "http://data.seattle.gov/resource/kzjm-xkqj.json", function( data ) {
  console.log(data);
});

As you will see this outputs the first 1000 rows of data (you need to use the $offset parameter to get the next set of rows).

The rows are stored in data as a list of Objects, so to output the second row of data:

$.get( "http://data.seattle.gov/resource/kzjm-xkqj.json", function( data ) {
  console.log(data[1]);
});
Adrian Laurenzi
  • 286
  • 1
  • 6