Skip to content

Commit beea14a

Browse files
committed
add documentation to README.md
1 parent ef2be18 commit beea14a

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,42 @@
77
Unofficial Quickbase JSON API wrapper for python
88

99
Makes life a little easier!
10+
11+
## Quickstart
12+
13+
### Installation
14+
To install, run `pip install quickbase-json-api-client`
15+
16+
### Initialize Client
17+
Use the following code to create and initialize a client object.
18+
```
19+
from quickbase_json.client import QuickbaseJSONClient # import client
20+
21+
client = QuickbaseJSONClient(realm="yourRealm", auth="userToken")
22+
```
23+
24+
Where `yourRealm` is the name (subdomain) of your Quickbase Realm and `userToken` is the user token used to authenticate
25+
with the realm.
26+
27+
### Query Records
28+
Querying for records is one of the most useful features of the Quickbase JSON API. Querying records with QJAC can be done
29+
using the following code
30+
31+
`response = client.query_records('tableId', fids, 'queryString')`
32+
33+
Where `tableId` is the ID of the table you wish to query from, `fids` is a list of field IDs you wish to receive and `queryString`
34+
is a quickbase [query string](https://help.quickbase.com/api-guide/componentsquery.html).
35+
36+
### Response Objects
37+
38+
A `QBResponse` object is returned when querying records with QJAC. A `QBResponse` has several methods that make
39+
handling returned data easier. Here are a few of the most useful ones:
40+
41+
**denest()**
42+
43+
Denests the data. I.e. changes `{'fid': {'value': 'actualValue'}}` to `{'fid': 'actualValue'}`
44+
45+
**orient(orient='records', key='3')**
46+
47+
Orients the data. Currently, the only option is 'records'. This will orient the returned data into a "record like structure", i.e. changes
48+
`{'fid': 'actualValue', 'fid': 'actualValue'}` to `{'key': {etc: etc}}`

src/quickbase_json/helpers.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@ class FileUpload(dict):
103103
Represents a file object for easy upload to quickbase.
104104
When uploading, set FID to FileUpload directly, bypass {'value': etc}
105105
"""
106+
107+
def __init__(self, path: str):
108+
"""
109+
:param path: path to file
110+
"""
111+
super().__init__()
112+
self.path = path
113+
114+
with open(path, 'rb') as f:
115+
# get file as a b64 string for upload to quickbase
116+
file = base64.b64encode(f.read()).decode()
117+
self.update({'value': {'fileName': f'{f.name.split("/")[-1]}', 'data': file}})
118+
119+
120+
class File(dict):
121+
"""
122+
Represents a file object for easy upload to quickbase.
123+
When uploading, set FID to FileUpload directly, bypass {'value': etc}
124+
"""
125+
106126
def __init__(self, path: str):
107127
"""
108128
:param path: path to file

0 commit comments

Comments
 (0)