Discussions

Expand all | Collapse all

Looking for simplest example to access quickbase using python

  • 1.  Looking for simplest example to access quickbase using python

    Posted 08-11-2018 17:02
    Can someone point me to examples that show how a quickbase/db can be accessed from the command line/using python -?  We would like to access, add, delete, change records and create reports - and in addition to the GUI provided, do such using CLI tools and python (saw pybase on github, am having some difficulty with it - unless someone can provide a complete example -?)


  • 2.  RE: Looking for simplest example to access quickbase using python

     
    Posted 08-14-2018 16:34
    Use the API --> https://help.quickbase.com/api-guide/index.html

    I use node.js so I'm not familiar with Python, but it all essentially works the same.

    See this library:

    http://docs.python-requests.org/en/master/

    This should allow you to do whatever your heart desires.

    Hope this helps,

    ~Rob


  • 3.  RE: Looking for simplest example to access quickbase using python

    Posted 03-29-2019 17:37
    Has anyone gotten this to work?


  • 4.  RE: Looking for simplest example to access quickbase using python

    Posted 07-15-2019 16:13
    Yes, do you still need help?


  • 5.  RE: Looking for simplest example to access quickbase using python

    Posted 08-05-2019 00:53
    I'm all set on getting Python to work with the API, but if you have any suggestions or resources I'd love to hear about them and/or share what I've done



  • 6.  RE: Looking for simplest example to access quickbase using python

    Posted 08-06-2019 15:54
    Hi,

    Been using pyqb (https://github.com/sjmh/pyqb) for all of my python work w/the Quickbase API. It's not complete, but easy to fork and add to.


  • 7.  RE: Looking for simplest example to access quickbase using python

    Posted 3 days ago
    I know that this is old...but I got here from a Google search for simple example so I wanted to help the next guy/gal out.  Here is my "simplest example."
    #!python3
    import requests
    import xmltodict
    from xml.etree import ElementTree as et
    import pprint
    pp = pprint.PrettyPrinter(indent=2)
    
    # ----------Add your personal stuff here:-----------
    yourEmail = 'your@email.here'
    yourPassword = 'verygoodpassword'
    aTableID = 'xxx5yyyyy'
    companyURLPrefix = 'joescookies'
    
    # -------------Authenticate to get a ticket--------------
    # one could use a user token here instead.
    headers = {
        "Content-Type": "application/xml",
        "Accept-Charset": "utf-8",
        "QUICKBASE-ACTION": "API_Authenticate"
    }
    # build an XML payload
    payload = et.Element('qdbapi')
    username = et.SubElement(payload, 'username')
    username.text = yourEmail
    password = et.SubElement(payload, 'password')
    password.text = yourPassword
    # hours = et.SubElement(payload, 'hours')  # Optional
    # hours.text = '24'  # Optional
    # make the payload ready for shipping
    humanPayload = et.tostring(payload)
    url2 = f'https://{companyURLPrefix}.quickbase.com/db/main'
    resp = requests.post(url2, data=humanPayload, headers=headers)
    # pp.pprint(vars(resp))
    # Parse the response so we can pull out the ticket
    parsed = et.XML(resp.text)
    authticket = parsed.find('ticket').text
    
    # -----------Using the authticket we can actually do some work--------------
    # this example is to get the API_GetDBInfo
    url3 = f'https://{companyURLPrefix}.quickbase.com/db/{aTableID}'
    headersGetDB = {
        "Content-Type": "application/xml",
        "Accept-Charset": "utf-8",
        "QUICKBASE-ACTION": "API_GetDBInfo"
    }
    # build another XML payload
    payloadGetDB = et.Element('qdbapi')
    ticket = et.SubElement(payloadGetDB, 'ticket')
    ticket.text = authticket
    # make the payload ready for shipping
    humanPayloadGetDB = et.tostring(payloadGetDB)
    respgetdb = requests.post(url3, data=humanPayloadGetDB, headers=headersGetDB)
    # print(et.XML(respgetdb.text).find('errtext').text)  # this checks for the errtext
    # pp.pprint(vars(respgetdb))  # this pumps out the full response
    # This makes the response a little nicer to sort through
    parsedGetDB = et.XML(respgetdb.text)
    # This is some of the info enbedded into the XML response.
    parsedGetDB.find('dbname').text
    parsedGetDB.find('lastModifiedTime').text
    parsedGetDB.find('lastRecModTime').text
    parsedGetDB.find('createdTime').text
    parsedGetDB.find('numRecords').text
    parsedGetDB.find('mgrID').text
    parsedGetDB.find('mgrName').text
    parsedGetDB.find('time_zone').text
    parsedGetDB.find('version').text
    ​


    ------------------------------
    David Choi
    ------------------------------