This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
# knackhq

Python wrapper for [KnackHQ API](http://knackhq.com/)

[![Build Status](https://travis-ci.org/amancevice/knackhq.svg?branch=master)](https://travis-ci.org/amancevice/knackhq)
[![PyPI version](https://badge.fury.io/py/knackhq.svg)](https://badge.fury.io/py/knackhq)


## Installation

```bash
pip install knackhq
```


## Connect to KnackHQ

Create a `KnackHQClient` instance to begin interacting with KnackHQ. Supply an app ID, an API key, and an optional API endpoint URL to the client. Alternatively, set these values in your environment with:

* `KNACKHQ_APP_ID`
* `KNACKHQ_API_KEY`
* `KNACKHQ_ENDPOINT`

```python
import knackhq

# KNACKHQ_APP_ID = <set in="" env="">
# KNACKHQ_API_KEY = <set in="" env="">
# KNACKHQ_ENDPOINT = <set in="" env="">

client = knackhq.KnackHQClient()
```


## Reading from KnackHQ


### Raw requests

In some cases you may wish to send a raw HTTP request to the KnackHQ JSON API. This will not normally be necessary but it is available:

```python
client.request("https://api.knackhq.com/v1/objects/object_1", 'GET')
client.request("https://api.knackhq.com/v1/objects/object_1", 'POST', body='{key: val}')
```


### Reading Objects

Iterate over objects in an app using the `client` object:

```python
for obj in client:
print obj

# => <knackhqobject v1="" objects="" object_1="">
# <knackhqobject v1="" objects="" object_2="">
# <knackhqobject v1="" objects="" object_3="">
# ...
# <knackhqobject v1="" objects="" object_n="">
```

Or, find an object by its key:

```python
obj = client.get_object('object_1')
```

If you are unsure of the key, use the `name` keyword argument to get the object by its name:

```python
obj = client.get_object(name='Customers')
```

Find metadata keys using the `keys()` function. Get metadata on an object using brackets (`[]`):

```python
obj.keys()

# => ['status',
# 'tasks',
# 'name',
# 'inflections',
# 'fields',
# 'connections',
# 'user',
# 'key',
# '_id']

obj['key']

# => 'object_1'
```


### Reading Records

Iterate over records in an object:

```python
for record in obj:
print record

# => <knackhqrecord v1="" objects="" object_1="" records="" ...="">
# <knackhqrecord v1="" objects="" object_2="" records="" ...="">
# <knackhqrecord v1="" objects="" object_3="" records="" ...="">
# ...
# <knackhqrecord v1="" objects="" object_n="" records="" ...="">
```

Use the `where()` function to filter records. Where accepts the following keyword-arguments:

* `record_id`
* `page`
* `rows_per_page`
* `sort_field`
* `sort_order`
* `filters`

If `record_id` is provided (and the record exists) `where(record_id=<id>)` will yield a collection of length 1.

Use `filters` to refine your search:

```python
filters = [
{
field: 'field_1',
operator: 'is',
value: 'test'
}, {
field: 'field_2',
operator: 'is not blank'
}
]

for record in obj.where(filters=filters):
print record

# => <knackhqrecord v1="" objects="" object_1="" records="" ...="">
# <knackhqrecord v1="" objects="" object_2="" records="" ...="">
# <knackhqrecord v1="" objects="" object_3="" records="" ...="">
# ...
# <knackhqrecord v1="" objects="" object_n="" records="" ...="">
```


## Writing to KnackHQ

*TODO*
Release History

Release History

0.0.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
knackhq-0.0.4.tar.gz (5.4 kB) Copy SHA256 Checksum SHA256 Source Jul 7, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting