Generic python bindings to connect to the Poplus components APIs.
Project description
Generic python bindings to connect to the Poplus components APIs.
Actually, this is only a convenient wrapper around Tortilla generic API wrapper, with some specialized instructions to use Poplus components apis.
The main advantage of Tortilla over other wrappers is that it allows access through a full object oriented interface, both when requesting data, and when parsing the results.
Results are transformed from JSON into a Python dictionary, and then bunchified.
Installation
poplus-pci is available as a module on PyPi, to install, simply run:
pip install poplus-pci
Alternatively, you can clone this repo and install as you see fit.
Quick start
First, let’s try read-only access to the legisladores-ar instance of Popit at mySociety, and get the paged list of political organizations in the argentinian parliament:
from pci import Popit popit = Popit( instance='legisladores-ar', host='popit.mysociety.org', )
instance Name of the instance you want to point to. There can be more than one for one installation.
host The hostname of the PopIt server.
Once created an instance, it’s easy to access data, using a full object oriented interface:
os = popit.organizations.get() # there are 65 organizations print(os.total) # but only 30 have been grabbed print(o.page) for i, o in enumerate(os.result, start=1): print("{0}: {1}".format(i, o.name)) # how to get next page? print os.next_url # get it os = popit.organizations.get(params={'page': 2})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.