The Printful API client wrapper makes life a bit easier when working with the API. This is an update from the original Python 2.7 client library that was provided here . The module requires an API key as input. The key can be generated in the store settings of your Printful account.
from printful import Printful
pf = Printful(key)
orders = pf.get('orders')
The Printful class extends the Requests library so data, param, json, etc. can be passed just as you would with requests.
address = {
'recipient': {
'country_code': 'US',
'state_code': 'CA'
},
'items': [
{'variant_id': 1, 'quantity': 1},
{'variant_id': 1118, 'quantity': 2}
]
}
pf.post('shipping/rates', json=address)
Or, retrieve only certain orders using offset
and limit
.
pf.get('orders', params={'offset': 5, 'limit':10})
is equivalent to:
pf.get('orders&offset=10&limit=5')