OpenStates v0.1.0 OpenStates View Source

Documentation for OpenStates.

Link to this section Summary

Functions

Returns the API key

Returns the API headers

Constructs a GraphQL query to the OpenStates API

Returns the API endpoint URL

Link to this section Functions

Returns the API key.

Examples

iex> OpenStates.api_key()
System.get_env("OPENSTATES_API_KEY")

Returns the API headers.

Examples

iex> OpenStates.headers()
["X-API-KEY": OpenStates.api_key()]
Link to this function

query(query_string) View Source
query(query_string :: String.t()) ::
  {:ok, Neuron.Response.t()} | {:error, response :: term()}

Constructs a GraphQL query to the OpenStates API.

Example

{:ok, response} =
  OpenStates.query("""
  {jurisdictions {
    edges {
      node {
        id
      }
    }
  }}
  """)
#=> {:ok, %Neuron.Response{body: %{ ... }, headers: [ ... ], status_code: 200}}

Returns the API endpoint URL.

Examples

iex> OpenStates.url()
"https://openstates.org/graphql"