Skip to main content

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:

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.0 - 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


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.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

netoapi-1.0.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file netoapi-1.0.0.tar.gz.

File metadata

  • Download URL: netoapi-1.0.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for netoapi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 038d20801a8590adeb74b9a1433aff55794cf656531488eb5144b4a0c0111e64
MD5 e0215f449e2b1cd303cf886bb9f3608a
BLAKE2b-256 f0dc789cf673846e93725176d4ca1d2fb8eee0ced736050b703fde63c8b631ba

See more details on using hashes here.

File details

Details for the file netoapi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: netoapi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for netoapi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 782450607317c3928c29835f239e823d437a579567ef9cb48369188d5351e5a9
MD5 e9727a728b9bfe5d3fe0fc145380462b
BLAKE2b-256 c60e3edbd64b6250ec8c661faa6eee24367358f313cf96cf468cc2d5206a651a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page