Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A simple wrapper for making requests with the FreshBooks API
branch: master

Merge pull request #3 from lord-otori/master

Changed method type in documentation.
latest commit 90bfc0a115
@jboesch authored
Failed to load latest commit information.
lib Changed documentation to match real method param type
README.markdown fixing readme
example.php fixing lines


FreshBooksRequest PHP API

This class is meant to give you the ability to quickly access the FreshBooks API.


  • You need to know the method names and params when you're creating a new FreshBooksRequest instance. See all here
  • The XML tag parameters you see on the freshbooks API page are the ones you pass to $fb->post() (as an array)
  • Require the lib and setup with your credentials (domain and token)

$domain = 'your-subdomain'; //
$token = '1234567890'; // your api token found in your account
FreshBooksRequest::init($domain, $token);
  • Now let's say we want to list clients with an email of
 * Fetch all clients by a specific id
// Method name found on the freshbooks API
$fb = new FreshBooksRequest('client.list');
// Any arguments you want to pass it
    'email' => ''
// Make the request
    echo 'successful! the full response is in an array below';
    echo $fb->getError();
  • If you're creating a recurring profile with multiple line items, it might look something like this:
 * Create a recurring profile with multiple line items
$fb = new FreshBooksRequest('recurring.create');
    'recurring' => array(
        'client_id' => 41,
        'lines' => array(
            'line' => array(
                    'name' => 'A prod name',
                    'description' => 'The description',
                    'unit_cost' => 10,
                    'quantity' => 2
                    'name' => 'Another prod name',
                    'description' => 'The other description',
                    'unit_cost' => 20,
                    'quantity' => 1
// You can view what the XML looks like that we're about to send over the wire
    $res = $fb->getResponse();
    $recurrng_id = $res['recurring_id'];
    // Do something with the recurring_id you were returned

Change Log

Changes in 1.0 (Sept 18, 2011)

  • Launched!
Something went wrong with that request. Please try again.