Skip to content

An Easy (Unofficial) Way to Access StockX's API

Notifications You must be signed in to change notification settings

walmat/stockx-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stockx-api

version npm

Easy access to StockX's unofficial API through object oriented promises. If you have any issues, you can contact me through discord at matthew#1232. Feel free to use this however you want, as it is under the MIT license. I would love to see what projects you guys can come up with using this. If you'd like to contribute to this library, fork the repo, make your changes, and submit a pull request.

Installation

npm install stockx-api

Or with yarn,

yarn add stockx-api

Features

  • Account login
  • Placing asks
  • Placing bids
  • Product searching
  • Variant scraping
  • Product monitoring

How to use

Basic use

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

(async () => {
    try {
        console.log('Logging in...');
        
        //Logs in using account email and password
        await stockX.login({
            user: 'accountemailhere', 
            password: 'accountpassword'
        });
        
        console.log('Successfully logged in!');

        //Returns an array of products
        const productList = await stockX.searchProducts('yeezy');
        
        //Fetch variants and product details of the first product
        const product = await stockX.fetchProductDetails(productList[0]);
        
        console.log('Placing an ask for ' + product.name);

        //Places an ask on that product
        const ask = await stockX.placeAsk(product, {
            amount: 5000000000, 
            size: '9.5'
        });
        
        console.log('Successfully placed an ask for $5000 for ' + product.name);
        
        //Updates the previous ask
        await stockX.updateAsk(ask, {
            amount: 600000
        });
        
        console.log('Updated previous ask!');
    }
    catch(e){
        console.log('Error: ' + e.message);
    }
})();

Customizing stockx-api

stockx-api accepts a few parameters in the class options

  • proxy - sets the proxy to be used with all requests being made (ip:port:user:pass)
  • currency - sets the currency to be used when placing asks/bids

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI({
    proxy: 'proxyhere',
    currency: 'USD'
});

Searching for products

You can directly use Stockx's search API by using the searchProducts method. This takes in one parameter - the search query. There is also an optional options parameter, in which you can pass in:

  • limit - limits the amount of search results returned.

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

stockX.searchProducts('yeezy', {
    limit: 5
})
.then(products => console.log(products))
.catch(err => console.log(`Error searching: ${err.message}`));

Scraping product details

You can scrape the variants and basic product information using the fetchProductDetails method. You can either pass in a previously fetched product from the searchProducts method or use the link to the product.

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet')
.then(product => console.log(product)
.catch(err => console.log(`Error scraping product details: ${err.message}`));

Logging in

You can login to stockX by using the login method. This takes in 2 parameters in the object

  • user - The account email/username
  • password - The account password

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

console.log('Logging in...');

stockX.login({
    user: 'accountemailhere', 
    password: 'accountpassword'
})
.then(() => console.log('Logged in successfully!'));

Placing asks

You can place an ask to stockX by using the placeAsk method. This takes in 3 parameters.

  • product - the product details

In the object:

  • amount - the price of the ask
  • size - the requested size

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

(async () => {
    console.log('Logging in...');

    //Logs in before placing ask
    await stockX.login({
        user: 'accountemailhere', 
        password: 'accountpassword'
    });

    console.log('Successfully logged in!');
    
    //Pull product details to place the ask
    const product = await stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet');

    console.log('Placing an ask for ' + product.name);

    //Place an ask on the product
    await stockX.placeAsk(product, {
        amount: 5000000000, 
        size: 'random'
    });
    
    console.log(`Successfully placed an ask for $5000000000 [${product.name}]`);
})();

Placing bids

You can place a bid to stockX by using the placeBid method. This takes in 3 parameters, identical to placing an ask.

  • product - the product details

In the object:

  • amount - the price of the ask,
  • size - the size of the shoe

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

(async () => {
    console.log('Logging in...');

    //Logs in before placing bid
    await stockX.login({
        user: 'accountemailhere', 
        password: 'accountpassword'
    });

    console.log('Successfully logged in!');
    
    //Pull product details to place the bid
    const product = await stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet');

    console.log('Placing a bid for ' + product.name);

    //Place a bid on that product
    await stockX.placeBid(product, {
        amount: 100, 
        size: '9.5'
    });
    
    console.log(`Successfully placed a bid for $100 [${product.name}]`);
})();

Editing previously made asks

You can edit a previously placed ask by using the updateAsk method. This takes in 2 parameters.

  • ask - the ask to update

In the object:

  • amount - the price to set the ask to

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

(async () => {
    console.log('Logging in...');

    //Logs in before placing ask
    await stockX.login({
        user: 'accountemailhere', 
        password: 'accountpassword'
    });

    console.log('Successfully logged in!');
    
    //Pull product details to place the ask
    const product = await stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet');

    console.log('Placing a bid for ' + product.name);

    //Place an ask on that product
    const ask = await stockX.placeBid(product, {
        amount: 100000, 
        size: '9.5'
    });
    
    console.log(`Successfully placed an ask for $100000 [${product.name}]`);

    //Update previously placed ask
    await stockX.updateAsk(ask, {
        amount: 10000000
    });
    
    console.log('Updated ask!');
})();

Editing previously made bids

You can edit a previously placed bid by using the updateBid method. This takes in 2 parameters.

  • bid - the bid to update

In the object:

  • amount - the price to set the bid to

For example:

const stockxAPI = require('stockx-api');
const stockX = new stockxAPI();

(async () => {
    console.log('Logging in...');

    //Logs in before placing bid
    await stockX.login({
        user: 'accountemailhere', 
        password: 'accountpassword'
    });

    console.log('Successfully logged in!');
    
    //Pull product details to place the bid
    const product = await stockX.fetchProductDetails('https://stockx.com/adidas-yeezy-boost-700-magnet');

    console.log('Placing a bid for ' + product.name);

    //Place a bid on that product
    const bid = await stockX.placeBid(product, {
        amount: 100, 
        size: '9.5'
    });
    
    console.log(`Successfully placed a bid for $100 [${product.name}]`);

    //Update previously placed bid
    await stockX.updateBid(bid, {
        amount: 75
    });
    
    console.log('Updated bid!');
})();

About

An Easy (Unofficial) Way to Access StockX's API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%