Giter Club home page Giter Club logo

ebay-node-api's Introduction

Ebay API Node.js

Ebay API Client for node js.

The intent is to simplify the request process by handling the tedious logic. It's a thin wrapper around eBay Api.

npm version Build Status

Table of Contents

Installation

npm install ebay-node-api

Usage:

let eBay = require('ebay-node-api')

let ebay = new eBay({
    clientID: "-- Client APP ID ----", 
    // options  - optional HTTP request timeout to apply to all requests.
})

Creates a new Ebay instance.

Getting Client ID:

Join eBay developers program. Register your app here https://go.developer.ebay.com/quick-start-guide.

Options

  • clientID - Required(String) - Client Id key provided when you register in eBay developers program.
  • limit - optional(Number) - fetch items functionality - Number that limits the number of data you need in response.
  • details - optional(Boolean) - Get User Details functionality - true, if you need details about the user.

Example

GetAccessToken

const Ebay = require("ebay-node-api");

let ebay = new Ebay({
    clientID: "--Client Id----",
    clientSecret: '-- Client Secret --',
    body: {
        grant_type: "client_credentials"
    }
});
ebay.getAccessToken().then((data) => {
    console.log(data); // data.access_token
}, (error) => {
    console.log(error);
});

FetchItemsByKeyword

const Ebay = require("ebay-node-api");

let ebay = new Ebay({
    clientID: "-- Client APP ID ----",
    limit: 6
});
ebay.findItemsByKeywords("iphone").then((data) => {
    console.log(data); // fetches top 6 results in form of JSON.
}, (error) => {
    console.log(error);
});

GetAllCategories

const Ebay = require("ebay-node-api");

let ebay = new Ebay({
    clientID: "-- Client App id ----",
    details: "childCategories" //optional parameter
});

ebay.getAllCategories().then((data) => {
    console.log(data); //extract data.CategoryArray
}, (error) => {
    console.log(error);
})

GetItemsByCategory

let ebay = new Ebay({
    clientID: "-- Client APP ID ----",
    limit: 6
});
ebay.findItemsByCategory(10181).then((data) => {
    console.log(data);
}, (error) => {
    console.log(error);
});

GetItem

// Get access token and pass it to this method
ebay.getAccessToken()
    .then((data) => {
        ebay.getItem('v1|202117468662|0').then((data) => {
            console.log(data);
            // Data is in format of JSON
            // To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
        })
    });

GetItemByLegacyId

ebay.getAccessToken()
    .then((data) => {
        ebay.getItemByLegacyId({
            "legacyItemId": 2628001 // Get Item Details Using a Legacy ID
            "legacyVariationSku": "V-00031-WHM" // default null
        }).then((data) => {
            if (!data) console.log(data);
            // Data is in format of JSON
            // To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
        });
    });

GetItemsByGroupId

ebay.getAccessToken()
    .then((data) => {
        ebay.getItemByItemGroup("151915076499").then((data) => {
            // Data is in format of JSON
            // To check the format of Data, Go to this url (https://jsonblob.com/56cbea67-30b8-11e8-953c-5d1886dcf4a0)
            console.log(data)
        }, (error) => {
            console.log(error);
        });
    });

SearchItemsByKeyword

ebay.getAccessToken()
    .then((data) => {
        ebay.searchItems({
            keyword: "drone",
            limit: "3"
        }).then((data) => {
            console.log(data);
            // Data is in format of JSON
            // To check the format of Data, Go to this url (https://developer.ebay.com/api-     docs/buy/browse/resources/item_summary/methods/search#w4-w1-w4-SearchforItemsbyKeyword-0)
        })
    });

SearchItemsByFreeShipping

ebay.getAccessToken()
    .then((data) => {
        ebay.searchItems({
            keyword: "drone",
            limit: 3,
            filter: { maxDeliveryCost: 0 }
        }).then((data) => {
            console.log(data);
            // Data is in format of JSON
            // To check the format of Data, Go to this url https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search#w4-w1-w4-ReturnItemswithFreeShipping-6.
        })
    });

SearchItemsByFilter

ebay.getAccessToken()
    .then((data) => {
        ebay.searchItems({
            keyword: "iphone",
            limit: 3,
            filter: { price: "[300..800]", priceCurrency: "USD", conditions: "NEW" }
        }).then((data) => {
            console.log(data);
            // Data is in format of JSON
            // To check the format of Data, Go to this url https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search#w4-w1-w4-ReturnItemsBasedonPriceandCondition-7.
        })
    });

Test

All test files are present inside test folder. You can run using

npm run test

Issues:

If you are facing any issues, you can create the issues here.

License:

MIT.

Examples:

I have mentioned the examples here https://github.com/ajay2507/ebay-node-api/tree/master/demo.

ebay-node-api's People

Contributors

pajaydev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.