OpenStates v0.1.2 OpenStates View Source
An Elixir client for the OpenStates GraphQL API.
Link to this section Summary
Link to this section Types
Link to this type
args() View Source
Link to this type
response()
View Source
response()
View Source
response() :: {:ok, Neuron.Response.t()} | {:error, response :: term()}
response() :: {:ok, Neuron.Response.t()} | {:error, response :: term()}
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 request headers.
Examples
iex> OpenStates.headers()
["X-API-KEY": OpenStates.api_key()]
Link to this function
jurisdictions()
View Source
jurisdictions()
View Source
jurisdictions() :: response()
jurisdictions() :: response()
Fetches the jurisdiction objects from the API.
Link to this function
jurisdictions(list) View Source
Link to this function
people_from(opts) View Source
Fetches legislators from a particular jurisdiction and organization.
Link to this function
query(query_string) View Source
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
sigil_q(query_string, list) View Source
Calls query/1
passing the string as the argument.
Example
~q"""
{
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"