infusionsoft-client
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'})
Setting XML-RPC Client Options
Any extra kwargs passed to initialize() will be passed along to xmlrpc.client.ServerProxy.
import infusionsoft
infusionsoft.initialize('myapp', '098f6bcd4621d373cade4e832627b4f6', use_builtin_types=True)
Some kwargs of interest are:
use_builtin_types: whether to utilize native Python types, rather than wrappers such as xmlrpc.client.DateTime or xmlrpc.client.Binary. I recommend turning this on. It will be turned on by default in the next major/breaking release.
verbose: set to True to print out the request and response bodies for each RPC call.
allow_none: whether to allow None to be sent over the wire. Infusionsoft, in general, doesn’t allow None (which is nil in XML-RPC parlance). If a field in a response is null, Infusionsoft will simply not send it.
retries: number of times to retry failed requests. Requests are retried on connection/socket errors, and “InvalidConfig” faults (if you’ve never seen them, I envy you). Any other type of fault will still raise an exception.
See the docs for more info.
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'
Pass extra configuration to the XML-RPC client with INFUSIONSOFT_CLIENT_OPTIONS:
INFUSIONSOFT_CLIENT_OPTIONS = {
'use_builtin_types': True,
}
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()
Metadata
Release files for infusionsoft-client 1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| infusionsoft-client-1.5.1.tar.gz | 18.8 kB | Without provenance | Details for infusionsoft-client-1.5.1.tar.gz |
Release files / infusionsoft-client-1.5.1.tar.gz
| Download URL | infusionsoft-client-1.5.1.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e6e3ae7c350476edef59319b4cf314bab73db89d84cc216ecc887417deaf01e
|
|
BLAKE2b-256 checksum How to use checksums |
ccde5f47d703636dd8766c89de7292882ed9fe2fbfcfd53f6263b9e1ecba0fbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for infusionsoft-client 1.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.