Package: quickbase-client
A High-Level Quickbase Python API Client & Model GeneratorQuickbase-Client is a library for interacting with Quickbase applications through their
RESTful JSON API (https://developer.quickbase.com/). It has features to generate model classes
for tables in your Quickbase app, and provides high level classes to interface between Python
objects and the Quickbase tables.Quick StartInstallationInstallation can be done through pip:pipinstallquickbase-clientThis will install both the libraryquickbase_client, and a command line toolqbcfor
running some handy scripts.Generating your ModelsTo interact and authenticate with your Quickbase applications you need a User Token. You can read
the Quickbase documentationhereon how to create one.
It is recommended to set an environment variableQB_USER_TOKENwith this value:exportQB_USER_TOKEN=mytokenfromquickbase;Next, say you have a hypothetical Quickbase Application named MyApp athttps://foo.quickbase.com/db/abcdefthat has tables for tracking things
against a repository like Issues & Pipelines.Running the following:qbcrunmodel-generate-ahttps://foo.quickbase.com/db/abcdefWould generate a directory structure likemodels
├── __init__.py
└── my_app
    ├── __init__.py
    ├── app.py
    ├── github_issue.py
    └── gitlab_pipeline.pyAnd classes likeGitHubIssuewhere you can interact with the data model through a Python object.Writing Records to QuickbaseClasses likeGitHubIssuethat subclassQuickbaseTablealso get a factory class-methodclient(user_tok)which creates an instance of the higher-levelQuickbaseTableClientto
make API requests for things related to that table:client=GitHubIssue.client(user_tok=os.environ['QB_USER_TOKEN'])new_issue=GitHubIssue(title='Something broke',# you get friendly-kwargs for fields without worrying about ID'sdescription='Please fix!',date_opened=date.today()# things like Python date objects will be serialized)response=client.add_record(new_issue)print(response.json())# all methods (except for query) return the requests Response objectQuerying Records from QuickbaseYou can also use the client object to send queries to the Quickbase API through thequerymethod. This method will serialize the data back in to a Python object. Thequerymethod on the
table class takes aQuickbaseQueryobject which is high level wrapper around the parameters
needed to make a query.Notably, thewhereparameter for specifying the query string. There is one (and in the future
there will be more) implementation of this which allows you to build query-strings through
higher-level python functions.You can use the methods exposed in thequickbase_client.querymodule like so:# convention to append an underscore to these methods to avoid clashing# with any python keywordsfromquickbase_client.queryimporton_or_before_fromquickbase_client.queryimporteq_fromquickbase_client.queryimportand_schema=GitHubIssue.schemaq=and_(eq_(schema.date_opened,schema.date_created),on_or_before_(schema.date_closed,date(2020,11,16)))print(q.where)# ({'9'.EX.'_FID_1'}AND{'10'.OBF.'11-16-2020'})recs=client.query(q)# recs will be GitHubIssue objects unless passing raw=Trueprint([str(r)forrinrecs])# ['<GitHubIssue title="Made And Closed Today" id="10000">']Controlling Lower-Level API CallsLastly, say you want to deal with just posting the specific json/data Quickbase is looking for.
TheQuickbaseTableClientobject wraps the lower-levelQuickbaseApiClientobject which has
methods for just sending the actual data (with an even lower-level utilityQuickbaseRequestFactoryyou could also use). These classes manage hanging on to the user token,
and the realm hostname, etc. for each request that is made.For example, note the signature ofqueryinQuickbaseApiClient:defquery(self,table_id,fields_to_select=None,where_str=None,sort_by=None,group_by=None,options=None):You can get to this class by going through the table client:api = client.api, or from
instantiating it directlyapi = QuickbaseApiClient(my_user_token, my_realm)With this, we could make the exact same request as before:api=QuickbaseApiClient(user_token='my_token',realm_hostname='foo.quickbase.com')response=api.query(table_id='abcdef',where_str="({'9'.EX.'_FID_1'}AND{'10'.OBF.'11-16-2020'})")data=response.json()More Resourcesexamplesdirectory.CONTRIBUTINGLICENSEOther NotesCurrently a bunch of duplicate aliases forQuickBasetoQuickbasesince this
was originally released with everything prefixed asQuickBase-. But since Quickbase
is branding more to “Quickbase”, this will eventually be the main naming for
version 1.0 in an effort to keep more consistent. So prefer to useQuickbase-prefixed classes
as in the future the other aliases will be dropped.