Skip to content

A Python API client for the Neto (Maropost) Ecommerce platform.

License

Notifications You must be signed in to change notification settings

dan-hobday/netoapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetoAPI Library

A Python API client for the Neto (Maropost) Ecommerce platform.


Requirements:

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.

About

A Python API client for the Neto (Maropost) Ecommerce platform.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages