Census v0.1.3 Census.Query View Source

Struct representing an API query.

Link to this section Summary

Functions

Create a new query

Returns the api url for a given query

Link to this section Types

Link to this type t() View Source
t() :: %Census.Query{client: term, foreach: term, get: term, within: term}

Link to this section Functions

Create a new query.

Usage:

iex> client = Census.Client.new("YOUR_API_KEY")
iex> Census.Query.new(client, get: "NAME,P0010001", foreach: "COUNTY:*", within: "STATE:55")
%Census.Query{
  client: %Census.Client{api_key: "YOUR_API_KEY", dataset: "SF1", vintage: "2010"},
  foreach: "COUNTY:*",
  get: "NAME,P0010001",
  within: "STATE:55"
}

Returns the api url for a given query.

Usage:

iex> client = Census.Client.new("YOUR_API_KEY")
iex> query = Census.Query.new(client, get: "NAME", foreach: "COUNTY:*", within: "STATE:55")
iex> Census.Query.url(query)
"http://api.census.gov/data/2010/sf1?key=YOUR_API_KEY&get=NAME&for=COUNTY:*&in=STATE:55"