How can i make a node request to get the product id of a card by searching its name

(Andrew Vasquez) #1

Im trying to make an application to make a mtg collection and also see the price of the card or at least check the price and using the endpoint http://api.tcgplayer.com/catalog/categories/1/search i set the productName in the filters to ‘black lotus’ and none of the responses are that card so im confused about how this searches products

(Joshua Burdick) #2

What does your request look like?

(Andrew Vasquez) #3
        var options = {
        method: 'POST',
        headers: {
            Authorization: "bearer " + process.env.BEARER_TOKEN
        },
        url: 'http://api.tcgplayer.com/catalog/categories/1/search',
        body:
        {
            filters: [{ name: 'productName', values: 'Black Lotus' }],
            includeAggregates: 'true'
        },
        json: true
    };

    request(options, function (error, response, body) {
        if (error) throw new Error(error);

        console.log(body);

        res.json(body)
    });

//The results come back but none of the cards are the card i searched for

(Andrew Vasquez) #4
    var options = {
    method: 'POST',
    headers: {
        Authorization: "bearer " + process.env.BEARER_TOKEN
    },
    url: 'http://api.tcgplayer.com/catalog/categories/1/search',
    body:
    {
        filters: [{ name: 'productName', values: 'Black Lotus' }],
        includeAggregates: 'true'
    },
    json: true
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);

    res.json(body)
});
(Joshua Burdick) #5

filters: [{ name: ‘productName’, values: ‘Black Lotus’ }],

Needs to be:
filters: [{ name: ‘ProductName’, values: [‘Black Lotus’] }],

Calling the search manifest returns these details and more. We also have a guide written on the search functionality here: