QuickBase PHP API Examples

i’ve had a few requests for examples of how to use the quickbase php api wrapper. so here goes:

setup the quickbase object with login info

include the library and setup the object by passing in username, password, true/false (xml/http), and dbID of the db/table you’ll be transacting with.

$quickbase = new QuickBase('username','password', true, 'dbID');

do a quickbase query

here, we setup a query to return field 3 where (field id 15 is equal to somevalue).

$queries = array(
        'fid' => '15',
        'ev'  => 'ex',
        'cri' => 'somevalue')

$results = $quickbase->do_query($queries, '', '', '3');

adding a record to a quickbase

this one is super easy. create an associative array with field id’s and values and then use the add_record method.

$fields = array(
        'fid' => '1',
        'value' => 'some value'),
        'fid' => '2',
        'value' => 'some value'),
        'fid' => '3',
'value'=>'some value')

edit a quickbase record

almost identical to add_record, setup the array and use the edit_record method.

$fields = array(
        'fid' => '1',
        'value' => 'some value'),
        'fid' => '2',
        'value' => 'some value'),
        'fid' => '3',
'value'=>'some value')

do a quickbase query

here, we setup a query to return field 3 where (field id 15 is equal to somevalue).

$queries = array(
        'fid' => '15',
        'ev'  => 'ex',
        'cri' => 'somevalue')

$results = $quickbase->do_query($queries, '', '', '5');

Published byJosh McGinnis

Josh is a software engineer, leader, startup advisor for the LA Chamber of Commerce and consultant residing in the Los Angeles area. Josh is passionate about helping entrepreneurs and businesses reach their maximum potential.


  • Eytan

    May 6, 2009 at 4:56 pm Reply

    Thanks for putting these examples together. They are helpful.

    One thing that I think might be a mistake in the add_record example is that the example you have above has it passing in “fid” as the id parameter. The code in qb.php, however, is expecting just “id” and so that causes things to not work as expected.

    I ran it both ways and when one uses “id” instead of “fid” it works as expected.

  • John

    May 25, 2009 at 11:52 pm Reply

    Josh , very nice sample.

    I had a misstake is used QuickBaseClient.js java library to query database to my web . But HTML pages using QuickBaseClient.js must be hosted within QuickBase applications.
    – I want to ask you: could i use quickbase php api wrapper for website hosted outside quickbase ?

    I appreciate it ,John.

    • Joshua

      May 26, 2009 at 5:57 am Reply

      Absolutely you can use the php sdk for apps outside of quickbase. All you need is a QuickBase user with the proper permissions for the operations you are trying to perform.

  • John

    May 26, 2009 at 10:43 pm Reply

    Josh, Thank for your fast response . I just send a private mail to your email : goodespeler@gmail.com about my situation. I need your help with quickbase php api. Please check it.
    I appreciate it, John.

  • John

    June 2, 2009 at 12:51 am Reply

    Thank Joshua, everything work perfect now. Great API library and very friendly support !!

  • Will

    June 5, 2009 at 9:33 am Reply

    I can’t seem to make this work. I’m getting the following error…

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in includes/qb.php on line 61

  • Will

    June 17, 2009 at 5:06 pm Reply

    Thank you!

    For developing this class; for responding so quickly; for the help troubleshooting my configuration error.

  • DBG

    June 29, 2009 at 6:41 pm Reply

    Joshua, how goes it? I’ve just taken over a QB project and am trying to use your wrapper. Am not too familiar with QB and seem to be hitting a roadblock. I’ve checked my server settings for Curl and have included your library.

    A few questions:

    – When I try to use the library, for example do_query(), nothing is returned, no errors, no results, nothing… not too sure where I am going wrong.

    – With do_query or edit_record: How do I determine which record I want to query or update? For example, I want FID 27 from #28845. Can you provide an example of this?

    – Where do I enter the Ticket #? In the wrapper $ticket = ” says to not change. A bit confused about this.

    – “setup a query to return field 3 where (field id 15 is equal to somevalue)”: A bit confused about this as well. If I want to return field 3, why am I using FID 15 instead of FID 3? Is this a miss-type?

    Will keep working at it; feel like I’m shooting in the dark a bit though. If you can point me in the right direction, great.


    • Luis Rolando Brenes

      August 27, 2012 at 4:17 pm Reply

      Hi, did you ever get this done?
      I am trying the same, basically with the same results.
      Thanks in advance,

  • John

    July 31, 2009 at 7:09 am Reply

    Hi Joshua,
    Do you have any solution for UTF-8 Font ? Query’s information do not display correct (explode) on website if database fields has UTF-8 content.
    – Do we need to set fields in database use UTF-8 like a default font? And how ? I tried many way but not success.
    Thank you very much .

  • Hunter

    November 5, 2009 at 1:17 pm Reply

    Quickbase can’t interpret PHP files can it? So I would have to host these on my own server and execute them there?

    Thanks for your help!


    • Joshua

      November 5, 2009 at 1:23 pm Reply

      No, it can’t so you would need to host these files. However, you could use the Javascript SDK which can be hosted using a QuickBase DB page.

  • Hunter

    November 5, 2009 at 1:37 pm Reply

    Good point. Thank you.

    I am looking at ways of using Flex/Flash with QB, but am running into all sorts of Sandbox violations unless I host the SWF within the Quickbase domain. I am actually fine with that, but it makes development tricky b/c my local host triggers the Sandbox violation messages too…

    Currently, I trust run a trace in Flex to make sure the API URLs have been built correctly. Then I upload the SWF and it runs perfectly. I am using Flash Builder 4 beta 2.

  • Joshua

    November 5, 2009 at 1:49 pm Reply

    Yea – in order for your SWF to work, we’d have to add your domain to our crossdomain.xml file here: http://www.quickbase.com/crossdomain.xml

    Which of course, we aren’t going to do as that isn’t feasible.

    We actually have a flex app that we use for the front-end, but we route all API requests to PHP files to handle the heavy lifting. This may help you with development as you’ll spend more time debugging php than flex and having to go through multiple builds and then re-uploading it.

    Firebug will also let you look at the request/response from the flex app to your PHP – again useful for local debugging.

    Have you looked Intuit’s Partner Platform? It’s a QuickBase-based platform that comes with a Flex QuickBase SDK – and it provides you a dev. sandbox for your Flex app. Check it out: https://ipp.developer.intuit.com/

    – Joshua

  • Hunter

    November 5, 2009 at 3:33 pm Reply

    I have signed up for the IPP and definitely think it’s great. However we use QB to manage several aspects of clinical trials for biotechs. Each trial has customized components to it, so the “build once sell to many” concept of the IPP is a bit out of our (read “my”) development experience at the moment. At some point I’d like to build a product that could be sold on the marketplace and then adapted by the user for each trial. For now, though we can copy over apps and change what’s needed.

    Flex has been great for building really nice graphs using the QB data. Also, I built an interface for transferring certain records from other systems into QB.

    However, I like the idea of using PHP for getting the data in and out of QB for the Flex front end to use. It’s great that you made php wrapper for this. I will try it out today.


  • Joshua

    November 5, 2009 at 3:39 pm Reply

    Don’t forget also that there are other options besides Flex for graphs. There are some really nice PHP graphing libraries that will let you feed it an XML file of your data and will spit out a nice graph.

    This could be an alternative to Flex as well if the sandboxing issue is a pain.

    Feel free to ping me on google talk if you ever have any other questions: goodespeler@gmail.com

    – Joshua

  • Len

    February 25, 2010 at 12:01 pm Reply


    I have been using the QB Perl SDK for some time, but now must venture down the PHP path. The below is returning an invalid request, and I am not sure why. My test is to return all the records from a table. It appears that authentication is succeeding, and that the token is behaving correctly. What am I missing? Thanks much!

    $quickbase = new QuickBase(‘$username’, ‘$password’, true, ‘$dbid’, ‘$QBToken’);
    $queries = array(
    ‘fid’ => ‘0’,
    ‘ev’ => ‘ct’,
    ‘cri’ => ”)
    $results = $quickbase->do_query($queries, ”, ”, ”);


  • Nicolas

    March 1, 2010 at 4:46 pm Reply


    I just want to know if there is a possibility to update the password in QuickBase via API ?

    Thanks for your answers.


    • Joshua

      March 1, 2010 at 5:08 pm Reply

      Unfortunately, no – you cannot update a users password via the api.

  • Rico

    March 6, 2010 at 10:28 pm Reply

    Hi Joshua,

    Good work on this API.

    Do you have a sample code using the public function add_record but with uploads? (i am using $usexml = true;)
    What kind of variable is $upload?
    How do upload the file?

    $response = $qb->add_record ($fields, $uploads);


  • Jennifer Strahan

    March 8, 2010 at 2:54 pm Reply


    I have an application where I parse the Quickbase results and display them on a search results page. In some cases the quickbase query returns so many records that I’m getting a memory error in PHP. I’d like to set up the results page so that I display a limited number of results and include links at the bottom so user can click to load the next set. I read about options skp-n and num-n but I haven’t had any luck figuring out how to specify those options in the do_query function. I tried the following with no luck:
    $results = $quickbase->do_query($queries, ”, ”, ‘’, ”, ”,’num-500′);

    Any suggestions on how I can add the options?


  • Tim

    March 31, 2010 at 1:17 pm Reply

    Hi Joshua,

    Thanks for this! I was able to create a small front-end web form for QuickBase data entry using the concepts above. I just didn’t get how to use the PHP wrapper until I saw your examples. I was also able to satisfy those people in our group who said “the form is so ugly – I can’t stand it” 🙂

    Thanks again!

  • Jon

    June 9, 2010 at 12:09 pm Reply

    It seems like maybe Quickbase has updated their API and this wrapper is out of date? For instance, I tried doing a simple $quickbase->get_schema and got an error 24 (“no app token”). If you go to the docs page you link to, they point you to new docs. Those docs say you must include an app token AND ticket on most API calls.

    Changing line 884 to:
    $url_string = $this->qb_ssl . $this->db_id. “?act=API_GetSchema&ticket=”. $this->ticket . “&apptoken=” . $this->app_token;

    And also adding this line to the XML version of the call:

    seemed to fix the problem.

  • Wilfredo

    July 6, 2010 at 7:42 pm Reply

    Hi Joshua:

    First of all, thank you for creating this QuickBase wrapper. I’ve been using it to add and search records and all works great.

    Today I need to update a record and I’m having difficulty achieving this task. I’m able to search & retrieve the record; but when I call the $quickbase->edit_record($fields); method I’m getting an error it doesn’t update the database.

    Where/How do I tell it which record to update?

    Thank you in advance for your help.

  • Steven The Nurse

    September 2, 2010 at 4:53 pm Reply

    Hey Josh, great work! i’m trying to get member sign up and quickbooks to go together. Please feel free to call me…
    Steven (305)964-6398

  • Tim

    September 10, 2010 at 6:27 pm Reply

    I added some code to my wrapper to use the API_UserRoles api call. I needed to simulate a user dropdown box – perhaps someone will find this useful.

    QB Wrapper Code Addition:

    public function user_roles() {
    if($this->xml) {
    $xml_packet = new SimpleXMLElement(”);
    if ($this->app_token)
    $xml_packet->addChild(‘apptoken’, $this->app_token);
    $xml_packet = $xml_packet->asXML();
    $response = $this->transmit($xml_packet, ‘API_UserRoles’);

    if($response) {
    return $response;
    return false;

    In my main php file, I use this to call the new function:
    $results = $quickbase->user_roles();

    $results will contain an array of all of the users in the database.

  • mandm

    September 24, 2010 at 1:58 pm Reply

    Hi Joshua, thanks for the nice wrapper, i wanted to know if you have some examples for the images uploads, that would be a great help. I have been trying it for a while now, but even though i get success on the upload, but the image does not show up in qb database. can you please post some examples of it?

    • Joshua McGinnis

      September 24, 2010 at 2:08 pm Reply

      This is what the XML in your request should look like:
      Here’s what the XML of the request should look like:

      POST https://quickbase.com/db/6mpjiez8?
      Content-Type: application/xml

      OK Corral


      Here’s a PHP example:

      // any file upload?
      if($_FILES[‘_fid_21’][‘name’]) {
      $file_name = $_FILES[‘_fid_21’][‘name’];
      $f_tmp_name = $_FILES[‘_fid_21’][‘tmp_name’];
      $file_size = $_FILES[‘_fid_21’][‘size’];

      $fh = fopen($f_tmp_name, ‘r’);
      $content = fread($fh, $file_size);
      $content = base64_encode($content);

      $uploads = array( array(‘fid’ => ’21’,
      ‘filename’ => $file_name,
      ‘value’ => $content) );

      // add activity record
      $quickbase = new QuickBase($username,$password,true, $dbID);
      if ($quickbase) {
      $payload = array(array(
      ‘fid’ => some_field_id,
      ‘value’ => some_val),
      ‘fid’ => some_field_id,
      ‘value’ => some_val)

      $resp = $quickbase->add_record($payload, $uploads);

  • Mike

    October 16, 2010 at 5:28 pm Reply

    Josh, In the $queries array can I add an slist parameter? Or how can I sort the query results? Thanks!

  • Chuck

    December 7, 2010 at 11:57 pm Reply

    Gen_results_table is working but do_query is not. Can you please throw out a few things I need to double-check? DBID is correct and I’m connecting cause gen_results_table displays fine. I get no xml response with do_query.

  • Will

    February 17, 2011 at 6:37 pm Reply

    Hi Josh, great work.

    Are you aware of any work been done to integrate WordPress and Quickbase?


    • Joshua McGinnis

      February 17, 2011 at 6:41 pm Reply

      Hi Wilfredo,

      I could building something pretty easily that would allow WordPress / QuickBase Integration.

      What in particular would you want the plugin to do?

      – Joshua

  • Tim

    March 8, 2011 at 4:26 pm Reply

    Can you post an example of how to use the import_from_csv function? I can’t seem to get it to work. Thanks! Keep up the great work!

    • Tim

      May 6, 2011 at 2:25 pm Reply

      It turned out that something was misspelled in the PHP wrapper code. I’m sorry I don’t exactly recall what it was right now…For those of you that use this function call, be sure to double-check the api call spellings, etc.

  • Mery

    May 12, 2011 at 10:39 pm Reply

    for the do_query example, can you give an example where i use AND for the criteria?

    let’s say where user is ‘eve’ AND ‘role is ‘manager’

    • Will

      October 24, 2011 at 2:42 pm Reply

      Hi Mery, I ran into the same issue. I was reading the framework and you can add a fourth element to the second or subsequent queries to add AND/OR…

      $queries = array(
      ‘fid’ => ’16’,
      ‘ev’ => ‘ex’,
      ‘cri’ => ‘eve’)
      ‘fid’ => ’19’,
      ‘ev’ => ‘ex’,
      ‘cri’ => ‘manager’,
      ‘ao’ => ‘AND’

  • Sagar

    June 10, 2011 at 1:31 pm Reply

    Hi Joshua,

    Can u please give us an example to fetch data from multiple tables in quickbase.


  • Alex Pagan-Ortiz

    November 3, 2011 at 1:16 pm Reply

    Hi Joshua,

    For the do_query example, I need to retrieve a field from a record based on a criteria.

    Something like “Select accountNo from Transaction where billingNo = some value

    I have he following code but is not showing any output…

    $line = fgetcsv($fp);

    $ArhBillingNumber = $line[1];

    $query= array(
    array(‘fid’ => ’10’,
    ‘ev’ => ‘ex’,
    ‘cri’ => $ArhBillingNumber));

    $results = quickbase->do_query($query,”,”,’11’);

    echo $results.”;

    Please Advise,


    • Joshua McGinnis

      November 3, 2011 at 2:29 pm Reply

      Hi Alex – you can’t just echo $results since the result will be a SimpleXML Object. Try var_dump($results); instead and see if it contains any data.

  • Alex Pagan-Ortiz

    November 10, 2011 at 1:40 pm Reply

    Hi Joshua,

    I am evaluating a PHP editor called NuSphere 6.1 and I am running some php scripts with this product and I am getting the following error from the QuickBase api class.

    Fatal error: Call to undefined function curl_init() in Z:\APO\qb-arh-php-works\QuickBaseClient.php on line 127

    However, when I run the same scripts from the browser it runs fine without showing the error.

    Do you know where is the curl-init method located? Any advise,

    thank you,


    • Joshua McGinnis

      November 10, 2011 at 1:42 pm Reply

      Hi Alex,

      I would run a phpinfo() from within the same environment and make sure curl is enabled.

      The curl-init method is located at the top of the QuickBase SDK class.

      – Joshua

  • Zied Ellouze

    March 9, 2012 at 4:14 pm Reply

    I use the php api for QuickBase
    and I look how I can make a request for selection according to multiple criteria
    as this example
    where field1=”x” and (field2=”y” or field3=”z”)
    thank you

    • Alex Pagan-Ortiz

      April 20, 2012 at 5:33 pm Reply

      $query = array(
      “fid” => $fieldfid,
      “ev” => “EX”,
      “cri” => value
      “ao” => ‘AND’,
      “fid” => $field2_fid,
      “ev” => “EX”,
      “cri” => value
      “ao” =>’AND’,
      “fid” => $field3_fid,
      “ev” => “EX”,
      “cri” => value
      $results = $qbconnect->do_query($query,”,”,;

  • Alex Pagan-Ortiz

    April 20, 2012 at 5:28 pm Reply

    Hi Johsua,
    I wrote a php script where I run queries that retrieve a single record from quickbase. Like,
    $qbconnect = new QuickBase(username,password,true,$QB_Table);
    $queries = array(
    “fid” => $QB_Table_field_fid,
    “ev” => “EX”,
    “cri” => $value )
    $results = $qbconnect->do_query($queries,”,”,$QBfieldvalue1.’.’. $QBFieldValue2.’.’.$QBFieldValue3.’.’.$QBFieldValue4.’.’.$QBFieldValue5);
    if( $results ){
    $record = $results->table->records->record->f;
    If( count($record) > 0){
    $field1 = $record[ 0 ];
    $field2 = $record[ 1 ];
    $field3 = $record[ 2 ];
    $field4 = $record[ 3 ];
    $field5 = $record[ 4 ];
    $return = array( $field1, $field2, $field3, $field4, $field5 );

    But now I need to modify the query to retrieve multiple records, the instructions to parse a single record to access every single field value is like,
    $record = $results->table->records->record->f;
    Then I access every element of the array with an index.
    Do you know or have an example that allows me to retrieve and access every field value from multiple records retrieved from quickbase?
    Thank you,

    • Joshua McGinnis

      April 20, 2012 at 5:59 pm Reply

      Hi Alex – I’m about to leave for vacation, but email me and I will help you when I return: joshua@mcginn.is

  • Mike Davis

    April 23, 2012 at 7:16 pm Reply


    Thank you – this page is still paying dividends.

    There is a bug(?) in the QuickBase API that your do_query code above uncovers. It turns out using EX vs. ex in a query yields different results. What we demonstrated repeatedly is that EX is an exact match whereas ex acts like CT.

    We demonstrated this by making direct calls via url to API_DoQuery so neither your sample nor quickbase.php code is at issue.
    Hope it helps anyone else encountering this problem.,


  • Alex Pagan-Ortiz

    June 6, 2012 at 1:22 pm Reply

    Hi Joshua,

    I running a bunch of php script that retrieve information from quickbase and recently I am getting the following error,

    Notice: Trying to get property of non-object in /var/www/production/QB-VWI-Library.php on line 694

    The error occurs every time execute the following instruction:

    $record = $results->table->records->record->f;

    Before this line of code there is a query that sent the result set to the variable $results.

    Thank you for your time,


    • Alex Pagan-Ortiz

      June 6, 2012 at 2:06 pm Reply

      Hi Joshua,
      Yes, the variable exist, those script have been running for months and the code have not been change, they just crashed from production. It must be an internal quickbase error.


  • Wally

    November 15, 2012 at 8:01 pm Reply

    Hi Joshua. edit_record requires the record id as the first parameter.

  • jim

    December 21, 2012 at 2:51 am Reply

    Hi Josh,
    Can you update the connection code for the “new” quickbase?
    $quickbase = new QuickBase(‘username’,’password’, true, ‘dbID’);
    on this page quickbase.com/user-assistance/resolve_scripting_issues.html
    it says to change
    QuickBase(username, pwd) to QuickBase(username, pwd, true, “”, “”, “”, “”)
    The complete call is: QuickBase (uname, pwd, usexml, db, apptoken, realm, hours). The account URL is passed via the realm parameter.

    is the URL passed thru the realm(6th) or hours(7th) parameter?

    Looks like I’m getting a connection error.
    Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in /quickbase.php:129 Stack trace: #0
    quickbase.php(129): SimpleXMLElement->__construct(”) #1 quickbase.php(152): QuickBase->transmit(‘authenticate() #3

    thanks jim

  • Sagar

    April 22, 2013 at 11:44 am Reply

    Hi Johsua,

    Since the latest upgrade in quickbase software, we are not able to retrieve the data from quickbase (We are using Quick Base PHP Api). Getting the following error. Can you please help us to fix the issue.

    Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in D:\app\controllers\quickbase.php:127 Stack trace: #0 D:\app\controllers\quickbase.php(127): SimpleXMLElement->__construct(”) #1 D:\app\controllers\quickbase.php(465): QuickBase->transmit(‘…’, ‘API_DoQuery’) #2 D:\app\controllers\my_quick_base_controller.php(24): QuickBase->do_query(Array, ”, ”, ”) #3 [internal function]: MyQuickBaseController->index(‘EMP’) #4 {main} thrown in D:\app\controllers\quickbase.php on line 127

    Thank You,

  • Mahe

    March 10, 2015 at 12:23 pm Reply

    Hi Joshua ,

    I have some trouble to retrieve table records from quickbase. I am using php how can i retrieve records from table.



  • Cristiam

    February 25, 2016 at 6:27 pm Reply

    Hi Joshua,

    I have a problem, I made a little form to add data to QuickBase but sometimes that data records and there are other times does not.
    Any idea why is that?


  • Stevens

    January 5, 2017 at 10:44 am Reply

    Below error showing when try to inser record from php server to quikbase

    how to fix.???
    Fatal error: Uncaught Exception: String could not be parsed as XML in C:\xampp\htdocs\hashmi\qb_drag\quickbase.php:107
    Stack trace:
    #0 C:\xampp\htdocs\hashmi\qb_drag\quickbase.php(107): SimpleXMLElement->__construct(”)
    #1 C:\xampp\htdocs\hashmi\qb_drag\quickbase.php(210): QuickBase->transmit(‘<?xml version="…’, ‘API_AddRecord’)
    #2 C:\xampp\htdocs\hashmi\qb_drag\upload.php(50): QuickBase->add_record(Array)
    #3 {main}
    thrown in C:\xampp\htdocs\hashmi\qb_drag\quickbase.php on line 107

    • Josh McGinnis

      January 5, 2017 at 5:06 pm Reply

      Hi Hashmi,

      To debug this issue, you need to echo the raw input string that is being converted to XML in the SDK. Around line 94, you should see:

      $this->input = $input;

      Just after this line, try:

      echo '<pre>'; var_dump($this->input); echo '</pre>';

      Take a look at the string and look for an element or tag that is missing, or some other error which might be causing the string to throw an exception when cast to a SimpleXML object.

  • hashmi

    January 18, 2017 at 8:57 am Reply

    How to add images/documents to quick base table as a record through php.?

  • Stevens

    January 19, 2017 at 11:30 am Reply

    How can we pass table values and form values to other application on click a button?

  • Adrian Honner

    March 31, 2017 at 3:49 pm Reply


    I would like to take examples about create table ApI,create filed of table Api, duplex of name and phone number checking Api
    ( QuickBase PHP SDK) form Mr. Josh


Post a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.