A Python3 API Client for the Neto (Maropost) Ecommerce platform
Project description
NetoAPI Library
A Python API client for the Neto (Maropost) Ecommerce platform.
Requirements:
- Python 3.7+
- Requests
To install:
pip install netoapi
Basic use:
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'
}
Method - NetoAPIClient.execute_api_call():
# 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
Custom exceptions:
Raised if netoapi is imported without the requests library installed:
netoapi.errors.DependencyNotFoundError
Raised if an error occurs during an API call:
netoapi.errors.NetoAPIRequestError
# Catch this error to avoid breaking execution
try:
api.execute_api_call(action, payload)
except NetoAPIRequestError as e:
# Handle the error
timeout:
Setting the connection and response timeout property
# 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
That's about all there is to it!
For more info see Neto API docs
Written by github.com/dan-hobday
Roadmap:
- -> 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
netoapi-1.0.1.tar.gz
(17.6 kB
view details)
Built Distribution
netoapi-1.0.1-py3-none-any.whl
(17.6 kB
view details)
File details
Details for the file netoapi-1.0.1.tar.gz
.
File metadata
- Download URL: netoapi-1.0.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 062a435ffbc29cb83f33fafded03236e426374d25efd6f5ee227680b1773d197 |
|
MD5 | fefed0640a2f3886b5f7ba1d5a57a9ec |
|
BLAKE2b-256 | ca28f0bab896c084cf1017ebf60f0958cf29a1e5979d2d34a5d7f28c5d94a555 |
File details
Details for the file netoapi-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: netoapi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d87607f0f7b74f95a3208a57905b7ed2cd2b012378c6f2863918e20da89b97a6 |
|
MD5 | 66bb6d57da6446d0b8106d519ff64c8f |
|
BLAKE2b-256 | ad11aad2c6d5112f587707f600cd8bfa483df9708c37baa4f63dd41bf9d6845f |