A Python API client for the Neto (Maropost) Ecommerce platform.
- Python 3.7+
- Requests
pip install netoapi
import netoapi
api = netoapi.NetoAPIClient(
my_endpoint,
my_username,
my_apikey
)
payload = {
"Filter": {
"SKU": "LSD",
"OutputSelector": [
"Name",
"RRP"
]
}
}
response = api.execute_api_call("GetItem", payload)
print(response)
{
'Item': [
{'RRP': '150.00', 'InventoryID': '31673', 'Name': 'Luke Skywalker Doll', 'SKU': 'LSD'}
],
'CurrentTime': '2021-02-06 10:49:40',
'Ack': 'Success'
}
# Parameters:
action: str """Used in the 'NETOAPI_ACTION' request header"""
payload: dict """Converted to JSON as the request payload"""
# See NETO API documentation for more information on building
# JSON payloads and available 'NETOAPI_ACTION' headers
netoapi.errors.DependencyNotFoundError
netoapi.errors.NetoAPIRequestError
# Catch this error to avoid breaking execution
try:
api.execute_api_call(action, payload)
except NetoAPIRequestError as e:
# Handle the error
# The timeout property will always return a tuple (connection, response)
print(type(api.timeout))
<class 'tuple'>
# By default the timeout property is set to (5, 5)
# timeout can be set to an integer, a tuple or NoneType
# Set both timeouts to the same value with an integer
api.timeout = 10 # 10 seconds
# Set the timeouts individually with a tuple
api.timeout = (5, 10)
# Set the connection timeout to 5 and wait forever for a response
api.timeout = (5, None)
# Cancel all time limits on connections and requests
api.timeout = None
For more info see Neto API docs
Written by github.com/dan-hobday
- -> V1.0.1 - Current release
- -> V1.1.0 - Map API fields to classes. This will make building payloads easier, less error prone and add support for field constraints.