0

I'm trying to read the table contents in Quick Base. As of now I'm downloading the files from Quickbase in CSV format and reading them from the python pandas package. Is there a way to get access to QuickBase tables using python API? So that we can avoid the process of downloading the files and directly reading the table contents directly from QuickBase

Progman
  • 16,827
  • 6
  • 33
  • 48
Venkatesh Gandi
  • 441
  • 1
  • 9
  • 24

2 Answers2

1

Yes, can you get table data via the Quickbase REST API: https://developer.quickbase.com

There isn't a directly supported SDK, but it's fairly simple to interact with this API using the Python json and request libraries to make a POST call.

import json
import requests

headers = {
    'QB-Realm-Hostname': '{QB-Realm-Hostname}',
    'User-Agent': '{User-Agent}',
    'Authorization': '{Authorization}'
}
body = {}
r = requests.post(
'https://api.quickbase.com/v1/records/query', 
headers = headers, 
json = body
)

print(json.dumps(r.json(),indent=4))
Erich Wehrmann
  • 464
  • 2
  • 11
  • Hi @Erich, I think only the content in {} is variable. Am I correct? can we keep the remaining things as the same? If so, what is the User-Agent? It seems https://developer.quickbase.com/operation/getTable is doing the same thing. Can you please explain more on how it works? – Venkatesh Gandi Mar 15 '21 at 17:01
  • 1
    The variables you would want to replace are: {QB-Realm-Hostname} the subdomain, {User-Agent} this is optional, just gives a way to identify who is sending the request, {Authorization} which is the QB-USER-TOKEN and body which is where you build a payload with the query parameters. – Erich Wehrmann Mar 17 '21 at 12:50
  • 1
    Also, developer.quickbase.com/operation/getTable will only return metadata about the table, not the data in the table – Erich Wehrmann Mar 17 '21 at 12:57
  • So, what could be the body to get all the table data? and also we will get the table data in JSON format, Am I correct? – Venkatesh Gandi Mar 17 '21 at 16:06
  • Hi @Erich, Can you please suggest on the above comment, please? – Venkatesh Gandi Mar 23 '21 at 10:39
  • 1
    To get all data you first need to know all of the numeric field ids for that table...to get all field ids, run this call https://developer.quickbase.com/operation/getFields...Once you have all fields, the body of the Query for Data call should look like this where the select parameter contains a list of all field ids: – Erich Wehrmann Mar 24 '21 at 13:22
  • 1
    { "from": "bck7gp3q2", "select": [1,2,3] } – Erich Wehrmann Mar 24 '21 at 13:23
0

Note: Please only comment if you have helpful things to say. I am fully aware that this should be a comment but I don't have enough reputation and I need help.

To Erich Wehrmann's answer:

Hello, thank you for your help. I have gotten here but I don't know how to actually get the data out of my table instead of just the field names in json format.

Do you know how I can actually get the data from my table?

import json
import requests

headers = {
    'QB-Realm-Hostname': 'my-realm.quickbase.com',
    'User-Agent': '{User-Agent}',
    'Authorization': 'QB-USER-TOKEN my-token',
    'Content-Type': 'application/json',
}

body = {
    'from': 'my-table-id', 'select': '[1,2]'
}
r = requests.get(
'https://api.quickbase.com/v1/fields?tableId=my-table-Id',
headers = headers,
json = body
)

print(json.dumps(r.json(),indent=4))
KeyaD77
  • 21
  • 6
  • This would have been better as a [comment](https://stackoverflow.com/help/privileges/comment) to the answer instead of another answer since this doesn't really answer the question at hand here – Wasi Master Feb 03 '22 at 06:57
  • @WasiMaster I am aware this should be a comment but you have to have 50 reputation to comment and I need help on this question. I just need a continuation of this help instead of starting a whole new question. – KeyaD77 Feb 04 '22 at 15:25
  • 1
    @KeyD77 Oh, sorry for that. I thought StackOverflow allowed comments on your own posts without 50 rep, sorry for the misunderstanding Edit: I've just now noticed that you are not the question author, I didn't see that before, sorry again. – Wasi Master Feb 05 '22 at 08:50