How do I connect to quickbooks online via python?

6.8k Views Asked by At

I'm trying to figure out how to authenticate and create an entry on quickbooks online through Python. Currently, when I try to click auth link in their API Explorer, I get 404 page.

What I'm trying to do is creating invoice through Python. However, it seems like their documentation is not complete. I contacted their support, and I haven't heard from them yet.

5

There are 5 best solutions below

0
On

This library will get the job done https://github.com/HaPsantran/quickbooks-python

It works in JSON so you would construct the Invoice based off of docs at https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/invoice using the JSON examples.

The library doesn't support sandbox mode** so if you are going to use the development consumer key and secret than you would change this code.

base_url_v3 =  "https://quickbooks.api.intuit.com/v3"

to

base_url_v3 =  "https://sandbox-quickbooks.api.intuit.com/v3"

while in that mode.

** Sandbox mode only applies currently to U.S. QBO

0
On

I had this same problem. I just figured it out and posed the step-by-step process here:

python with Quickbooks Online API v3

Hope this helps.

3
On

The python-quickbooks library is probably the correct choice now, as it is a "complete rework of quickbooks-python". It has pretty comprehensive instructions on getting and using the auth keys, though I wouldn't call it "simple", since the process is by definition somewhat complex. The instructions are "for Django", but the Django-specific code simply gets parameters out of a URL string.

We're using it to great effect, because the syntax is as easy as:

auth_client = AuthClient(
    client_id = CLIENT_ID # from QB website
    ,client_secret = CLIENT_SECRET # from QB website
    ,environment = 'sandbox' # or 'production'
    ,redirect_uri = REDIRECT_URI
)

client = QuickBooks(
    auth_client = auth_client
    ,refresh_token = REFRESH_TOKEN
    ,company_id = COMPANY_ID
)

account = Account.get(qbid, qb=client) # qbid can be retrieved from the AccountList
return account.CurrentBalance
0
On

Having written a lot of the module @Minimul mentions — with a very helpful start by simonv3, who figured out how to get it working first and then I just built on it — I am fairly confident that this will not support the oauth workflow of getting the request token, prompting the user to authenticate out of band, and then getting and storing the access token. It presumes you already have an access token.

Simon (or another Python developer) may be able to comment on how he gets the access token with Python, and if so, it'd be great if he (or they) could add it to the module for all to enjoy.

0
On

I looked at the existing python clients for quickbooks and found them to be either outdated or not having all the features. So i created a new python client for quickbooks which can be found at https://pypi.python.org/pypi/quickbooks-py