Socrata v0.1.0 Socrata.Client View Source
The Client is the main interface of the library. Using a Client, you can get the records and metadata for a data set.
The Client accepts optional paramaters domain
and app_token
. These values
can either be configured when you call new/3
or in your application’s
config/config.exs
file:
config :socrata,
domain: "example.com",
app_token: "blah blah blah"
For more information about tokens and their use, see the Socrata App Tokens docs.
Link to this section Summary
Functions
Gets the records for a data set
Gets the view information (metadata) for a data set
Creates a new Client struct
Link to this section Types
Link to this section Functions
get_records(Socrata.Client.t(), Socrata.Query.t(), String.t(), keyword()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Gets the records for a data set.
Options
The opts
parameter of the function is passed directly to HTTPoison.get!/3
so you can control the request/response life cycle.
Note: the params
key of the options is overwritten by the query struct.
Example
alias Socrata.{Client, Query}
query =
Query.new()
|> Query.limit(5)
Client.new("6zsd-86xi", "data.cityofchicago.org")
|> Client.get_records(query)
# %HTTPoison.Response{
# body: "[{\"arrest\":false,\"beat\":\"0412\",\"block\":\"016XX E 86TH PL\", ...}, ... ]",
# headers: [ {"X-Socrata-RequestId", "blahblahblah"}, ... ],
# request_url: "https://data.cityofchicago.org/resource/6zsd-86xi.json?%24limit=5",
# status_code: 200
# }
get_view(Socrata.Client.t(), keyword()) :: HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()
Gets the view information (metadata) for a data set.
Options
The opts
parameter of the function is passed directly to HTTPoison.get!/3
so you can control the request/response life cycle.
Example
alias Socrata.Client
Rader.new("6zsd-86xi", "data.cityofchicago.org")
|> Client.get_view()
# %HTTPoison.Response{
# body: "{\"name\": \"Crimes - 2001 to present\", ... }",
# headers: [ {"X-Socrata-RequestId", "blahblahblah"}, ... ],
# request_url: "https://data.cityofchicago.org/views/6zsd-86xi.json",
# status_code: 200
# }
new(String.t(), String.t(), String.t()) :: Socrata.Client.t()
Creates a new Client struct.