How to use Zipa for getting and manipulating data

Getting data is as simple as calling a function, check out how to make a simple get, pass arguments and manage objects.

Simple GET

For well written APIs the calls will have much sense. For example, for getting all repos from django GitHub organization you just call:

from zipa import api_github_com as gh

Passing arguments

Function arguments are passed to the request.


This would do a GET /orgs/django/repos?page=2

Using custom headers

Passing custom headers for each request can be done by adding to the config object, an headers dict.

from zipa import api_awesomeapi_com as aw

aw.config.headers = {
    'user': 'test-user',
    'api-key': 'n131390cxs09f0-w42k34ha'

aw.get_all_entites()**{'property': 'value'})

Using a custom response handler

By default, zipa will raise HTTPError for responses with status_code between 400 and 599 included.

from zipa import api_awesomeapi_com as aw

def response_handler(response):
    if response.status_code >= 400:
        if response.status_code == 400:
            raise BadRequest
        elif response.status_code == 404:
            return default_value
            raise SomeException

        return response.json()
    except ValueError:
        raise BadResponse

aw.config.response_handler = response_handler

Creating an object

gist ='Test gist', files={'empty.txt': {'content': 'a'}})

Deleting an object


See Also

SSL Certificate Verification

The magic behind Zipa

Here are the rules zipa is following when doing its magic.


Zipa is a magic pythonic REST client that allows you to easily access REST APIs that follow [...]