StockX Python3 API Wrapper
Project description
Stockx Python3 API Wrapper
Notes
This is an unofficial StockX SDK for Python3. This project is currently not unit tested and is likely full of bugs. It not recommended to use this SDK in production applications unless you really know what you’re doing. Pull requests, issues, and requests for features are welcome. SDK documentation will come as features are finished.
This SDK does not (currently) support accounts registered with Facebook or Twitter.
Prerequisites
You’ll need to create an account on StockX. Please make sure to register with an email+password (not Facebook or Twitter) at the moment.
Basic Usage
from stockxsdk import Stockx
stockx = Stockx()
email = 'YOUR_EMAIL'
password = 'YOUR_PASSWORD'
stockx.authenticate(email, password)
product_id = stockx.get_first_product_id('BB1234')
highest_bid = stockx.get_highest_bid(product_id)
print(highest_bid.shoe_size, highest_bid.order_price)
lowest_ask = stockx.get_lowest_ask(product_id)
print(lowest_ask.shoe_size, lowest_ask.order_price)
SDK Documentation
stockx.authenticate
stockx.authenticate(email, password)
Authenticates the SDK to make requests on your behalf. You must authenticate the SDK to retrieve info about your account or place new asks/bids.
Parameters
string - Email for the account
string - Password for the account
Returns
bool Success of the login operation
Example
email = 'example@test.com'
password = 'example123'
logged_in = stockx.authenticate(email, password)
print(logged_in) # `True`, hopefully
stockx.me
stock.me()
Returns information about your account.
Parameters
none
Returns
Object - Account info as a JSON object
Example
me = stock.me()
print(me) # some huge JSON object
stockx.selling
stockx.selling()
Returns information about what you’re currently selling (asks, pending, sold).
Parameters
none
Returns
list<StockxItem> - A list of StockxItem objects
Example
selling = stockx.selling()
for item in selling:
print(item.item_type, item.item_id, item.item_price)
stockx.buying
stockx.buying()
Returns information about what you’re currently buying (bids, pending, bought).
Parameters
none
Returns
list<StockxItem> - A list of StockxItem objects
Example
buying = stockx.buying()
for item in buying:
print(item.item_type, item.item_id, item.item_price)
stockx.rewards
stockx.rewards()
Returns information about your seller level as a JSON object
Parameters
none
Returns
Object - Seller level info as a JSON object
Example
rewards = stockx.rewards()
print(rewards) # some JSON object
stockx.stats
stockx.stats()
Returns statistics about your collection as a JSON object
Parameters
none
Returns
Object - User stats as a JSON object
Example
stats = stockx.stats()
print(stats) # some JSON object
stockx.cop_list
stockx.cop_list()
Returns your current cop list as a list of StockxItem objects
Parameters
none
Returns
List<StockxItem> - Current coplist as list of StockxItem objects
Example
cop_list = stockx.cop_list()
for item in cop_list:
print(item.item_type, item.item_id, item.item_price)
stockx.add_product_to_follow
stockx.add_product_to_follow(product_id)
Adds a new product to your cop list. product_id must be the ID of a specific size.
Parameters
string - Product ID of product to follow
Returns
bool - Success of the operation
Example
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
followed = stockx.add_product_to_follow(size_id)
print(followed) # True, hopefully
stockx.add_product_to_portfolio
stockx.add_product_to_portfolio(product_id, purchase_price, condition='new', purchase_date=None)
Adds a new product to your portfolio. purchase_date is a standard YYYY-MM-DD string and defaults to today’s date. condition is one of: new, 9.5, 9, 8.5, 8, 7, 6, 5, 4, 3, 2, 1 and defaults to new.
Parameters
string - Product ID of product to add to portfolio
number - Price of product at purchase
string - Condition of product
string - Purchase date of product
Returns
bool - Success of the operation
Example
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
added = stockx.add_product_to_collection(size_id)
print(added) # True, hopefully
stockx.get_product
stockx.get_product(product_id)
Returns the full StockX product object given a StockX product id
Parameters
string - Product ID of product to get
Returns
StockxProduct - The product with that ID
Example
product_id = '2c91a3dc-4ba6-40bc-af0b-a259f793a223'
product = stockx.get_product(product_id)
print(product.title) # 'Adidas EQT Support 93/17 Core Black Turbo'
stockx.get_asks
stockx.get_asks(product_id)
Returns a list of all ‘Ask’ StockxOrder objects for a given product ID
Parameters
string - Product ID
Returns
List<StockxOrder> - List of ‘Ask’ StockxOrder objects
Example
product_id = '2c91a3dc-4ba6-40bc-af0b-a259f793a223'
asks = stockx.get_asks(product_id)
for ask in asks:
print(ask.shoe_size, ask.order_price)
stockx.get_lowest_ask
stockx.get_lowest_ask(product_id)
Returns the lowest ask for a given product as a StockxOrder object
Parameters
string - Product ID
Returns
StockxOrder - Lowest ask as a StockxOrder
Example
product_id = '2c91a3dc-4ba6-40bc-af0b-a259f793a223'
lowest_ask = stockx.get_lowest_ask(product_id)
print(ask.shoe_size, ask.order_price)
stockx.get_bids
stockx.get_bids(product_id)
Returns a list of all ‘Bid’ StockxOrder objects for a given product ID
Parameters
string - Product ID
Returns
List<StockxOrder> - List of ‘Bid’ StockxOrder objects
Example
product_id = '2c91a3dc-4ba6-40bc-af0b-a259f793a223'
bids = stockx.get_bids(product_id)
for bid in bids:
print(bid.shoe_size, bid.order_price)
stockx.get_highest_bid
stockx.get_highest_bid(product_id)
Returns the highest bid for a given product as a StockxOrder object
Parameters
string - Product ID
Returns
StockxOrder - highest bid as a StockxOrder
Example
product_id = '2c91a3dc-4ba6-40bc-af0b-a259f793a223'
highest_bid = stockx.get_highest_bid(product_id)
print(bid.shoe_size, bid.order_price)
stockx.create_ask
stockx.create_ask(product_id, price, expiry_date=None)
Creates a new ask for a product at a given price to expire at a given date. Expiry date is a standard YYYY-MM-DD string and defaults to now+30 days.
Parameters
string - Product ID
number - Price in USD
expiry_date - Ask expiry date; defaults to now+30 days
Returns
string - Ask ID
Example
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
ask_id = stockx.create_ask(size_id, 300)
print(ask_id) # Some string
stockx.update_ask
stockx.update_ask(ask_id, new_price, expiry_date=None)
Updates an ask for a product at a given price to expire at a given date. Expiry date is a standard YYYY-MM-DD string and defaults to now+30 days. ask_id is the item_id for that ask returned by stockx.selling().
Parameters
string - Ask ID
number - New price for the ask
expiry_date - Ask expiry date, defaults to now+30 days
Returns
bool - Success of the operation
Example
ask_id = '12489999967982049999'
updated = stockx.update_ask(ask_id, 400)
print(updated) # True, hopefully
stockx.cancel_ask
stockx.cancel_ask(ask_id)
Cancels an ask for a product. ask_id is the item_id for that ask returned by stockx.buying().
Parameters
string - Ask ID
Returns
bool - Success of the operation
Example
ask_id = '12489999967982049999'
cancelled = stockx.cancel_ask(ask_id)
print(cancelled) # True, hopefully
stockx.create_bid
stockx.create_bid(product_id, price, expiry_date)
Creates a new bid for a product at a given price to expire at a given date. Expiry date is a standard YYYY-MM-DD string and defaults to now+30 days.
Parameters
string - Product ID number - Price in USD expiry_date - Bid expiry date, defaults to now+30 days
Returns
string - Bid ID
Example
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
bid_id = stockx.create_bid(size_id, 300)
print(bid_id) # Some string
stockx.update_bid
stockx.update_bid(bid_id, new_price, expiry_date=None)
Updates an bid for a product at a given price to expire at a given date. Expiry date is a standard YYYY-MM-DD string and defaults to now+30 days. bid_id is the item_id for that bid returned by stockx.buying().
Parameters
string - Bid ID
number - New price for the bid
expiry_date - Bid expiry date, defaults to now+30 days
Returns
bool - Success of the operation
Example
bid_id = '12489999967982049999'
updated = stockx.update_bid(bid_id, 400)
print(updated) # True, hopefully
stockx.cancel_bid
stockx.cancel_bid(bid_id)
Cancels an bid for a product. bid_id is the item_id for that bid returned by stockx.selling().
Parameters
string - Bid ID
Returns
bool - Success of the operation
Example
bid_id = '12489999967982049999'
cancelled = stockx.cancel_bid(bid_id)
print(cancelled) # True, hopefully
stockx.search
stockx.search(query)
Searches StockX for a given query. Returns the first 20 matches.
Parameters
string - The query to search for
Returns
List<Object> - A list of JSON response objects
Example
hits = stockx.search('BB1234')
for hit in hits:
print(hit) # Some huge JSON object
stockx.get_first_product_id
stockx.get_first_product_id(query)
Returns the first product ID for a given query.
Parameters
string - The query to search for
Returns
string - ID of the first product returned
Example
product_id = stockx.get_first_product_id('BB1234')
print(product_id) # '2c91a3dc-4ba6-40bc-af0b-a259f793a223'
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
File details
Details for the file stockx-py-sdk-0.0.2.tar.gz
.
File metadata
- Download URL: stockx-py-sdk-0.0.2.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de2bf7b125b038cb71ce160e8c3869583c7996f30a6d7be53f6d023fe8ec4c35 |
|
MD5 | 0df1926b1ec0cd1755709cee087f1e48 |
|
BLAKE2b-256 | e649e7316cae6626327c44b12703460541b9312b3fb2946a2a9e30823a3130a4 |