ebay-api 1.13.7 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -19
- package/README.md +512 -118
- package/lib/api/apiFactory.d.ts +27 -0
- package/lib/api/apiFactory.js +100 -0
- package/lib/api/apiFactory.js.map +1 -0
- package/lib/api/base.d.ts +13 -0
- package/lib/api/base.js +25 -0
- package/lib/api/base.js.map +1 -0
- package/lib/api/index.d.ts +11 -0
- package/lib/api/index.js +18 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/restful/buy/browse/index.d.ts +84 -0
- package/lib/api/restful/buy/browse/index.js +142 -0
- package/lib/api/restful/buy/browse/index.js.map +1 -0
- package/lib/api/restful/buy/deal/index.d.ts +55 -0
- package/lib/api/restful/buy/deal/index.js +80 -0
- package/lib/api/restful/buy/deal/index.js.map +1 -0
- package/lib/api/restful/buy/feed/index.d.ts +43 -0
- package/lib/api/restful/buy/feed/index.js +85 -0
- package/lib/api/restful/buy/feed/index.js.map +1 -0
- package/lib/api/restful/buy/index.d.ts +17 -0
- package/lib/api/restful/buy/index.js +21 -0
- package/lib/api/restful/buy/index.js.map +1 -0
- package/lib/api/restful/buy/marketing/index.d.ts +27 -0
- package/lib/api/restful/buy/marketing/index.js +51 -0
- package/lib/api/restful/buy/marketing/index.js.map +1 -0
- package/lib/api/restful/buy/marketplaceInsights/index.d.ts +28 -0
- package/lib/api/restful/buy/marketplaceInsights/index.js +51 -0
- package/lib/api/restful/buy/marketplaceInsights/index.js.map +1 -0
- package/lib/api/restful/buy/offer/index.d.ts +23 -0
- package/lib/api/restful/buy/offer/index.js +37 -0
- package/lib/api/restful/buy/offer/index.js.map +1 -0
- package/lib/api/restful/buy/order/index.d.ts +264 -0
- package/lib/api/restful/buy/order/index.js +369 -0
- package/lib/api/restful/buy/order/index.js.map +1 -0
- package/lib/api/restful/commerce/catalog/index.d.ts +73 -0
- package/lib/api/restful/commerce/catalog/index.js +108 -0
- package/lib/api/restful/commerce/catalog/index.js.map +1 -0
- package/lib/api/restful/commerce/charity/index.d.ts +34 -0
- package/lib/api/restful/commerce/charity/index.js +56 -0
- package/lib/api/restful/commerce/charity/index.js.map +1 -0
- package/lib/api/restful/commerce/identity/index.d.ts +14 -0
- package/lib/api/restful/commerce/identity/index.js +27 -0
- package/lib/api/restful/commerce/identity/index.js.map +1 -0
- package/lib/api/restful/commerce/index.d.ts +15 -0
- package/lib/api/restful/commerce/index.js +19 -0
- package/lib/api/restful/commerce/index.js.map +1 -0
- package/lib/api/restful/commerce/notification/index.d.ts +117 -0
- package/lib/api/restful/commerce/notification/index.js +187 -0
- package/lib/api/restful/commerce/notification/index.js.map +1 -0
- package/lib/api/restful/commerce/taxonomy/index.d.ts +78 -0
- package/lib/api/restful/commerce/taxonomy/index.js +135 -0
- package/lib/api/restful/commerce/taxonomy/index.js.map +1 -0
- package/lib/api/restful/commerce/translation/index.d.ts +15 -0
- package/lib/api/restful/commerce/translation/index.js +25 -0
- package/lib/api/restful/commerce/translation/index.js.map +1 -0
- package/lib/api/restful/developer/analytics/index.d.ts +22 -0
- package/lib/api/restful/developer/analytics/index.js +45 -0
- package/lib/api/restful/developer/analytics/index.js.map +1 -0
- package/lib/api/restful/developer/index.d.ts +5 -0
- package/lib/api/restful/developer/index.js +9 -0
- package/lib/api/restful/developer/index.js.map +1 -0
- package/lib/api/restful/index.d.ts +63 -0
- package/lib/api/restful/index.js +165 -0
- package/lib/api/restful/index.js.map +1 -0
- package/lib/api/restful/postOrder/cancellation/index.d.ts +57 -0
- package/lib/api/restful/postOrder/cancellation/index.js +95 -0
- package/lib/api/restful/postOrder/cancellation/index.js.map +1 -0
- package/lib/api/restful/postOrder/case/index.d.ts +63 -0
- package/lib/api/restful/postOrder/case/index.js +97 -0
- package/lib/api/restful/postOrder/case/index.js.map +1 -0
- package/lib/api/restful/postOrder/index.d.ts +11 -0
- package/lib/api/restful/postOrder/index.js +15 -0
- package/lib/api/restful/postOrder/index.js.map +1 -0
- package/lib/api/restful/postOrder/inquiry/index.d.ts +82 -0
- package/lib/api/restful/postOrder/inquiry/index.js +131 -0
- package/lib/api/restful/postOrder/inquiry/index.js.map +1 -0
- package/lib/api/restful/postOrder/return/index.d.ts +231 -0
- package/lib/api/restful/postOrder/return/index.js +361 -0
- package/lib/api/restful/postOrder/return/index.js.map +1 -0
- package/lib/api/restful/sell/account/index.d.ts +217 -0
- package/lib/api/restful/sell/account/index.js +337 -0
- package/lib/api/restful/sell/account/index.js.map +1 -0
- package/lib/api/restful/sell/analytics/index.d.ts +41 -0
- package/lib/api/restful/sell/analytics/index.js +61 -0
- package/lib/api/restful/sell/analytics/index.js.map +1 -0
- package/lib/api/restful/sell/compliance/index.d.ts +37 -0
- package/lib/api/restful/sell/compliance/index.js +57 -0
- package/lib/api/restful/sell/compliance/index.js.map +1 -0
- package/lib/api/restful/sell/feed/index.d.ts +151 -0
- package/lib/api/restful/sell/feed/index.js +255 -0
- package/lib/api/restful/sell/feed/index.js.map +1 -0
- package/lib/api/restful/sell/finances/index.d.ts +74 -0
- package/lib/api/restful/sell/finances/index.js +105 -0
- package/lib/api/restful/sell/finances/index.js.map +1 -0
- package/lib/api/restful/sell/fulfillment/index.d.ts +137 -0
- package/lib/api/restful/sell/fulfillment/index.js +199 -0
- package/lib/api/restful/sell/fulfillment/index.js.map +1 -0
- package/lib/api/restful/sell/index.d.ts +29 -0
- package/lib/api/restful/sell/index.js +33 -0
- package/lib/api/restful/sell/index.js.map +1 -0
- package/lib/api/restful/sell/inventory/index.d.ts +248 -0
- package/lib/api/restful/sell/inventory/index.js +346 -0
- package/lib/api/restful/sell/inventory/index.js.map +1 -0
- package/lib/api/restful/sell/listing/index.d.ts +14 -0
- package/lib/api/restful/sell/listing/index.js +25 -0
- package/lib/api/restful/sell/listing/index.js.map +1 -0
- package/lib/api/restful/sell/logistics/index.d.ts +44 -0
- package/lib/api/restful/sell/logistics/index.js +66 -0
- package/lib/api/restful/sell/logistics/index.js.map +1 -0
- package/lib/api/restful/sell/marketing/index.d.ts +443 -0
- package/lib/api/restful/sell/marketing/index.js +609 -0
- package/lib/api/restful/sell/marketing/index.js.map +1 -0
- package/lib/api/restful/sell/metadata/index.d.ts +77 -0
- package/lib/api/restful/sell/metadata/index.js +131 -0
- package/lib/api/restful/sell/metadata/index.js.map +1 -0
- package/lib/api/restful/sell/negotiation/index.d.ts +24 -0
- package/lib/api/restful/sell/negotiation/index.js +39 -0
- package/lib/api/restful/sell/negotiation/index.js.map +1 -0
- package/lib/api/restful/sell/recommendation/index.d.ts +26 -0
- package/lib/api/restful/sell/recommendation/index.js +39 -0
- package/lib/api/restful/sell/recommendation/index.js.map +1 -0
- package/lib/api/traditional/XMLRequest.d.ts +98 -0
- package/lib/api/traditional/XMLRequest.js +191 -0
- package/lib/api/traditional/XMLRequest.js.map +1 -0
- package/lib/api/traditional/clientAlerts/index.d.ts +9 -0
- package/lib/api/traditional/clientAlerts/index.js +15 -0
- package/lib/api/traditional/clientAlerts/index.js.map +1 -0
- package/lib/api/traditional/clientAlerts/types.d.ts +31 -0
- package/lib/api/traditional/clientAlerts/types.js +36 -0
- package/lib/api/traditional/clientAlerts/types.js.map +1 -0
- package/lib/api/traditional/fields.d.ts +1948 -0
- package/lib/api/traditional/fields.js +1949 -0
- package/lib/api/traditional/fields.js.map +1 -0
- package/lib/api/traditional/finding/index.d.ts +12 -0
- package/lib/api/traditional/finding/index.js +16 -0
- package/lib/api/traditional/finding/index.js.map +1 -0
- package/lib/api/traditional/index.d.ts +17 -0
- package/lib/api/traditional/index.js +207 -0
- package/lib/api/traditional/index.js.map +1 -0
- package/lib/api/traditional/merchandising/index.d.ts +7 -0
- package/lib/api/traditional/merchandising/index.js +11 -0
- package/lib/api/traditional/merchandising/index.js.map +1 -0
- package/lib/api/traditional/shopping/index.d.ts +11 -0
- package/lib/api/traditional/shopping/index.js +16 -0
- package/lib/api/traditional/shopping/index.js.map +1 -0
- package/lib/api/traditional/trading/index.d.ts +142 -0
- package/lib/api/traditional/trading/index.js +146 -0
- package/lib/api/traditional/trading/index.js.map +1 -0
- package/lib/auth/authNAuth.d.ts +49 -0
- package/lib/auth/authNAuth.js +122 -0
- package/lib/auth/authNAuth.js.map +1 -0
- package/lib/auth/index.d.ts +17 -0
- package/lib/auth/index.js +32 -0
- package/lib/auth/index.js.map +1 -0
- package/lib/auth/oAuth2.d.ts +90 -0
- package/lib/auth/oAuth2.js +258 -0
- package/lib/auth/oAuth2.js.map +1 -0
- package/lib/ebay-api.min.js +2 -0
- package/lib/ebay-api.min.js.map +1 -0
- package/lib/enums/apiEnums.d.ts +49 -0
- package/lib/enums/apiEnums.js +55 -0
- package/lib/enums/apiEnums.js.map +1 -0
- package/lib/enums/index.d.ts +2 -0
- package/lib/enums/index.js +15 -0
- package/lib/enums/index.js.map +1 -0
- package/lib/enums/restfulEnums.d.ts +966 -0
- package/lib/enums/restfulEnums.js +1012 -0
- package/lib/enums/restfulEnums.js.map +1 -0
- package/lib/errors/index.d.ts +66 -0
- package/lib/errors/index.js +208 -0
- package/lib/errors/index.js.map +1 -0
- package/lib/index.d.ts +56 -0
- package/lib/index.js +99 -0
- package/lib/index.js.map +1 -0
- package/lib/request.d.ts +26 -0
- package/lib/request.js +51 -0
- package/lib/request.js.map +1 -0
- package/lib/types/apiTypes.d.ts +28 -0
- package/lib/types/apiTypes.js +3 -0
- package/lib/types/apiTypes.js.map +1 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +16 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/restfulTypes.d.ts +1082 -0
- package/lib/types/restfulTypes.js +3 -0
- package/lib/types/restfulTypes.js.map +1 -0
- package/lib/types/traditonalTypes.d.ts +34 -0
- package/lib/types/traditonalTypes.js +3 -0
- package/lib/types/traditonalTypes.js.map +1 -0
- package/package.json +115 -21
- package/.npmignore +0 -17
- package/.travis.yml +0 -7
- package/examples/Finding-FindItemsByKeywords.js +0 -46
- package/examples/Merchandising-GetMostWatchedItemsRequest.js +0 -16
- package/examples/Shopping-GetSingleItem.js +0 -18
- package/examples/Trading-GetOrders.js +0 -26
- package/index.js +0 -10
- package/lib/deep-to-array.js +0 -42
- package/lib/defaults.js +0 -69
- package/lib/errors.js +0 -44
- package/lib/json-parser.js +0 -336
- package/lib/key-lists.js +0 -64
- package/lib/urls.js +0 -64
- package/lib/versions.js +0 -35
- package/lib/xml-converter.js +0 -21
- package/lib/xml-request.js +0 -207
- package/scripts/parse-input-xml.js +0 -41
- package/test/deep-to-array.test.js +0 -100
- package/test/errors.test.js +0 -75
- package/test/helpers.js +0 -22
- package/test/mocha.opts +0 -1
- package/test/mocks/GetMultipleItems.xml +0 -115
- package/test/mocks/GetOrders-empty.xml +0 -17
- package/test/mocks/GetOrders.xml +0 -463
- package/test/pagination.test.js +0 -5
- package/test/parsing.test.js +0 -248
- package/test/xml-request.test.js +0 -447
package/README.md
CHANGED
|
@@ -1,149 +1,543 @@
|
|
|
1
|
-
eBay API
|
|
2
|
-
|
|
1
|
+
# eBay Node API in TypeScript with Browser support
|
|
2
|
+
[](https://travis-ci.com/hendt/ebay-api)
|
|
3
|
+
[](https://codecov.io/gh/hendt/ebay-api)
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
This eBay API implements both Traditional \(xml\) and the RESTful eBay API.
|
|
6
|
+
It supports `client credentials grant` and `authorization code grant` \(Auth'N'Auth, OAuth2 and IAF\).
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
* [API Browser Examples](https://hendt.github.io/ebay-api/)
|
|
9
|
+
* [API Documentation](https://hendt.gitbook.io/ebay-api/)
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
## eBay Docs
|
|
12
|
+
* [eBay API Explorer](https://developer.ebay.com/my/api_test_tool)
|
|
13
|
+
* [eBay API Docs](https://developer.ebay.com/docs)
|
|
9
14
|
|
|
15
|
+
## Changelog
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
* `v6.2.0` is the latest release.
|
|
18
|
+
* See [here](https://github.com/hendt/ebay-api/blob/master/CHANGELOG.md) for the full changelog.
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
with an interface that is both a) somewhat consistent across APIs and b) not too different from the underlying interface.
|
|
20
|
+
## Implementation status
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
### RESTful API
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
| API | Implemented |
|
|
25
|
+
| :--- | :--- |
|
|
26
|
+
| **Buy API** | ✔ Browse API `v1.10.0`<br>✔ Deal API `v1.3.0`<br>✔ Feed API<br>✔ Marketing API<br>✔ Offer API<br>✔ Order API<br>✔ Marketplace Insights API |
|
|
27
|
+
| **Commerce API** | ✔ Catalog API<br>✔ Charity API `v1.2.0`<br>✔ Identity API<br>✔ Notification API `v1.2.0`<br>✔ Taxonomy API `v1.0.0`<br>✔ Translation API `v1_beta.1.4` |
|
|
28
|
+
| **Developer API** | ✔ Analytics API|
|
|
29
|
+
| **Post Order API** | ✔ Cancellation API<br>✔ Case Management API<br>✔ Inquiry API<br>✔ Return API |
|
|
30
|
+
| **Sell API** | ✔ Account API `v1.6.3`<br>✔ Analytics API `v1.3.0`<br>✔ Compliance API `v1.4.1`<br>✔ Feed API<br>✔ Finance API `v1.9.0`<br>✔ Fulfillment API `v1.19.10`<br>✔ Inventory API `v1.14.0`<br>✔ Listing API<br>✔ Logistics API<br>✔ Marketing API `v1.10.0`<br>✔ Metadata API<br>✔ Negotiation API `v1.1.0`<br>✔ Recommendation API `v1.1.0`|
|
|
19
31
|
|
|
32
|
+
### Traditional API
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
| API | Implemented |
|
|
35
|
+
| :--- | :--- |
|
|
36
|
+
| **Finding API** | ✔ |
|
|
37
|
+
| **Shopping API** | ✔ |
|
|
38
|
+
| **Merchandising API** | ✔ |
|
|
39
|
+
| **Trading API** | ✔ |
|
|
40
|
+
| **Client Alerts API** | ✔ |
|
|
41
|
+
| **Feedback API** | ✔ |
|
|
22
42
|
|
|
23
|
-
|
|
24
|
-
(I realize this is contrary to best practice, but the module is not yet settled enough to major-bump every time.)
|
|
43
|
+
## Install
|
|
25
44
|
|
|
26
|
-
|
|
27
|
-
|
|
45
|
+
```bash
|
|
46
|
+
npm install ebay-api
|
|
47
|
+
yarn add ebay-api
|
|
48
|
+
```
|
|
28
49
|
|
|
50
|
+
## 🚀 Usage & Quick start
|
|
29
51
|
|
|
30
|
-
|
|
52
|
+
Sign up for an API key here: [Developer Account](https://developer.ebay.com/signin?tab=register).
|
|
53
|
+
Checkout API [examples](https://github.com/hendt/ebay-api/tree/master/examples).
|
|
31
54
|
|
|
32
|
-
|
|
55
|
+
### NodeJS
|
|
33
56
|
|
|
34
|
-
|
|
57
|
+
```javascript
|
|
58
|
+
import eBayApi from 'ebay-api';
|
|
59
|
+
// or:
|
|
60
|
+
// const eBayApi = require('ebay-api')
|
|
35
61
|
|
|
36
|
-
|
|
62
|
+
const eBay = new eBayApi({
|
|
63
|
+
appId: '-- also called Client ID --',
|
|
64
|
+
certId: '-- also called Client Secret --',
|
|
65
|
+
sandbox: false
|
|
66
|
+
});
|
|
37
67
|
|
|
68
|
+
const item = await eBay.buy.browse.getItem('v1|254188828753|0');
|
|
69
|
+
console.log(JSON.stringify(item, null, 2));
|
|
70
|
+
```
|
|
38
71
|
|
|
39
|
-
|
|
72
|
+
#### Detailed configuration example
|
|
73
|
+
```javascript
|
|
74
|
+
import eBayApi from 'ebay-api';
|
|
40
75
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(You'll need a key to run the examples.)
|
|
46
|
-
|
|
47
|
-
And please make sure to follow the liscence terms: eBay API [License](http://developer.ebay.com/join/licenses/individual/) and [Terms](https://www.x.com/developers/ebay/programs/affiliates/terms) when using this library.
|
|
76
|
+
const eBay = new eBayApi({
|
|
77
|
+
appId: '-- also called Client ID --',
|
|
78
|
+
certId: '-- also called Client Secret --',
|
|
79
|
+
sandbox: false,
|
|
48
80
|
|
|
81
|
+
siteId: eBayApi.SiteId.EBAY_US, // required for traditional APIs, see https://developer.ebay.com/DevZone/merchandising/docs/Concepts/SiteIDToGlobalID.html
|
|
82
|
+
|
|
83
|
+
marketplaceId: eBayApi.MarketplaceId.EBAY_US, // defautl. required for RESTful APIs
|
|
84
|
+
acceptLanguage: eBayApi.Locale.en_US, // defautl
|
|
85
|
+
contentLanguage: eBayApi.ContentLanguage.en_US, // defautl.
|
|
49
86
|
|
|
50
|
-
|
|
87
|
+
// optional parameters, should be omitted if not used
|
|
88
|
+
devId: '-- devId --', // required for traditional Trading API
|
|
89
|
+
ruName: '-- eBay Redirect URL name --', // 'RuName' (eBay Redirect URL name) required for authorization code grant
|
|
90
|
+
|
|
91
|
+
authToken: '-- Auth\'n\'Auth for traditional API (used by trading) --', // can be set to use traditional API without code grant
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Browser
|
|
96
|
+
Check out live example: [https://hendt.github.io/ebay-api/](https://hendt.github.io/ebay-api/).
|
|
97
|
+
Because of the eBay CORS problems a Proxy server is required to use the API in the Browser.
|
|
98
|
+
|
|
99
|
+
For testing purpose you can use `https://ebay.hendt.workers.dev/` url as proxy. You can also set up your own Proxy server. We have added a example for cloudfront workers: [https://github.com/hendt/ebay-api/blob/master/proxy/worker.js](https://github.com/hendt/ebay-api/blob/master/proxy/worker.js)
|
|
100
|
+
|
|
101
|
+
Or use [https://github.com/Rob--W/cors-anywhere](CORS Anywhere is a NodeJS proxy) (works very well with heroku.com).
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ebay-api@latest/lib/ebay-api.min.js"></script>
|
|
106
|
+
<script>
|
|
107
|
+
const eBay = new eBayApi({
|
|
108
|
+
appId: 'appId',
|
|
109
|
+
certId: 'certId',
|
|
110
|
+
sandbox: false
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// eBay.req.instance is AxiosInstance per default
|
|
114
|
+
eBay.req.instance.interceptors.request.use((request) => {
|
|
115
|
+
// Add Proxy
|
|
116
|
+
request.url = 'https://ebay.hendt.workers.dev/' + request.url;
|
|
117
|
+
return request;
|
|
118
|
+
});
|
|
51
119
|
|
|
52
|
-
|
|
120
|
+
eBay.buy.browse.getItem('v1|254188828753|0').then(item => {
|
|
121
|
+
console.log(JSON.stringify(item, null, 2));
|
|
122
|
+
}).catch(e => {
|
|
123
|
+
console.error(e);
|
|
124
|
+
});
|
|
125
|
+
</script>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 🔧 eBayApi Config
|
|
129
|
+
The first (required) parameter in eBayApi instance takes an object with following properties:
|
|
130
|
+
|
|
131
|
+
| Name | Occurrence | Description |
|
|
132
|
+
| :--- | :--- | :--- |
|
|
133
|
+
| appId | Required | App ID \(Client ID\) from [Application Keys](https://developer.ebay.com/my/keys). |
|
|
134
|
+
| certId | Required | Cert ID \(Client Secret\) from [Application Keys](https://developer.ebay.com/my/keys). |
|
|
135
|
+
| devId | Conditionally | The Dev Id from [Application Keys](https://developer.ebay.com/my/keys). |
|
|
136
|
+
| sandbox | Required<br><pre>Default: `false`</pre> | If true, the [Sandbox Environment](https://developer.ebay.com/tools/sandbox) will be used. |
|
|
137
|
+
| ruName | Conditionally | The redirect\_url value. [More info](https://developer.ebay.com/api-docs/static/oauth-redirect-uri.html). |
|
|
138
|
+
| autoRefreshToken | Required<pre>Default: `true`</pre> | Auto refresh the token if it's expired. |
|
|
139
|
+
| siteId<br><i>Traditional</i> | Required<br><pre>Default: `SiteId.EBAY_US`</pre> | eBay site to which you want to send the request (Trading API, Shopping API). |
|
|
140
|
+
| authToken<br><i>Traditional</i> | Optional | The Auth'N'Auth token. The traditional authentication and authorization technology used by the eBay APIs. |
|
|
141
|
+
| marketplaceId<br><i>RESTful</i> | Required<br><pre>Default: `MarketplaceId.EBAY_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#marketpl) REST HTTP Header. X-EBAY-C-MARKETPLACE-ID identifies the user's business context and is specified using a marketplace ID value. Note that this header does not indicate a language preference or consumer location. |
|
|
142
|
+
| scope<br><i>RESTful</i> | Conditionally<bre><pre>Default:<br>`['https://api.ebay.com/oauth/api_scope']` </pre> | The scopes assigned to your application allow access to different API resources and functionality. |
|
|
143
|
+
| endUserCtx<br><i>RESTful</i> | Conditionally recommended<br><i>RESTful</i> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers) X-EBAY\_C\_ENDUSERCTX provides various types of information associated with the request. |
|
|
144
|
+
| contentLanguage<br><i>RESTful</i> | Conditionally required<br><pre>Default: `ContentLanguage.en_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers)Content-Language indicates the locale preferred by the client for the response. |
|
|
145
|
+
| acceptLanguage<br><i>RESTful</i> | Optional<pre>Default: `Locale.en_US`</pre> | [Docs](https://developer.ebay.com/api-docs/static/rest-request-components.html#headers) Accept-Language indicates the natural language the client prefers for the response. This specifies the language the client wants to use when the field values provided in the request body are displayed to consumers. |
|
|
146
|
+
|
|
147
|
+
## Load config from environment
|
|
148
|
+
Use `eBayApi.fromEnv()` to load data from environment variables.
|
|
149
|
+
|
|
150
|
+
| Name | Value |
|
|
151
|
+
| :--- | :--- |
|
|
152
|
+
| appId | process.env.EBAY_APP_ID |
|
|
153
|
+
| certId | process.env.EBAY_CERT_ID |
|
|
154
|
+
| devId | process.env.EBAY_DEV_ID |
|
|
155
|
+
| authToken | process.env.EBAY_AUTH_TOKEN |
|
|
156
|
+
| siteId | process.env.EBAY_SITE_ID |
|
|
157
|
+
| marketplaceId | process.env.EBAY_MARKETPLACE_ID |
|
|
158
|
+
| ruName | process.env.EBAY_RU_NAME |
|
|
159
|
+
| sandbox | process.env.EBAY_SANDBOX === 'true' |
|
|
160
|
+
|
|
161
|
+
## 🐞 Debug
|
|
162
|
+
To see debug logs use `DEBUG=ebay:*` environment variable.
|
|
163
|
+
|
|
164
|
+
## 🔑 Access token types
|
|
165
|
+
See the full Documentation [here](https://developer.ebay.com/api-docs/static/oauth-token-types.html).
|
|
166
|
+
|
|
167
|
+
*Client credentials grant flow* mints a new Application access token.
|
|
168
|
+
*Authorization code grant flow* mints a new User access token.
|
|
169
|
+
|
|
170
|
+
### User access token (authorization code grant flow)
|
|
171
|
+
👉 Recommended for all API Calls.
|
|
172
|
+
|
|
173
|
+
> You must employ a User token to call any interface that accesses or modifies data that is owned by the user (such as user information and account data).
|
|
174
|
+
To get a User token, the users of your app must grant your application the permissions it needs to act upon their behalf. This process is called user consent. With the user consent flow, each User token contains the set of scopes for which the user has granted their permission [(eBay Token Types)](https://developer.ebay.com/api-docs/static/oauth-token-types.html).
|
|
175
|
+
|
|
176
|
+
### Application access token (client credentials grant flow)
|
|
177
|
+
👉 Recommended for API calls that will only request application data (`GET` method, and it's also restricted).
|
|
178
|
+
|
|
179
|
+
> Application tokens are general-use tokens that give access to interfaces that return application data. For example, many GET requests require only an Application token for authorization.
|
|
180
|
+
[(eBay Token Types)](https://developer.ebay.com/api-docs/static/oauth-token-types.html)
|
|
181
|
+
|
|
182
|
+
If no other token is set, this token will be obtained *automatically* in the process of calling an RESTful API.
|
|
183
|
+
|
|
184
|
+
### Auth'N'Auth
|
|
185
|
+
👉 The "old" way. Only works with Traditional API.
|
|
186
|
+
Checkout the [Auth'N'Auth example](https://github.com/hendt/ebay-api/tree/master/examples/traditional/authNAuth.ts).
|
|
187
|
+
|
|
188
|
+
You can also generate the token on eBay developer page and use it directly (see Detailed configuration example).
|
|
189
|
+
|
|
190
|
+
## OAuth2: Exchanging the authorization code for a User access token
|
|
191
|
+
|
|
192
|
+
[eBay Docs](https://developer.ebay.com/api-docs/static/oauth-auth-code-grant-request.html)
|
|
53
193
|
|
|
54
|
-
|
|
194
|
+
```javascript
|
|
195
|
+
import eBayApi from 'ebay-api';
|
|
196
|
+
|
|
197
|
+
// 1. Create new eBayApi instance and set the scope.
|
|
198
|
+
const eBay = eBayApi.fromEnv();
|
|
199
|
+
|
|
200
|
+
eBay.OAuth2.setScope([
|
|
201
|
+
'https://api.ebay.com/oauth/api_scope',
|
|
202
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
|
|
203
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment'
|
|
204
|
+
]);
|
|
205
|
+
|
|
206
|
+
// 2. Generate and open Url and Grant Access
|
|
207
|
+
const url = eBay.OAuth2.generateAuthUrl();
|
|
208
|
+
console.log('Open URL', url);
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
After you granted success, eBay will redirect you to your 'Auth accepted URL' and add a query parameter `code`
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
### Express example
|
|
215
|
+
This is how it would look like if you use `express`:
|
|
216
|
+
|
|
217
|
+
```javascript
|
|
218
|
+
import eBayApi from 'ebay-api';
|
|
55
219
|
|
|
56
|
-
|
|
220
|
+
app.get('/success', async function(req, res) {
|
|
221
|
+
// 3. Get the parameter code that is placed as query parameter in redirected page
|
|
222
|
+
const code = req.query.code; // this is provided from eBay
|
|
223
|
+
const eBay = eBayApi.fromEnv(); // or use new eBayApi()
|
|
57
224
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
225
|
+
try {
|
|
226
|
+
const token = await eBay.OAuth2.getToken(code);
|
|
227
|
+
eBay.OAuth2.setCredentials(token);
|
|
228
|
+
// store this token e.g. to a session
|
|
229
|
+
req.session.token = token
|
|
230
|
+
|
|
231
|
+
// 5. Start using the API
|
|
232
|
+
const orders = await eBay.sell.fulfillment.getOrders()
|
|
233
|
+
res.send(orders);
|
|
234
|
+
} catch(e) {
|
|
235
|
+
console.error(e)
|
|
236
|
+
res.sendStatus(400)
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
If token is already in session:
|
|
242
|
+
|
|
243
|
+
```js
|
|
244
|
+
import eBayApi from 'ebay-api';
|
|
245
|
+
|
|
246
|
+
app.get('/orders/:id', async function(req, res) {
|
|
247
|
+
const id = req.params.id;
|
|
248
|
+
const eBay = eBayApi.fromEnv(); // or use new eBayApi(...)
|
|
249
|
+
const token = req.session.token;
|
|
250
|
+
if (!token) {
|
|
251
|
+
return res.sendStatus(403);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
eBay.OAuth2.setCredentials(token);
|
|
77
255
|
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
256
|
+
// If token get's refreshed
|
|
257
|
+
eBay.OAuth2.on('refreshAuthToken', (token) => {
|
|
258
|
+
req.session.token = token;
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
// 5. Start using the API
|
|
263
|
+
const order = await eBay.sell.fulfillment.getOrder(id);
|
|
264
|
+
res.send(order);
|
|
265
|
+
} catch(e) {
|
|
266
|
+
console.error(e)
|
|
267
|
+
res.sendStatus(400)
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## RESTful API
|
|
273
|
+
|
|
274
|
+
### How to set the Scope
|
|
275
|
+
|
|
276
|
+
```javascript
|
|
277
|
+
const eBay = new eBayApi({
|
|
278
|
+
// ...
|
|
279
|
+
scope: ['https://api.ebay.com/oauth/api_scope']
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Or:
|
|
283
|
+
eBay.OAuth2.setScope([
|
|
284
|
+
'https://api.ebay.com/oauth/api_scope',
|
|
285
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly',
|
|
286
|
+
'https://api.ebay.com/oauth/api_scope/sell.fulfillment'
|
|
287
|
+
]);
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Use apix.ebay.com or apiz.ebay.com (beta) endpoints
|
|
291
|
+
For some APIs, eBay use a `apix`/`apiz` subdomain. To use these subdomains you can use `.apix`/`.apiz` before the api call like this:
|
|
292
|
+
```javascript
|
|
293
|
+
eBay.buy.browse.apix.getItem() // now it will use https://apix.ebay.com
|
|
294
|
+
eBay.buy.browse.apiz.getItem() // now it will use https://apiz.ebay.com
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
In any case eBay adds a new subdomain, it's also possible to configure whatever you want:
|
|
298
|
+
```javascript
|
|
299
|
+
eBay.buy.browse.api({subdomain: 'apiy'}).getItem() // now it will use https://apiy.ebay.com
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### How to refresh the token
|
|
303
|
+
If `autoRefreshToken` is set to true (default value) the token will be automatically refreshed when eBay response with `invalid access token` error.
|
|
304
|
+
|
|
305
|
+
Use Event Emitter to get the token when it gets successfully refreshed.
|
|
306
|
+
```javascript
|
|
307
|
+
eBay.OAuth2.on('refreshAuthToken', (token) => {
|
|
308
|
+
console.log(token)
|
|
309
|
+
// Store this token in DB
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
// for client token
|
|
313
|
+
eBay.OAuth2.on('refreshClientToken', (token) => {
|
|
314
|
+
console.log(token)
|
|
315
|
+
// Store this token in DB
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
To manuel refresh the auth token use `eBay.OAuth2.refreshAuthToken()` and for the client token `eBay.OAuth2.refreshClientToken()`.
|
|
319
|
+
Keep in mind that you need the 'refresh_token' value set.
|
|
320
|
+
|
|
321
|
+
```javascript
|
|
322
|
+
const token = await eBay.OAuth2.refreshToken();
|
|
323
|
+
// will refresh Auth Token if set, otherwise the client token if set.
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Additional request headers
|
|
327
|
+
Sometimes you want to add additional headers to the request like a GLOBAL-ID `X-EBAY-SOA-GLOBAL-ID`.
|
|
328
|
+
You have multiple options to do this.
|
|
329
|
+
|
|
330
|
+
### RESTful API headers
|
|
331
|
+
```javascript
|
|
332
|
+
const eBay = new eBayApi();
|
|
333
|
+
|
|
334
|
+
eBay.buy.browse.api({headers: {
|
|
335
|
+
'X-EBAY-SOA-GLOBAL-ID': 'EBAY-DE'
|
|
336
|
+
}}).getItem('v1|382282567190|651094235351').then((item) => {
|
|
337
|
+
console.log(item)
|
|
338
|
+
})
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Traditional API headers
|
|
342
|
+
You can pass headers directly in the method call in the second parameter:
|
|
343
|
+
```javascript
|
|
344
|
+
eBay.trading.AddFixedPriceItem({
|
|
345
|
+
Item: {
|
|
346
|
+
Title: 'title',
|
|
347
|
+
Description: {
|
|
348
|
+
__cdata: '<div>test</div>'
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
headers: {
|
|
353
|
+
'X-EBAY-SOA-GLOBAL-ID': 'EBAY-DE'
|
|
354
|
+
}
|
|
355
|
+
})
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Low level: use the Axios interceptor to manipulate the request
|
|
359
|
+
```javascript
|
|
360
|
+
import eBayApi from 'ebay-api';
|
|
361
|
+
const eBay = new eBayApi(/* { your config here } */);
|
|
362
|
+
|
|
363
|
+
eBay.req.instance.interceptors.request.use((request) => {
|
|
364
|
+
// Add Header
|
|
365
|
+
request.headers['X-EBAY-SOA-GLOBAL-ID'] = 'EBAY-DE';
|
|
366
|
+
return request;
|
|
367
|
+
})
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Handle JSON GZIP response e.g fetchItemAspects
|
|
371
|
+
You need a decompress library installed like `zlib`.
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
npm install zlib # or yarn add zlib
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
```javascript
|
|
378
|
+
import eBayApi from 'ebay-api';
|
|
379
|
+
import zlib from 'zlib';
|
|
380
|
+
|
|
381
|
+
const toString = (data) => new Promise((resolve) => {
|
|
382
|
+
zlib.gunzip(data, (err, output) => {
|
|
383
|
+
if (err) throw err;
|
|
384
|
+
resolve(output.toString());
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
const eBay = new eBayApi(/* { your config here } */);
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
const data = await eBay.commerce.taxonomy.fetchItemAspects(/* categoryTreeId */);
|
|
392
|
+
const result = await toString(data);
|
|
393
|
+
|
|
394
|
+
console.log(result)
|
|
395
|
+
} catch (e) {
|
|
396
|
+
console.error(e);
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Controlling Traditional XML request and response
|
|
401
|
+
The second parameter in the traditional API has the following options:
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
export type Options = {
|
|
405
|
+
raw?: boolean // return raw XML
|
|
406
|
+
parseOptions?: object // https://github.com/NaturalIntelligence/fast-xml-parser
|
|
407
|
+
useIaf?: boolean // use IAF in header instead of Bearer
|
|
408
|
+
headers?: Headers // additional Headers (key, value)
|
|
409
|
+
hook?: (xml) => BodyHeaders // hook into the request to modify the body and headers
|
|
410
|
+
};
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
[Fast XML](https://github.com/NaturalIntelligence/fast-xml-parser) is used to parse the XML. You can pass the parse option to `parseOptions` parameter.
|
|
132
414
|
|
|
133
415
|
## Examples
|
|
134
416
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
417
|
+
### Trading - AddFixedPriceItem \(CDATA\)
|
|
418
|
+
|
|
419
|
+
You can submit your description using CDATA if you want to use HTML or XML.
|
|
420
|
+
|
|
421
|
+
```javascript
|
|
422
|
+
eBay.trading.AddFixedPriceItem({
|
|
423
|
+
Item: {
|
|
424
|
+
Title: 'title',
|
|
425
|
+
Description: {
|
|
426
|
+
__cdata: '<div>test</div>'
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Trading - ReviseFixedPriceItem (Update the price of an item)
|
|
433
|
+
|
|
434
|
+
```javascript
|
|
435
|
+
eBay.trading.ReviseFixedPriceItem({
|
|
436
|
+
Item: {
|
|
437
|
+
ItemID: 'itemId',
|
|
438
|
+
StartPrice: 'startPrice'
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Buy - getItem
|
|
444
|
+
|
|
445
|
+
```javascript
|
|
446
|
+
eBay.buy.browse.getItem('v1|382282567190|651094235351').then(a => {
|
|
447
|
+
console.log(a);
|
|
448
|
+
}).catch(e => {
|
|
449
|
+
console.log(e)
|
|
450
|
+
});
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### Post-Order - getReturn
|
|
454
|
+
|
|
455
|
+
```javascript
|
|
456
|
+
eBay.postOrder.return.getReturn('5132021997').then(a => {
|
|
457
|
+
console.log(a);
|
|
458
|
+
}).catch(e => {
|
|
459
|
+
console.log(e)
|
|
460
|
+
});
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Finding - findItemsByProduct \(use XML attributes and value\)
|
|
464
|
+
|
|
465
|
+
```javascript
|
|
466
|
+
eBay.finding.findItemsByProduct({
|
|
467
|
+
productId: {
|
|
468
|
+
'@_type': 'ReferenceID',
|
|
469
|
+
'#value': '53039031'
|
|
470
|
+
}
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
// will produce:
|
|
474
|
+
// <productId type="ReferenceID">53039031</productId>
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### Finding - findItemsIneBayStores
|
|
478
|
+
|
|
479
|
+
```javascript
|
|
480
|
+
eBay.finding.findItemsIneBayStores({
|
|
481
|
+
storeName: 'HENDT'
|
|
482
|
+
}, {raw: true}).then(result => {
|
|
483
|
+
// Return raw XML
|
|
484
|
+
console.log(result);
|
|
485
|
+
});
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Finding - findItemsAdvanced \(findItemsByKeywords\)
|
|
489
|
+
|
|
490
|
+
```javascript
|
|
491
|
+
eBay.finding.findItemsAdvanced({
|
|
492
|
+
itemFilter: [{
|
|
493
|
+
name: 'Seller',
|
|
494
|
+
value: 'hendt_de'
|
|
495
|
+
}],
|
|
496
|
+
keywords: 'katze'
|
|
497
|
+
}).then(result => {
|
|
498
|
+
console.log(result);
|
|
499
|
+
});
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
### Trading - GetMyeBaySelling
|
|
503
|
+
|
|
504
|
+
```javascript
|
|
505
|
+
eBay.trading.GetMyeBaySelling({
|
|
506
|
+
SoldList: {
|
|
507
|
+
Include: true,
|
|
508
|
+
Pagination: {
|
|
509
|
+
EntriesPerPage: 20,
|
|
510
|
+
PageNumber: 1
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}).then(data => {
|
|
514
|
+
console.log(data.results)
|
|
515
|
+
});
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
## FAQ
|
|
519
|
+
1. Do I need the [eBay OAuth Client](https://www.npmjs.com/package/ebay-oauth-nodejs-client) dependency?
|
|
520
|
+
|
|
521
|
+
No. This library has already all authentication implemented and support also auto refreshing token.
|
|
522
|
+
|
|
523
|
+
2. What does IAF mean?
|
|
524
|
+
|
|
525
|
+
IAF stands for IDENTITY ASSERTION FRAMEWORK.
|
|
526
|
+
The traditional API supports IAF. That means you can use the OAuth2 token with the traditional APIs.
|
|
527
|
+
|
|
528
|
+
3. Is it possible to Upload Pictures directly to EPS?
|
|
529
|
+
|
|
530
|
+
Yes. Checkout the [Browser](https://hendt.github.io/ebay-api/) example and [Node Example here](https://github.com/hendt/ebay-api/blob/master/examples/traditional/trading.UploadSiteHostedPictures.ts).
|
|
531
|
+
|
|
532
|
+
## Contribution
|
|
533
|
+
|
|
534
|
+
Check [here](https://github.com/hendt/ebay-api/blob/master/CONTRIBUTING.md)
|
|
535
|
+
|
|
536
|
+
## Supported By
|
|
537
|
+
|
|
538
|
+
[hendt.de](https://hendt.de)
|
|
539
|
+
[rootle.de](https://rootle.de)
|
|
540
|
+
|
|
541
|
+
## 📝 License
|
|
146
542
|
|
|
147
|
-
|
|
148
|
-
[examples]: https://github.com/benbuckman/nodejs-ebay-api/tree/master/examples
|
|
149
|
-
[request]: https://github.com/request/request
|
|
543
|
+
MIT.
|