Skip to content

real-alexei/pyvend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyvend is a thin Vend API wrapper for Python

Usage

Here are some examples.

import os
import vend


# Authorization

auth = vend.Auth(os.environ['VEND_CLIENT_ID'], os.environ['VEND_CLIENT_SECRET'], os.environ['VEND_REDIRECT_URI'])
auth_url = auth.get_auth_url() # send retailer to this URL to authorize your client app
...
token = auth.request_token(code, domain_prefix)


# API

api = API(token)
api.customers(params={'email': '[email protected]'}) # GET /api/[email protected]
api.supplier(post=data) # POST data to /api/supplier
api.supplier(5, put=data) # PUT data to /api/supplier/5

# Handle errors
try:
    api.blah()
except vend.APIError, e:
    e.status # 404
    str(e) # {'error': 'Endpoint not found'}

# Note that invalid input does not raise APIError and must be handled as normal response
response = api.products(post={"invalid": "data"})
# {
#   'details': 'Missing handle',
#   'error': 'Could not Add or Update',
#   'status': 'error'
# }

About

Vend API wrapper for Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages