FreshBooks

Search


API Calls

Resources

Javascript library for FreshBooks API

by Sunir in Development on May 20, 2009

Props to Milan Rukavina who has created a Javascript library for FreshBooks, available under the Apache License, version 2.0. The library allows web applications to make calls to FreshBooks through Javascript. However, because Javascript is not permitted to make cross-domain requests, you will need to install a server-side proxy or a flash-based proxy. See the project page for details.

1 comments

Are you using Keep-Alive?

by Taavi in Development on January 30, 2009

Do you use the FreshBooks API? Do you make multiple requests in a session? Is it painful waiting for each and every request to complete?

If so, you have to ask if you’re getting the best performance out of the API. When one piece of work at your end may entail 3-4 API requests, the average speed of making requests can have a big impact on your own application’s performance.

Our web servers are set up to allow HTTP persistent connections which eliminates the delay of opening a new HTTP connection (and renegotiating SSL!) for each API request.

In our own testing, this can result in up to 50% time savings over the course of a multi-request interaction! For example, cURL in PHP automatically takes advantage of persistent connections, if you don’t force it to make a new connection each time:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_USERPWD, $token);
$request = get_first_request();
while ($request) {
  curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  $request = get_next_request($response = curl_exec($ch));
}
curl_close($ch);

Ben’s looking to update the FreshBooks Ruby wrapper to make use of persistent connections. Enjoy!

0 comments

Making Widgets with jQuery

by Taavi in Development on May 1, 2008

You may have noticed that we recently released the FreshBooks Time Tracker widget. What you may not have noticed beneath its shiny exterior, is this fantastic helper library called jQuery. Here are some excellent reasons for using it…

Portability

While the FreshBooks widget is currently only for OSX’s Dashboard, a lot of the HTML element access and glitzy fades are pure jQuery, and should be portable to other widget facilities, and the FreshBooks website itself. It’s also nice to be able to use the same skills in widget creation as webpage creation.

Power

The $() construct is much, much more powerful than it at first appears. Take a closer look at the full power of selectors to see what I mean. And the skills you learn are re-usable, since jQuery implements CSS3-style selectors. When browsers get around to fully supporting them, you’ll already be at home. In addition, jQuery also makes dealing with XML (as returned by the FreshBooks API) and Ajax in general a whole lot easier!

Conciseness

jQuery also leads to shorter, more concise JavaScript. $(”#submit”) is so much easier to type than document.getElementById(“submit”), and infinitely more flexible when you want to, say, operate on all of the images in a page with $(“img”). You “chain” together various jQuery commands, such as css() and show() simply by applying them to the returned “wrapped set”, like $(“img”).css(‘opacity’,0.5).

Peer Pressure

Apparently I’m not the only one who thought this would be a good idea. I just recently noticed an awesome SVN notifier widget which also includes jQuery. Perhaps the idea is catching on…

0 comments

« Older Posts   Newer Posts »