chwrapper

Release v0.3. (Installation)

chwrapper is a simple python wrapper around the Companies House API

>>> import chwrapper
>>> s = chwrapper.Search()
>>> r = s.search_officers("John Smith")
>>> r.status_code
200
>>> r.headers['content-type']
'application/json'
>>> r.json()
{'kind': 'search#officers', 'items_per_page': 20, 'start_index': 0,
'total_results': 731629,...}

User Guide

Installation

Distribute & Pip

Installing chwrapper is simple with pip:

$ pip install chwrapper

Get the Code

Chwrapper is available on GitHub.

You can either clone the public repository:

$ git clone git://github.com/jamesgardiner/chwrapper.git

Download the tarball:

$ curl -OL https://github.com/jamesgardiner/chwrapper/tarball/master

Or, download the zipball:

$ curl -OL https://github.com/jamesgardiner/chwrapper/zipball/master

Once you have a copy of the source, you can embed it in your Python package, or install it into your site-packages easily:

$ python setup.py install

Quickstart

Here is a quick introduction to chwrapper.

First, make sure that:

Creating a search object with chwrapper is simple. Begin by importing the chwrapper module:

>>> import chwrapper

And then create a Search object

>>> s = chwrapper.Search(access_token="12345")

This creates a Search object called s.

An access token can be obtained from Companies House and can either be passed explicitly to the Search object, or implicitly as an environment variable called COMPANIES_HOUSE_KEY or CompaniesHouseKey.

To query the API, we can use the Search object’s methods. For example:

>>> r = s.search_companies("1234567")
>>> r.status_code
200
>>> r.json
{'start_index': 0, 'kind': 'search#companies', 'page_number': 1,
'total_results': 1,...}

All the Search class methods can be found in the Developer Interface.

Developer Interface

All of chwrappers’ functionality is contained in the Search class. Each of the methods returns an instance of the Response object, more details of which can be found in the Requests documentation.

Contributor Guide

I’d welcome contributions from the community. See CONTRIBUTING.md for more info.: