Skip to main content

A client library for the FreshBooks API

Project description

Refreshbooks provides a simple synchronous API for manipulating FreshBooks
invoices, clients, and other data::

from refreshbooks import api

c = api.OAuthClient(
'example.freshbooks.com',
'consumerkey',
'My Consumer Secret',
'An existing token',
'An existing token secret',
user_agent='Example/1.0'
)

response = c.invoice.create(
invoice=dict(
client_id='8',
lines=[
api.types.line(
name='Yard Work',
unit_cost='10',
quantity='4'
)
]
)
)

invoice_response = c.invoice.get(
invoice_id=response.invoice_id
)

print "New invoice created: #%s (id %s)" % (
invoice_response.invoice.number,
invoice_response.invoice.invoice_id
)

invoices_response = c.invoice.list()

print "There are %s pages of invoices." % (
invoices_response.invoices.attrib['pages'],
)

for invoice in invoices_response.invoices.invoice:
print "Invoice %s total: %s" % (
invoice.invoice_id,
invoice.amount
)

Consumer keys and secrets can be obtained from FreshBooks. This library
does not handle negotiating for an OAuth token+secret pair; see the
`oauth` module or the OAuth specification for details.

This library also supports the older token-based API authorization
scheme::

c = api.TokenClient(
'example.freshbooks.com',
'My API token',
user_agent='Example/1.0'
)

# ... as above ...

API methods return lxml.objectify.ObjectifiedDataElement trees, which
can be manipulated as Python objects with the same structure as the
underlying XML.

If you are having trouble accessing items as in:

items_response = c.items.list()
for item in items_response.items.item:
print item.item_id

Adjust your syntax to use dictionary item lookup:

items_response = c.items.list()
for item in items_response['items'].item:
print item.item_id

ObjectifiedDataElement provides a method named items which shadows the
items element in the response. Accessing items with dictionary lookup
syntax is the known work-around.

References:

- http://developers.freshbooks.com/ - The FreshBooks API
- http://developers.freshbooks.com/authentication-2/#OAuth - FreshBooks and OAuth

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

refreshbooks-1.6.tar.gz (12.4 kB view details)

Uploaded Source

Built Distributions

refreshbooks-1.6-py2.7.egg (14.4 kB view details)

Uploaded Egg

refreshbooks-1.6-py2.6.egg (14.4 kB view details)

Uploaded Egg

File details

Details for the file refreshbooks-1.6.tar.gz.

File metadata

  • Download URL: refreshbooks-1.6.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for refreshbooks-1.6.tar.gz
Algorithm Hash digest
SHA256 460bef4e871cd76a2c2f2639dd916002087ac4f62614a8fb23ee3fba4a2923e2
MD5 49549f6ef31c13f5900ca86ad271bfaf
BLAKE2b-256 a83392cbf31cf8d24fdfe9a7a382d3f1a45466d2641834f135eee3d5ce04683a

See more details on using hashes here.

File details

Details for the file refreshbooks-1.6-py2.7.egg.

File metadata

File hashes

Hashes for refreshbooks-1.6-py2.7.egg
Algorithm Hash digest
SHA256 3b5b9a0cd1ece9d4062b85932afd540db0d7c493cc640574aca44bed45cc3d2b
MD5 31c738bfe326cadfa7bb090ea72ef760
BLAKE2b-256 16838a2838765820a94c008e1c45448586f539a2c5d51c2649c7b3ca6d480509

See more details on using hashes here.

File details

Details for the file refreshbooks-1.6-py2.6.egg.

File metadata

File hashes

Hashes for refreshbooks-1.6-py2.6.egg
Algorithm Hash digest
SHA256 7b82a5a9fb25013d5af48331624bb2d82a880b24e8fd4f15da1aabfbaaabf878
MD5 fd9a44e085090a0ad1905c68d3eb03c0
BLAKE2b-256 75c08c4e855530ca9c6c0b7e996781e0ab63d9482c96d4c5799ef1e0b8361441

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page