Sexy Infusionsoft XML-RPC API client
Project description
A simple-to-use Infusionsoft XML-RPC API client, with included stubs for code sense. Python 3.5+ only (but pull requests welcome :smirk:).
Installation
pip install infusionsoft-client
Quickstart
First, initialize the client with your app name and API key:
import infusionsoft
infusionsoft.initialize('myapp', '098f6bcd4621d373cade4e832627b4f6')
And use the infusionsoft like a regular xmlrpc.client.ServerProxy:
import infusionsoft
contact_id = infusionsoft.ContactService.add({'FirstName': 'Johnny'})
Usage with Django
infusionsoft-client includes a Django integration out of the box. Just add it to your INSTALLED_APPS:
INSTALLED_APPS = (
# ...
'infusionsoft.contrib.django',
)
And add your app name and API key to your settings:
INFUSIONSOFT_APP_NAME = 'myapp'
INFUSIONSOFT_API_KEY = '098f6bcd4621d373cade4e832627b4f6'
Getting All Rows of a Query
Some API calls are paginated, and require multiple calls to retrieve all results. This can be a pain, and you may find yourself writing the same code over and over. To this end, infusionsoft-client provides a consume() generator function, which will consume all pages of any query function.
To use it, create a lambda (or regular) function taking page and limit as arguments which performs your paginated API call, and pass it to consume():
import infusionsoft
from infusionsoft.query import consume
query_fn = lambda page, limit: (
infusionsoft.DataService.query('mytable', limit, page, ['Id']))
# Use with a for-loop, to avoid storing all rows in memory:
for row in consume(query_fn):
do_stuff(row)
# Or retrieve all rows at once
all_rows = list(consume(query_fn))
Generate Code Stubs
Shipped with infusionsoft-client is code to download the official Infusionsoft XML-RPC docs, parse them with BeautifulSoup, and generate Python 3.5-compatible stubs for all methods.
To generate these yourself, first install the extra requirements:
pip install -r stub-requirements.txt
Then run the generate_stubs() function, which will return a string:
from infusionsoft.gen_stubs import generate_stubs
source = generate_stubs()
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
Hashes for infusionsoft-client-1.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac76fc0fd700f0577cbf45c66a86c81e1cddd5850f142f7a9da269499c2fba9f |
|
MD5 | 9916cd616dc3451a6f39ef3ae25a699e |
|
BLAKE2b-256 | 6018bc505f3005db5f544ce66dcc7cb1400aa54f71fbef7a31fd4b863d199514 |