Interact with KnackHQ API
Project description
KnackHQ
Python wrapper for KnackHQ API
Installation
pip install knackhq
Connect to KnackHQ
Create a KnackApp
instance to begin interacting with KnackHQ. Supply an app ID, an API key, and an optional API endpoint URL to the client:
import knackhq
app = knackhq.KnackApp('<app_id>', '<api_key>')
Alternatively, set these values in your environment with:
KNACKHQ_APP_ID
KNACKHQ_API_KEY
KNACKHQ_ENDPOINT
(optional)
app = knackhq.KnackApp()
Reading from KnackHQ
Raw requests
You may wish to send a raw request response from the KnackHQ API:
app.request('GET', 'objects/object_1/records') # or,
app.request('GET', 'objects', 'object_1', 'records')
Getting Objects
Use dictionary syntax to get objects by name or key:
obj = app['object_1'] # or,
obj = app['MyObject']
Access object metadata using dictionary syntax:
obj['name']
obj['key']
obj['fields']
Getting Records
Use the get_records()
method to iterate over records in an object:
for record in obj.get_records():
print(record)
Supply arguments to get_records()
to filter records. Options include:
record_id
page
rows_per_page
sort_field
sort_order
filters
Use filters
to refine your search:
filters = [
{
field: 'field_1',
operator: 'is',
value: 'test'
}, {
field: 'field_2',
operator: 'is not blank'
}
]
for record in obj.get_records(filters=filters):
print(record)
If you know the ID of the record, use get_record()
to return a single record:
record = obj.get_record('1234567890ABCDEF')
Writing Records
TODO
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.
Source Distribution
File details
Details for the file knackhq-0.2.0.tar.gz
.
File metadata
- Download URL: knackhq-0.2.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c9dfcabbce7c408ccaf8fb378d1a6d43531c91eed51064c78aa3f210924a00e |
|
MD5 | 7bae61aca6925b6374bf39698ef5a107 |
|
BLAKE2b-256 | 9ba45438ac23b3d5de38b882cd321bdd020f3ed91d07ae2a4e65e7b66eccbbbf |