• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Saving Time And Effort With QuickBase Api - Sergio Haro

  • 7,273 views
Uploaded on

Ever wish you could enter pages of data into QuickBase without lifting a finger? How about aggregating data from an external source but you don't want to set up your own SQL server and build your own …

Ever wish you could enter pages of data into QuickBase without lifting a finger? How about aggregating data from an external source but you don't want to set up your own SQL server and build your own reporting tools? Learn to rise above the native QuickBase interface and explore the vast and powerful capabilities QuickBase provides through its API's. It's time to get started with the QuickBase API and build your first tool/script/app.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
7,273
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
94
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • So how does this help you?The QuickBase API is a powerful interface giving you programmatic access to record data and application schemas.With the API, you can integrate QuickBase with the rest of your business process by pushing or pulling data to QuickBase from your other solutions.With the API, you can provide you own custom Business Logic, by pulling the necessary data from QuickBase and running you logic on that data set.With the API, you can even create your own custom UI to simplify or expand the native QuickBase interface.
  • To get jump started with our API, try using one of the many SDK’s we provide on code.intuit.comWe have a support for a variety of different languages, with an almost indentical feature set in each one. It all depends on your language preference. And if you don’t see something you like, with the information in this session you’ll be able to write your own library in a breeze.If you want more details on either our Javascript or Ruby SDK, stay tuned for some of our upcoming presentations which will go more in depth into those particular languages.
  • So how does the QuickBase API work?Fundamentally, it’s a simple pseudo-REST HTTP API. You simply make an HTTP request to QuickBase and QuickBase will return an answer as XML.Before we go farther, lets remind ourselves what an http request is. HTTP requests happen all the time. Its what your web browser does when you type a url into it. And it consists of 3 basic parts.
  • It all starts with a URL. This is basically tells us where the request should go
  • The second part of the HTTP request is the Headers. These are basically meta-data about the request. The example on the screen is a request I got using Firebug when my web browser requested a page from QuickBase.
  • Finally, an HTTP request might also have a body. Inside the body, you put any data that you want to send to the server.The body is only sent when you perform an HTTP POST, as opposed to an HTTP GET. This is called POSTing data to the server. In your web browser, this happens whenever you submit a form. Your web browser creates an HTTP request, automatically takes the data that you entered, and sets the body of the http request to be that data.
  • The first component is the scope. The scope of the api call basically tells us what object you want to call with the API.
  • QuickBase can use all 3 of these pieces to form an API call.Each API call will also be made up of 3 basic components. Don’t worry, I’ll explain each one.
  • In QuickBase, we have 3 basic objects you can make an API call on.The main object is a place holder for any API’s that doesn’t use a particular application or table.In an API call, You tell us the object by putting it in the URL as shown.
  • The second part of any API call is the name of the action you want to take. Or in programming speak, these is the name function that should be execute with your request.You can pass us the name of the action in any part of the HTTP request.
  • If you want to tell us the action in the header, just add a new header called Quickbase-Action.If you want to tell us the action in the URL, add a new key-value pair into the query string of the URL (basically anything after a question mark in a URL.)I won’t go into detail about the Body because the recommended way is to put the action in the URL.
  • The last part of an API call is the parameters or arguments that are needed for the particular action you want to take. Again there are multiple ways to do this. You can provide the parameters as form-urlencoded or as xml. And you can even inter-mix the different methods.
  • So to explain this more concretely, lets take an actual example. We’ll use API_FindDBByName. This api is pretty simple, basically, you pass in the name of an application or table and QuickBase will return the ID of that application/table if it exists.It takes 3 parameters (dbname, ticket, and apptoken). The ticket and apptoken are actually required by the majority of API’s. The ticket tells us what user to run the request as. An the apptoken is a special random string you can add to your applications to protect it from people calling API’s on it without your consent. The ticket parameter in the request is the authentication ticket. QuickBase uses this ticket to verify the caller’s identity and authority to perform the requested operation. A valid ticket will be returned when a valid user name/password is passed into any function. In particular the function API_Authenticate may be used to get a valid ticket. Only the function API_Authenticate will return a cookie with the ticket. All other API functions will only return the ticket as part of the XML response.The ticket is necessary if you are calling on behalf of a user. If you want to make a call without a ticket, you need to make sure your app is open to everyone on the internet.An apptoken can be added to each of your apps for added security. (Thus a api call would require both a ticket (specific to User) and an apptoken (specific to App).
  • If you decide on the XML route, the format is pretty simple. The root tag should always be qdbapi. The child tags will then be names of the parameters. So your xml will always be in one layer. Always make sure to XML encode your values or you might see strange things.
  • So to Solidify the example, this is what our http request will finally look like with XML data.
  • The second way of passing parameters to quickbase is using form-urlencoding. This is how your browser submits forms. Basically, it’s a long string where you write the parameter names “equals” the value. Each pair is separated by the & sign. If you use this method make sure to url encode the values you pass in or you might see some funky behavior.
  • Again, here’s an http request using form encoding
  • Now, if you take the body of the previous request and paste it to the end of the url, you’ll achieve the very same thing. For quick tests or debugging this is great. However, be forewarned that this can be a security hole because people in the network will be able to see your data.This is why we recommend putting the data in the http request body, once you’re ready to deploy your code.
  • So now that you’ve sent the request, what are you going to get back.Some of the API calls return HTML, or JSON. But XML is the primary format for the QuickBase API. And it looks very similar to the XML you send to us. Again the root tag is “qdbapi”.Inside of the root, you’ll find a variety of tags depending on the action. You will always get back the action, errcode, and errtext. The rest depends on the specific API you are calling. If your api was successful, the errcode will be 0. However if something went wrong you’ll see a number other than zero. Inside of the errtext you might find useful information detailing what the problem was. For API_FindDBByName, we are interested in the dbid tag.
  • So if we want to step into some real code now. I’ll share with you one of the recent pieces of code I wrote that used the QuickBase API.So in the QuickBase PD team, as we were developing a certain new feature, we had to find a way to measure the performance benefit of introducing this feature. However, with the complexity of the codebase, we did not want to spend a lot of time instrumenting the code. What we discovered was that our web server logs actually contained pretty much every measurement we were interested in. In this case it was the request time, load balancer time, app server time, and the time spent in queues. Unfortunately, one of our simulation runs could take a very long time. Too long to stick around to input the data by hand.So I went ahead a built a script in C# that took the server logs and parsed them (extracting the necessary information). Once I had the data, I would upload the data to QuickBase. What this allowed us to do is leave our simulations running over night, and the next day I could log into QuickBase and look at all the results.
  • My script has the same core as what I suspect most of your scripts will do. I took some input, parsed it to get the necessary information, ran some computations, and then returned the result. However, instead of doing a printf, I uploaded the data into QuickBase where I could run all sorts of fancy graphs and reportsThe portion of the code dealing with QuickBase was structured very similarly to how I outlined an http request earlier. Oh, and for the size of the script, I didn’t find the need to download and set up the C# SDK. Instead I just wrote my own http requests.
  • So the code here is broken up into 4 sections. The first part of the code calls a helper function to build the xml body.
  • You can see that code on this page. Unfortunately, C# has some monolothic methods for manipulating XML. Some of the newer languages can treat XML as a built in type. But anyways, the format is quite simple. The first step creates the root node. I then go and create all the children with their specified tag names and set their value. Finally, I convert my xml document into a string.
  • Now if we go back to the main function. The next step is to create the HTTP request. This is where you set the URL.
  • Then I set all the HTTP headers
  • Finally, I set the body of the request. Unfortunately, C# requires me to convert the string to bytes which is why it looks so nasty.But that’s basically it. Its quite simple really, The only real work is in putting together the data that we’ll send to quickbase. The actual http request and all the heavy lifting is usually taken care of by the standard libraries of the language you choose.
  • So these urls are some links to our API documentation. Don’t worry about copying them down. This presentation should be posted online for you all to download freely. Make sure to stay tuned for the following presentations to see some more in-depth examples that use the QuickBase API.

Transcript

  • 1. Saving Time and Effort with the QuickBase API
    Sergio Haro
  • 2. How does this help you?
    Integration
    Export/Import data from external sources (SQL / MS Access)
    Automate data entry
    Mash-ups (Add QuickBase data to other websites)
    See upcoming presentations ‘Connecting QuickBase with Databases’ and ‘Website Integration with QuickBase ‘
    Custom Business Logic
    Pull data to perform custom logic
    Insert calculated data back
    Custom UI
    Build your own app or website with QuickBase as your backing store
    Bypass the native UI to simplify or expand its capabilities
  • 3. Jump-Start with SDK @ code.intuit.com
    Browser-Based
    JavaScript
    Good for db-pages (beware of cross-domain policy if using on external websites)
    http://intuitlabs.com/apps/yql-and-intuit-quickbase (Getting around cross-domain)
    See upcoming sessions ‘Magic Buttons’ and ‘Building a QuickBase Mobile Application’
    Scripting Languages
    Ruby
    http://www.ruby-lang.org
    Object-oriented scripting language
    Write scripts in your favorite text editor
    See upcoming session ‘Integrating with QuickBase Web Services’
    VB
    http://msdn.microsoft.com/en-us/vbasic/
    Build VB scripts in Visual Studio (Windows only)
    Perl
    http://www.perl.org/
    Write scripts in your favorite text editor
    General Programming Languages
    C#
    http://msdn.microsoft.com/en-us/vcsharp/
    Build C#apps in Visual Studio (Windows only)
    Java
    http://java.sun.com/
    Build Java apps with your favorite IDE (Eclipse, NetBeans, etc)
  • 4. How does it work?
    HTTP (GET or POST)
    You
    QuickBase
    XML
  • 5. HTTP Request
    URL
    POST http://www.quickbase.com/db/main
  • 6. HTTP Request
    URL
    POST http://www.quickbase.com/db/main
    Headers
    Host: www.quickbase.com
    User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: UTF-8,*
    Keep-Alive: 300
    Connection: keep-alive
  • 7. HTTP Request
    URL
    POST http://www.quickbase.com/db/main
    Headers
    Host: www.quickbase.com
    User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: UTF-8,*
    Keep-Alive: 300
    Connection: keep-alive
    Body
    foobar=true&type=unknown
  • 8. Components of an API Call
    Scope
    Set in the URL
    Dependent on Action
  • 9. Components of an API Call
    Scope
    Action to perform
    Parameters for action
  • 10. Scope
    Main
    https://www.quickbase.com/db/main
    App
    https://www.quickbase.com/db/{app_id}
    Table
    https://www.quickbase.com/db/{table_id}
  • 11. Components of an API Call
    Scope
    Action to perform
    • Set in the URL, Headers, or Body
  • Action
    Header
    QUICKBASE-ACTION: API_AddRecord
    URL
    Query string: “a=API_AddRecord”
    https://www.quickbase.com/db/b4ds?a=API_AddRecord
    Body
    <qdbapi>
    <action>API_AddRecord</action>
    </qdbapi>
  • 12. Components of an API Call
    Scope
    Action to perform
    Parameters for action
    • Set in the URL and/or Body
    • 13. Dependent on action
    • 14. Encoded as XML or Form
  • Parameters for Action (API_FindDBByName)
    Parameter: Value
    dbname: Test API
    ticket: kiedzc4rtab8gqdr6
    apptoken: asfkhlk35rnl4nn
  • 15. XML Parameters
    <qdbapi>
    <dbname>test API</dbname>
    <ticket>kiedzc4rtab8gqdr6</ticket>
    <apptoken>asfkhlk35rnl4nn<apptoken>
    </qdbapi>
  • 16. XML Parameters
    URL
    POST http://www.quickbase.com/db/main
    Headers
    Content-Type: application/xml
    Content-Length: 76
    QUICKBASE-ACTION: API_FindDBByName
    Body
    <qdbapi>
    <dbname>test API</dbname>
    <ticket>kiedzc4rtab8gqdr6</ticket>
    <apptoken>asfkhlk35rnl4nn<apptoken>
    </qdbapi>
  • 17. Form Parameters
    dbname=test%20API&ticket=kiedzc4rtab8gqdr6
    &apptoken=asfkhlk35rnl4nn
  • 18. Form Parameters
    URL
    POST http://www.quickbase.com/db/main
    Headers
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 76
    QUICKBASE-ACTION: API_FindDBByName
    Body
    dbname=test%20API&ticket=kiedzc4rtab8gqdr6&apptoken=asfkhlk35rnl4nn
  • 19. GET Request
    URL
    POST http://www.quickbase.com/db/main?a=API_FindDBByName&dbname=test%20API&ticket=kiedzc4rtab8gqdr6&apptoken=asfkhlk35rnl4nn
    Headers
    Content-Type: text/html
    Body
  • 20. What will I get back?
    <?xml version="1.0" ?>
    <qdbapi>
    <action>API_FindDBByName</action>
    <errcode>0</errcode>
    <errtext>No error</errtext>
    <dbid>57pa5vjf</dbid>
    <dbname>Test API</dbname>
    </qdbapi>
  • 21. Example
    09-15 02:49:58.550 I366aswux2 Process: Req: 0.013 [LB: 0.003 WS: 0.004 Q: 0.004] Bytes=[R: 0 W: 24957] Uid=56752832 OP=/db/main
    Date
    Time
    Request ID
    Logging Function
    Request Time
    Load Balancer time
    App Server time
    Queue time
    Bytes Read
    Bytes Written
    User ID
    URL
  • 22. Example
    Main Script Tasks:
    Get lines from input
    Parse lines
    Calculate Statistics
    Upload Statistics
  • 23. Example - Create Request
    string action;
    // Get POST data
    string data = addRecord(stats, out action);
    // Create HTTP Request
    string url = “http://www.quickbase.com/db/” + dbid;
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
    // Set HTTP Headers
    webRequest.Method = "POST";
    webRequest.ContentType = "application/xml";
    webRequest.Headers.Add("QUICKBASE-ACTION", action);
    // Write Body
    byte[] postBytes = Encoding.ASCII.GetBytes(data);
    webRequest.ContentLength = postBytes.Length;
    Stream postStream = webRequest.GetRequestStream();
    postStream.Write(postBytes, 0, postBytes.Length);
    postStream.Close();
  • 24. Example - Create Body
    // Create Root Document
    action = "API_AddRecord";
    XmlDocument doc = new XmlDocument();
    XmlElement root = doc.CreateElement("qdbapi");
    XmlElement child;
    // Add Field
    child = doc.CreateElement("field");
    child.SetAttribute("fid", "6");
    child.InnerText = stats.webServerAverage.ToString();
    root.AppendChild(child);

    // Add App token
    child = doc.CreateElement("apptoken");
    child.InnerText = "ye6wbdh59j7rbsf3txbd679ha7";
    root.AppendChild(child);
    doc.AppendChild(root);
    StringWriter sw = new StringWriter();
    XmlTextWriter tx = new XmlTextWriter(sw);
    doc.WriteTo(tx);
    return sw.ToString();
  • 25. Example - Create Request
    string action;
    // Get POST data
    string data = addRecord(stats, out action);
    // Create HTTP Request
    string url = “http://www.quickbase.com/db/” + dbid;
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
    // Set HTTP Headers
    webRequest.Method = "POST";
    webRequest.ContentType = "application/xml";
    webRequest.Headers.Add("QUICKBASE-ACTION", action);
    // Write Body
    byte[] postBytes = Encoding.ASCII.GetBytes(data);
    webRequest.ContentLength = postBytes.Length;
    Stream postStream = webRequest.GetRequestStream();
    postStream.Write(postBytes, 0, postBytes.Length);
    postStream.Close();
  • 26. Example - Create Request
    string action;
    // Get POST data
    string data = addRecord(stats, out action);
    // Create HTTP Request
    string url = “http://www.quickbase.com/db/” + dbid;
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
    // Set HTTP Headers
    webRequest.Method = "POST";
    webRequest.ContentType = "application/xml";
    webRequest.Headers.Add("QUICKBASE-ACTION", action);
    // Write Body
    byte[] postBytes = Encoding.ASCII.GetBytes(data);
    webRequest.ContentLength = postBytes.Length;
    Stream postStream = webRequest.GetRequestStream();
    postStream.Write(postBytes, 0, postBytes.Length);
    postStream.Close();
  • 27. Example - Create Request
    string action;
    // Get POST data
    string data = addRecord(stats, out action);
    // Create HTTP Request
    string url = “http://www.quickbase.com/db/” + dbid;
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
    // Set HTTP Headers
    webRequest.Method = "POST";
    webRequest.ContentType = "application/xml";
    webRequest.Headers.Add("QUICKBASE-ACTION", action);
    // Write Body
    byte[] postBytes = Encoding.ASCII.GetBytes(data);
    webRequest.ContentLength = postBytes.Length;
    Stream postStream = webRequest.GetRequestStream();
    postStream.Write(postBytes, 0, postBytes.Length);
    postStream.Close();
  • 28. Resources
    Developer Resources
    http://quickbase.intuit.com/developer/
    API Guide (old)
    https://www.quickbase.com/up/6mztyxu8/g/rc7/en/
  • 29. API’S YOU SHOULD KNOW
  • 30. API_Authenticate
    Parameters:
    username
    password
  • 31. API_AddRecord
    Parameters:
    Field (name=“Field Name” or fid=“14”)
    apptoken
    ticket
  • 32. API_EditRecord
    Parameters:
    rid
    Field (name=“Field Name” or fid=“14”)
    apptoken
    ticket
  • 33. API_DoQuery
    Parameters:
    query/qid/qname
    clist
    slist
    apptoken
    ticket