python with Quickbooks Online API v3 -


i need implementing python app accesses quickbooks api. have written several apps use apis, once oauth world, bit lost.

at rate, found quickbooks-python wrapper here: https://github.com/troolee/quickbooks-python

but there 0 examples of working code showing how implement properly. imagine more experienced python programmer figure out how make work without instructions, seems i'm missing basics.

if connected, work there...

it seems documentation on github jumps around , more experienced programmer, make perfect sense. i'm not following...

from quickbooks import *  consumerkey =           "fromapiconsole" consumersecret =        "fromapiconsole" callbackurl =           "https://quickbooks.api.intuit.com/v3"  qbobject = quickbooks(         consumer_key = consumerkey,         consumer_secret = consumersecret,         callback_url = callbackurl         )  authorize_url = qbobject.get_authorize_url() # create service, , further set qbobject.  oauth_token = request.get['oauth_token'] oauth_verifier = request.get['oauth_verifier'] realm_id = request.get['realmid']  session = qbobject.get_access_tokens(oauth_verifier)  # want access reports  reporttype = "profitandloss"  url = "https://quickbooks.api.intuit.com/v3/company/asdfasdfas/" url += "reports/%s" % reporttype  r = session.request( #this rauth request     "post",     url,     header_auth = true,     realm = realm_id,     params={"format":"json"}     )  qb = quickbooks(     consumer_key = consumerkey,     consumer_secret = consumersecret,     access_token = qbtoken.access_token, # stored token     access_token_secret = qbtoken.access_token_secret, # stored secret     company_id = qbtoken.realm_id #the stored realm_id     )  qbtext = str(qb.query_objects(business_object, params, query_tail))  print qbtext 

i pretty sure am:

  1. importing wrong modules/classes
  2. missing huge pieces of code "glue together" samples found on github
  3. not using django here , know request class above in django, i'd make work python script without using django
  4. not getting token/identifier/realmid initial authorize_url function. prints on screen, i'm not sure how grab it...

the end goal here connect , p&l statement quickbooks online. if can far, sure can rest of need out of api. don't need change anything, i'm looking include data reports dashboards.

* update *

okay, figured out how connect, i'm not sure how reports.

the answer this, on prior api page:

accessing api once you've gotten hold of quickbooks access tokens, can create qb object:  qb = quickbooks(consumer_key = qb_oauth_consumer_key,          consumer_secret = qb_oauth_consumer_secret,         access_token = qb_access_token,          access_token_secret = qb_access_token_secret,         company_id = qb_realm_id         ) 

still trying basic reports...

okay, here's how make work. i'm focused on reports, here's how can reports quickbooks online api using python:

1) go https://github.com/finoptimal-dev/quickbooks-python , download code

2) make sure have rauth installed. if on aws/ec2, simply:

sudo yum install rauth 

3) edit quickbooks2.py file , add following end:

qb = quickbooks(consumer_key = qb_oauth_consumer_key,          consumer_secret = qb_oauth_consumer_secret,         access_token = qb_access_token,          access_token_secret = qb_access_token_secret,         company_id = qb_realm_id         ) 

4) setup sandbox application on quickbooks site here: https://developer.intuit.com/v2/ui#/app/startcreate (you have create developer account if don't have one)

5) once setup, can go "keys" tab of app , grab app token, oauth consumer key , oauth consumer secret.

6) go intuit developer playground @ https://appcenter.intuit.com/playground/oauth/ia , use info step #5 obtain access token , access token secret.

7) change variables in step #3 correct values. qb_realm_id, company id. can in sandbox logging https://developer.intuit.com/v2/ui#/sandbox , looking company id.

7) add following code below code step #3 above

print qb.get_report('profitandloss','summarize_column_by=month&start_date=2014-01-01&end_date=2014-12-31') 

i use above dates b/c quickbooks sandbox company has no income/expense data in 2015, have pick dates in 2014.

8) important: use quickbooks sandbox reporting purposes, need change get_report() function use base_url_v3 instead of being hard-coded production url.

look row in get_report() function looks this:

url = "https://quickbooks.api.intuit.com/v3/company/%s/" % \ 

and change this:

url = self.base_url_v3 + "/company/%s/" % \ 

9) can change base_url_v3 way @ top this:

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

10) , should able run:

python quickbooks2.py 

you should see bunch of json data quickbooks sandbox company.

11) can explore bit test out appropriate urls here: https://developer.intuit.com/apiexplorer?apiname=v3qbo#reports

12) report reference here: https://developer.intuit.com/docs/0100_accounting/0400_references/reports , shows parameters can use. test parameters in explorer, enter them in "request body" section.

i struggled while , figured out. hope helps else.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -