sunlight.service – API superclass

This page is more aimed to API hackers, not so much API users. If you’re a user, feel free to read up on how this works, but this might not be the easiest thing to develop an app around.

Classes and Variables

Base service class. All API classes (such as say - sunlight.services.openstates.OpenStates) inherit from this.

class sunlight.service.EntityDict(data={}, meta=None)[source]

EntityDict provides a dictionary representation of an API entity along with a _meta dictionary that contains information about the query results. This could include result count and pagination details.

class sunlight.service.EntityList(data=[], meta=None)[source]

EntityList provides an iterable of API entities along with a _meta dictionary that contains information about the query results. This could include result count and pagination details.

class sunlight.service.Service[source]

Base class for all the API implementations, as well as a bunch of common code on how to actually fetch text over the network.

get(*args, **kwargs)[source]

Get some data from the network - this is where we actually fetch something and make a request.

Warning

Be sure that API_KEY was set before calling this method. This will throw a sunlight.errors.NoAPIKeyException if the API_KEY is not set.

args:
top_level_object (str): Thing to query for (such as say,
“bills” for OpenStates )
kwargs:
These arguments will be passed to the underlying API implementation to help create a query. Validation will happen down below, and on a per-API level.