Stockx Python3 API Wrapper
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.
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.
You can install this package with pip
:
$ pip install stockxsdk
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)
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.
string
- Email for the accountstring
- Password for the account
bool
Success of the login operation
email = '[email protected]'
password = 'example123'
logged_in = stockx.authenticate(email, password)
print(logged_in) # `True`, hopefully
stock.me()
Returns information about your account.
none
Object
- Account info as a JSON object
me = stock.me()
print(me) # some huge JSON object
stockx.selling()
Returns information about what you're currently selling (asks, pending, sold).
none
list<StockxItem>
- A list of StockxItem objects
selling = stockx.selling()
for item in selling:
print(item.item_type, item.item_id, item.item_price)
stockx.buying()
Returns information about what you're currently buying (bids, pending, bought).
none
list<StockxItem>
- A list of StockxItem objects
buying = stockx.buying()
for item in buying:
print(item.item_type, item.item_id, item.item_price)
stockx.rewards()
Returns information about your seller level as a JSON object
none
Object
- Seller level info as a JSON object
rewards = stockx.rewards()
print(rewards) # some JSON object
stockx.stats()
Returns statistics about your collection as a JSON object
none
Object
- User stats as a JSON object
stats = stockx.stats()
print(stats) # some JSON object
stockx.cop_list()
Returns your current cop list as a list of StockxItem objects
none
List<StockxItem>
- Current coplist as list of StockxItem objects
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(product_id)
Adds a new product to your cop list. product_id
must be the ID of
a specific size.
string
- Product ID of product to follow
bool
- Success of the operation
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
followed = stockx.add_product_to_follow(size_id)
print(followed) # True, hopefully
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
.
string
- Product ID of product to add to portfolionumber
- Price of product at purchasestring
- Condition of productstring
- Purchase date of product
bool
- Success of the operation
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
added = stockx.add_product_to_collection(size_id)
print(added) # True, hopefully
stockx.get_product(product_id)
Returns the full StockX product object given a StockX product id
string
- Product ID of product to get
StockxProduct
- The product with that ID
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(product_id)
Returns a list of all 'Ask' StockxOrder
objects for a given product
ID
string
- Product ID
List<StockxOrder>
- List of 'Ask' StockxOrder
objects
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(product_id)
Returns the lowest ask for a given product as a StockxOrder
object
string
- Product ID
StockxOrder
- Lowest ask as a StockxOrder
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(product_id)
Returns a list of all 'Bid' StockxOrder
objects for a given product
ID
string
- Product ID
List<StockxOrder>
- List of 'Bid' StockxOrder
objects
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(product_id)
Returns the highest bid for a given product as a StockxOrder
object
string
- Product ID
StockxOrder
- highest bid as a StockxOrder
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(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.
string
- Product IDnumber
- Price in USDexpiry_date
- Ask expiry date; defaults to now+30 days
string
- Ask ID
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
ask_id = stockx.create_ask(size_id, 300)
print(ask_id) # Some string
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()
.
string
- Ask IDnumber
- New price for the askexpiry_date
- Ask expiry date, defaults to now+30 days
bool
- Success of the operation
ask_id = '12489999967982049999'
updated = stockx.update_ask(ask_id, 400)
print(updated) # True, hopefully
stockx.cancel_ask(ask_id)
Cancels an ask for a product. ask_id
is the item_id
for that ask
returned by stockx.buying()
.
string
- Ask ID
bool
- Success of the operation
ask_id = '12489999967982049999'
cancelled = stockx.cancel_ask(ask_id)
print(cancelled) # True, hopefully
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.
string
- Product ID number
- Price in USD expiry_date
- Bid
expiry date, defaults to now+30 days
string
- Bid ID
size_id = '36f86e69-9d4f-4b82-94a2-d85b4e7fd370'
bid_id = stockx.create_bid(size_id, 300)
print(bid_id) # Some string
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()
.
string
- Bid IDnumber
- New price for the bidexpiry_date
- Bid expiry date, defaults to now+30 days
bool
- Success of the operation
bid_id = '12489999967982049999'
updated = stockx.update_bid(bid_id, 400)
print(updated) # True, hopefully
stockx.cancel_bid(bid_id)
Cancels an bid for a product. bid_id
is the item_id
for that bid
returned by stockx.selling()
.
string
- Bid ID
bool
- Success of the operation
bid_id = '12489999967982049999'
cancelled = stockx.cancel_bid(bid_id)
print(cancelled) # True, hopefully
stockx.search(query)
Searches StockX for a given query. Returns the first 20 matches.
string
- The query to search for
List<Object>
- A list of JSON response objects
hits = stockx.search('BB1234')
for hit in hits:
print(hit) # Some huge JSON object
stockx.get_first_product_id(query)
Returns the first product ID for a given query.
string
- The query to search for
string
- ID of the first product returned
product_id = stockx.get_first_product_id('BB1234')
print(product_id) # '2c91a3dc-4ba6-40bc-af0b-a259f793a223'