-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathbrowseApi.js
68 lines (56 loc) · 2.26 KB
/
browseApi.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const Ebay = require('../src/index');
const { clientId, clientSecret } = require('./credentials/index');
let access_token = '';
let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
body: {
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'
}
});
// Getting access token and calling getItem 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)
})
});
// Reference ebay developer page https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItemByLegacyId#_samples
// Getting access token and calling getItemByLegacyId method.
ebay.getAccessToken()
.then((data) => {
ebay.getItemByLegacyId({
'legacyItemId': 2628001 // Get Item Details Using a Legacy ID
}).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)
});
});
//Get Item Details Using a Legacy ID and SKU
ebay.getAccessToken()
.then((data) => {
ebay.getItemByLegacyId({
'legacyItemId': 2628001,
'legacyVariationSku': 'V-00031-WHM'
}).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)
});
});
//retrieves the details of the individual items in an item group
// reference https://developer.ebay.com/api-docs/buy/browse/resources/item/methods/getItemsByItemGroup#uri.item_group_id
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);
});
});