An easy to use python interface for BlackCurve's API
Project description
BlackCurve Python API Library
API Documentation
Documentation for the BlackCurve endpoints can be found here.
Requirements
- Python 2.7+
- Requests HTTP library for python v2.0 or above.
Installation
$ pip install requests
$ pip install blackcurve_api
Basic Usage
Initiate a Connection
You just need your subdomain and a access token to get started
from blackcurve.api import BlackCurveAPI
bc = BlackCurveAPI({{ subdomain }}, {{ access_token }})
Reload a Access Token
Need a new access token, or just misplaced the old one?
bc = BlackCurveAPI({{ subdomain }})
token = bc.get_access_token({{ client_key }}, {{ client_secret }})
print(token)
This will also update your BlackCurveAPI instance with the new token so you can immediately carry on with requests.
Get Prices
Get a list of current Prices
# get all the prices
bc.prices().all()
# get all prices
prices = bc.prices().all()
print('You have {} prices'.format(len(prices)))
# get a price for a single product by id
bc.prices().find('42')
# filter specific product columns
bc.prices(columns=['Price', 'Product ID']).all()
# filter geography
bc.prices(geography='UK').all()
# filter by column value -- price >= 5
bc.prices(price_gte=5).all()
Data Sources Info
Get column and data type information about your data sources
# get all the data sources
bc.data_sources_info().all()
# get a single data source
bc.data_sources_info().find('Sales History').all()
Data Sources
Get a list of all of the data in a given source
# get all of the data from sales history
bc.data_sources().find('Sales History').all()
# get just the volume and product id columns in sales history
bc.data_sources(columns=['Volume', 'Product ID']).find('Sales History').all()
# filter by column value -- price >= 5
bc.data_sources(price_gte=5).find('Sales History').all()
# get a generator for all the pages returned in sales history
sales_history = bc.data_sources().find('Sales History').all()
page = 1
for x in sales_history:
print('Page %s of Sales History: %s' % (page, x))
page += 1
Geographies & Currencies
Get a list of associated data for Geographies and Currencies
# get a list of all of the geography data
bc.geographies().all()
# get a specific geography
bc.geographies('Website UK').all()
# get a list of all currencies
bc.currencies().all()
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
blackcurve-0.2.0.tar.gz
(8.1 kB
view hashes)
Built Distribution
blackcurve-0.2.0-py3-none-any.whl
(13.9 kB
view hashes)
Close
Hashes for blackcurve-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97afe61ee49eca080cfc3e4cc18a765dffadf9b2d0c4f92abcf46f02500c2f3c |
|
MD5 | 6999c1f39feb30836c2381467d67954e |
|
BLAKE2b-256 | 85a2c194abc07824b978a0fbfcc0da66a75aec38358455d6d834b2283984b776 |