Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amancevice/knackhq
Python wrapper for KnackHQ API
https://github.com/amancevice/knackhq
Last synced: 4 months ago
JSON representation
Python wrapper for KnackHQ API
- Host: GitHub
- URL: https://github.com/amancevice/knackhq
- Owner: amancevice
- License: mit
- Created: 2016-05-02T13:04:48.000Z (almost 9 years ago)
- Default Branch: main
- Last Pushed: 2024-03-10T15:28:18.000Z (12 months ago)
- Last Synced: 2024-10-10T04:07:55.354Z (4 months ago)
- Language: Python
- Size: 81.1 KB
- Stars: 5
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KnackHQ


[](https://github.com/amancevice/knackhq/actions/workflows/pytest.yml)
[](https://codeclimate.com/github/amancevice/knackhq/test_coverage)
[](https://codeclimate.com/github/amancevice/knackhq/maintainability)Python wrapper for [KnackHQ API](https://www.knack.com/developer-documentation/)
## Installation
```bash
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:
```python
import knackhqapp = knackhq.KnackApp('', '')
```Alternatively, set these values in your environment with:
* `KNACKHQ_APP_ID`
* `KNACKHQ_API_KEY`
* `KNACKHQ_ENDPOINT` (optional)```python
app = knackhq.KnackApp()
```## Reading from KnackHQ
### Raw requests
You may wish to send a raw request response from the KnackHQ API:
```python
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:
```python
obj = app['object_1'] # or,
obj = app['MyObject']
```Access object metadata using dictionary syntax:
```python
obj['name']
obj['key']
obj['fields']
```### Getting Records
Use the `get_records()` method to iterate over records in an object:
```python
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:
```python
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:
```python
record = obj.get_record('1234567890ABCDEF')
```## Writing Records
*TODO*