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
Link to this function
api_key()
View Source
api_key()
View Source
api_key() :: String.t()
api_key() :: String.t()
Returns the API key.
Examples
iex> OpenStates.api_key()
System.get_env("OPENSTATES_API_KEY")
Link to this function
headers()
View Source
headers()
View Source
headers() :: keyword()
headers() :: keyword()
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)
View Source
query(query_string :: String.t()) ::
{:ok, Neuron.Response.t()} | {:error, response :: term()}
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}}
Link to this function
url()
View Source
url()
View Source
url() :: String.t()
url() :: String.t()
Returns the API endpoint URL.
Examples
iex> OpenStates.url()
"https://openstates.org/graphql"