pajaydev / ebay-node-api

eBay API Client for node
https://pajaydev.github.io/ebay-node-api
MIT License
131 stars 76 forks source link

Buy Now, US Location Only, Free Shipping, Sort least to greatest #95

Closed doverradio closed 4 years ago

doverradio commented 4 years ago

Hello,

Thank you so much for adding the ability to search by seller.

  1. How do I search for a seller and specify Buy Now, US Location Only, Free Shipping, Sort least to greatest from those results?

  2. How do I request these things for when making general search calls not for a specific seller?

pajaydev commented 4 years ago

@doverradio you can search using the browse api with following filters. You can specify the seller name also. Kindly check this one https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search#h2-input

doverradio commented 4 years ago

Hi, I tried using the filters in FindItemsByCategory in this way

ebay.findItemsByCategory({
    categoryID: 10181,

}).then((data) => {
    // console.log(data);
    console.log(data[0].errorMessage[0].error[0].message[0]);
}, (error) => {
    console.log(error);
});

but got error Invalid category ID.

How can I pass in filters on this call?

If I deviate from your example it constantly fails but I need to specify show sold only and price range.

After I checked your source code, perhaps you could replace the current function with this to the function:

const findItemsByCategory = function (options) {
    let categoryID = options.categoryID;
    if (!options.categoryID) throw new Error('INVALID_REQUEST_PARMS --> Category ID is null or invalid');
    this.options.name = categoryID;
    this.options.operationName = FIND_ITEMS_BY_CATEGORY;
    this.options.param = 'categoryId';
    this.options.additionalParam = constructAdditionalParams(options);
    const url = urlObject.buildSearchUrl(this.options);
    return getRequest(url).then((data) => {
        return JSON.parse(data).findItemsByCategoryResponse;
    }, console.error // eslint-disable-line no-console
    );
};

After applying the above, my code now works using that.

pajaydev commented 4 years ago

@doverradio Thanks for reporting, it was not supporting filtering. Let me make this change quickly.

pajaydev commented 4 years ago

Let me create a new issue https://github.com/pajaydev/ebay-node-api/issues/103 to keep it separate from this thread.

pajaydev commented 4 years ago

@doverradio you can use this directly like below to get the sold items

ebay.findCompletedItems({
    keywords: 'Garmin nuvi 1300 Automotive GPS Receiver',
    categoryId: '156955',
    sortOrder: 'PricePlusShippingLowest', //https://developer.ebay.com/devzone/finding/callref/extra/fndcmpltditms.rqst.srtordr.html
    Condition: 3000,
    SoldItemsOnly: true,
    entriesPerPage: 2,
}).then((data) => {
    console.log(data);
}, (error) => {
    console.log(error);
});

Kindly let me know did i get ur question correct.

pajaydev commented 4 years ago

@doverradio Closing this issue, kindly re-open if u r facing this issue