-
Notifications
You must be signed in to change notification settings - Fork 75
/
searchApi.js
105 lines (90 loc) · 3.7 KB
/
searchApi.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const Ebay = require('../src/index');
const { clientId, clientSecret } = require('./credentials');
const makeString = require('make-string');
let ebay = new Ebay({
clientID: clientId,
clientSecret: clientSecret,
body: {
grant_type: 'client_credentials',
scope: 'https://api.ebay.com/oauth/api_scope'
}
});
// // //Search for Items by Keyword.
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)
})
});
// // Search for Items by Category.
ebay.getAccessToken()
.then((data) => {
ebay.searchItems({
categoryId: 2080,
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-SearchforItemsbyCategory-1.
})
});
// // Retrieve the Item Aspects by Keyword Search.
ebay.getAccessToken()
.then((data) => {
ebay.searchItems({
keyword: 'iphone',
fieldgroups: 'ASPECT_REFINEMENTS'
}).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-RetrievetheItemAspectsbyKeywordSearch-3.
})
});
// // Return Items with Free Shipping.
// // Pass params inside filter object to filter items.
ebay.getAccessToken()
.then((data) => {
ebay.searchItems({
keyword: 'drone',
limit: 3,
filter: { maxDeliveryCost: 0 },
aspect_filter: { categoryId: 179697, conditionDistributions: '{NEW}' } // docs to provide aspect_filter https://developer.ebay.com/api-docs/buy/browse/resources/item_summary/methods/search#h2-input
}).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.
})
});
// Return Items Based on Price and Condition.
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.
})
});
// // Search items by Image, this is in experimental mode.
// https://developer.ebay.com/api-docs/buy/browse/resources/search_by_image/methods/searchByImage
ebay.getAccessToken()
.then((data) => {
console.log
ebay.searchByImage({
imgPath: 'demo/shoe.jpg',
limit: 3,
sort: '-price' // igmPath or base64Image
}).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)
})
});