Skip to content

rockwood/census

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Census

Elixir library for interacting with the US Census API

Installation

Add census to your list of dependencies in mix.exs:

def deps do
  [{:census, "~> 0.3"}]
end

Usage

Get an api key at api.census.gov/data/key_signup.html.

Create a client

iex> client = Census.client(YOUR_API_KEY, dataset: "SF1", vintage: 2010)

Clients will default to the 2010 SF1 dataset. Other datasets are available at census.gov

Query the api

Here, we're querying the total population for each county in Wisconsin. Documentation for available query parameters can be found at api.census.gov/data.html

iex> {:ok, resp} = Census.fetch(client, get: "NAME,H010001", foreach: "COUNTY:*", within: "STATE:55")
iex> resp.results
[%{"NAME" => "Adams County", "H010001" => "20875", ...}]

This library makes no attempt to coerce returned values. Almost everything is returned as a string, so you'll need to implement your own coercion if necessary.

License

This software is licensed under the Apache 2 License.

About

Elixir library for interacting with api.census.gov

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages