benbuckman / nodejs-ebay-api Goto Github PK
View Code? Open in Web Editor NEW[No longer maintained] eBay API Client for Node.js
License: MIT License
[No longer maintained] eBay API Client for Node.js
License: MIT License
I have made a simple script to interface with ebay through this plugin but all queries are using these values.
serviceName='Trading'
opType='GetSellingManagerSoldListings';
Even if i leave them blank it queries this same API. Even when i try GetSellingManagerSaleRecord is shows the same response.
What am i doing wrong?
my server.js below.. I have replaced my actual values with XXXXXXXXXXXXXX. The authToken is fed in from the client side at this time.
var ebay_cred={
//get orders
// app/environment
devId: 'XXXXXXXXXXXXXX',
certId: 'XXXXXXXXXXXXXX',
appName: 'XXXXXXXXXXXXXX',
sandbox: false,
};
s={};
s.userOps=function(x,y){
y=ebay_cred;
for (var n in x) {
y[n]=x[n];
}
return y;
}
var http = require('http'),io = require('socket.io'),fs = require('fs'),request = require('request');
var server = http.createServer();
server.listen(3000);
io = io.listen(server);
io.on('connection', function (cn) {
function tx(x){cn.emit('f',x);}
cn.on('f', function (d) {
switch(d.f){
case'diag':
tx(ebay_cred);
break;
case'getOrders':
d.op.serviceName='Trading',d.op.opType='GetSellingManagerSoldListings';
ebay.xmlRequest(s.userOps(d.op),function(er,d) {
tx({f:'getOrders',d:ebay.flatten(d)});
});
break;
case'x':
ebay.xmlRequest(s.userOps(d.op),function(er,d) {
tx(d);
});
break;
}
});
});
my client code looks like this
<table id="processingOrders">
<tbody>
</tbody>
</table>
<script>
$user={token:'XXXXXXXXXXXX'}
var socket = io('ws://localhost:3000');
function cx(x){
if(!x.op){x.op={}};x.op.authToken=$user.token;
socket.emit('f',x);
}
socket.on('f',function (d) {
console.log(d);
switch(d.f){
case'getOrders':
d.e=$('#processingOrders');
d.tmp='';
if(d.d&&d.d.SaleRecord){
$.each(d.d.SaleRecord,function(n,v){
v._SM=v.SellingManagerSoldTransaction,v._SA=v.ShippingAddress;
d.tmp+='<tr>';
d.tmp+='<td>'+v._SM.ItemTitle+'</td><td>'+v._SA.Name+'</td><td>'+v._SA.PostalCode+'</td>';
d.tmp+='</tr>';
});
}
d.e.find('tbody').append(d.tmp);
break;
}
delete(d.tmp);
});
</script>
Some example client calls:
cx({f:'getOrders'})
cx({f:'x',ops:{serviceName:'Finding',opType:'GetSellingManagerSaleRecord',params:{ItemID:"172279039480",TransactionID:"1581513952007"}}})
Hi,
I am trying to do a BulkDataExchange call with no luck. I enter the correct operation type but I still keep getting. Did anyone manage to do a BulkDataExchange call? Could you tell me what am I doing wrong?
Thanks in advance!!
'Bad response status code 500 <?xml version=\'1.0\' encoding=\'UTF-8\'?><errorMessage xmlns="http://www.ebay.com/marketplace/services"><error><errorId>2000</errorId><domain>CoreRuntime</domain><severity>Error</severity><category>Request</category><message>Service operation is unknown</message><subdomain>Inbound_Meta_Data</subdomain><parameter name="Param1"></parameter></error></errorMessage>'
var eBayAPI = require('ebay-api');
static startDownloadJobRequest(requestParams){
return new Promise(function (resolve, reject){
eBayAPI.xmlRequest({
serviceName : 'BulkDataExchange',
opType : 'startDownloadJob',
devId: eBayParams.devId,
certId: eBayParams.certId,
appName: eBayParams.appName,
sandbox: eBayParams.sandBox,
authToken: requestParams.token,
params: {
'downloadJobType': "SoldReport"
}
}, function(error, result) {
console.log("startDownloadJobRequest",error, result);
if(error)
reject(error);
else{
resolve(result);
}
});
});
}
}
Hi, I'm trying to make an AddFixedPriceItemCall. I'm using the ebayApiPostXmlRequest
method, and my params are seen below:
params: {
authToken: myAuthTokenIsHere,
Item: {
Country: 'US',
Currency: 'USD',
Description: description,
ListingType: 'FixedPriceItem',
PictureDetails: picturesArray,
Quantity: '5',
StartPrice: price
},
}
I have auth tokens, etc. and all application tokens, I've simply omitted that code from here. Unfortunately, it's giving errors that the country doesn't exist, although it's obviously shown in my Item{} object. Is this a bug, or am I doing something wrong?
Thank you!
Hello Dev,
I am using this nodejs-ebay-api module for searching the book using ISBN in app. So I took reference of this findItemsByProduct from eBay developers site. I have tried my code like following
var parameters = {
productId:{ '__value__': "9788172234980", '@type': 'ISBN' },
outputSelector: ['AspectHistogram'],
paginationInput: {
entriesPerPage: 10
}
};
ebay.xmlRequest({
serviceName: 'Finding',
opType: 'findItemsByProduct',
appId: 'My-app-id',
params: parameters
}, function itemsCallback(error, itemsResponse) {
if (error) throw error;
var items = itemsResponse.searchResult.item;
console.log('Found', items.length, 'items');
//console.log(items[0].sellingStatus.currentPrice.amount);
for (var i = 0; i < items.length; i++) {
console.log(items[i].title);
}
});
But getting error as
EbayClientError: Bad response status code 500 <?xml version='1.0' encoding='UTF-8'?><errorMessage xmlns="http://www.ebay.com/marketplace/search/v1/services"><error><errorId>5014</errorId><domain>CoreRuntime</domain><severity>Error</severity><category>System</category><message>Error reading from XML stream: Unexpected character '@' (code 64) in content after '<' (malformed start element?).
at javax.xml.stream.SerializableLocation@a550a55</message><subdomain>Comm_Recv</subdomain><parameter name="Param1">Unexpected character '@' (code 64) in content after '<' (malformed start element?).
at javax.xml.stream.SerializableLocation@a550a55</parameter></error></errorMessage>
at Request._callback (/home/user/node_modules/ebay-api/lib/xml-request.js:151:23)
at Request.self.callback (/home/user/node_modules/request/request.js:200:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/home/user/node_modules/request/request.js:1067:10)
at emitOne (events.js:101:20)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/home/user/node_modules/request/request.js:988:12)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
Please suggest me on this.
Is it possible to make the API call to the "GetMemberMessages" end point.
This is the error I get:
{ '$': { xmlns: 'urn:ebay:apis:eBLBaseComponents' },
Timestamp: '2017-05-04 18:45:55',
Ack: 'Failure',
Errors:
{ ShortMessage: 'Unsupported API call.',
LongMessage: 'The API call "GetMemberMessagesRequest" is invalid or not supported in this release.',
ErrorCode: '2',
SeverityCode: 'Error',
ErrorClassification: 'RequestError' },
Version: '775',
Build: '18007281' }
Params I am using:
params: {
"WarningLevel":"High",
"MailMessageType":"All",
"Pagination":{
"EntriesPerPage":"100",
"PageNumber":"1"
}
}
Unhandled rejection Error: Sandbox endpoint for Analytics service not yet implemented.
How can we solve this part issue in the library?
Hello. I need to use this method.
http://developer.ebay.com/devzone/finding/callref/findItemsByProduct.html
<productId type="string"> ProductId (string) </productId>
I don't know how to insert attribute "type" in xml tag. Please, help.
This example if followed will not authenticate, requires additional fields: https://github.com/benbuckman/nodejs-ebay-api/blob/master/examples/Finding-FindItemsByKeywords.js
If you try to pass a params object that has a nested object inside it, the xml serialization doesn't work properly.
{code}
params : {
authToken : 'AuthToken',
ItemID : 'itemId',
// 'CreateTimeFrom' : '2013-10-13T00:00:00.0',
// 'CreateTimeTo' : '2013-10-27T00:00:00.0',
MemberMessage :
{
Body : ['Hello,',
'There'].join('\n'),
QuestionType: 'General',
RecipientID : 'ReceipientId',
Subject : 'My Store'
}
}
{code}
The XML you get in this case doesn't include the contents of MemberMessage and you get . That's it.
(this is an example trying to use the AddMemberMessageAAQToPartner eBay API Method to send an ebay message to a buyer (http://developer.ebay.com/Devzone/XML/docs/Reference/eBay/AddMemberMessageAAQToPartner.html)
Is this possible with this API?
I have tried this but I get a 503 error:
getCategories(){
const params = {
q: this.keywords.split(/\s+/),
category_tree_id: this.categoryId
};
return new Promise((resolve, reject) => {
this.client.xmlRequest({
serviceName: 'Taxonomy',
opType: 'getCategorySuggestions',
appId: this.appId,
params,
parser: this.client.parseResponseJson
}, (err, res) => {
if (err) {
return reject(err);
}
resolve(res);
});
});
}
I put a breakpoint on xml-converter.js, and the xmlBody is passed in correctly, but somewhere it will drop all the notificationEnable entries
raw xml received from ebay
<?xml version="1.0" encoding="UTF-8"?>
<GetNotificationPreferencesResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2016-10-03T03:22:21.880Z</Timestamp>
<Ack>Success</Ack>
<Version>967</Version>
<Build>E967_CORE_APINOTIFY_18003059_R1</Build>
<UserDeliveryPreferenceArray>
<NotificationEnable>
<EventType>EndOfAuction</EventType>
<EventEnable>Disable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>AuctionCheckoutComplete</EventType>
<EventEnable>Enable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>Feedback</EventType>
<EventEnable>Disable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>FixedPriceTransaction</EventType>
<EventEnable>Enable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>ItemListed</EventType>
<EventEnable>Disable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>MyMessagesM2MMessage</EventType>
<EventEnable>Disable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>BidReceived</EventType>
<EventEnable>Disable</EventEnable>
</NotificationEnable>
<NotificationEnable>
<EventType>FeedbackReceived</EventType>
<EventEnable>Enable</EventEnable>
</NotificationEnable>
</UserDeliveryPreferenceArray>
</GetNotificationPreferencesResponse>
after conversion
{
"$": {
"xmlns": "urn:ebay:apis:eBLBaseComponents"
},
"Timestamp": "2016-10-03T03:22:21.880Z",
"Ack": "Success",
"Version": "967",
"Build": "E967_CORE_APINOTIFY_18003059_R1",
"UserDeliveryPreferences": []
}
I see that the master branch has stopped using restler and is now using request. However, this branch doesnt appear to have made it to npm. The package.json file declares 0.1.1, which is the package version I currently have...however the npm still has the outdated restler module (old branch?).
I will fork this module for now and then npm link to it locally...but I do not believe npm has the most recent version of your library. Let me know if I am mistaken or just missing something.
I can only seem to get one gallery image. Is it possible to get all the images back? or at least a few?
This is my code snippet that calls the function:
ebay.ebayApiPostXmlRequest({
serviceName: 'Trading',
opType: 'GetOrders',
devName: 'mobisoft',
....},function(error, results) {
if (error) {
console.dir(error);
process.exit(1);
}
res.send(getAddresses(results.OrderArray.Order));<--line 39
});
In my callback function I call res.send(...), this function is being triggered twice from ebay-api/index.js:417:7 which caused this exception.
It looks like the second one was triggered upon receiving response 304 but I cannot decrypt the https traffice.
< http.js:689
< throw new Error('Can't set headers after they are sent.');
< ^
< Error: Can't set headers after they are sent.
< at ServerResponse.OutgoingMessage.setHeader (http.js:689:11)
< at ServerResponse.header (/Users/brucexia/nodejs/ebayhelper/node_modules/express/lib/response.js:662:10)
< at ServerResponse.json (/Users/brucexia/nodejs/ebayhelper/node_modules/express/lib/response.js:232:10)
< at ServerResponse.send (/Users/brucexia/nodejs/ebayhelper/node_modules/express/lib/response.js:134:21)
< at module.exports (/Users/brucexia/nodejs/ebayhelper/routes/orders.js:39:13)
< at request.on.error.message (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/index.js:417:7)
< at parseData (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/index.js:411:9)
< at async.iterator.fn (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/node_modules/async/lib/async.js:517:34)
< at async.waterfall.wrapIterator (/Users/brucexia/nodejs/ebayhelper/node_modules/ebay-api/node_modules/async/lib/async.js:441:34)
< at process._tickCallback (node.js:419:13)
Hi,
It seems that the Finding and Product URLS are currently using HTTP while HTTPS is now supported. I've created a branch with the requeired changed by was unable to push it to origin due to the following. It would be great to have this included.
remote: Permission to benbuckman/nodejs-ebay-api.git denied to dietkinnie.
Best regards,
dietkinnie
Hi,
In the Trading API GetOrders call there is an input parameter: IncludeFinalValueFee if you send this with true value the FinalValueFee should be in the response according to the eBay API documentation and the ebay scratchpad call but I don't seem to find it in our response the FinalValueFee parameter that should be there. Do you know what could be the issue?
Thank you for your help in advance.
Hi,
when trying to submit a product to ebay you have to specify the urls of the picturesyou want to add and they'r placed in a xml PictureUrl tag. Because all the xml tags have the same name there's a issue when you try to add more than 1 picture to the json (you actully override the previouse one).
Is there anyway to fix this issue without adding xml tags manualy?
There is a bug in the version of restler that this module utilizes. This thread provides a good look into the issue and how it was solved angular-app/angular-app#125.
This issue originally manifested itself when I would make a request to ebay, send a response back and then make another request and attempt to send another response which would then throw the error "Cant set headers after they are sent.".
Here is the original fix: QuePort/restler@d44d126
Restler has committed the fix and is functioning as expected.
Thanks for the great job on eBay API.
AFAIK you are converting JSON objects into node-xml formats, while the json2xml object format is more friendly to pure JavaScript coders.
Could even skip the _(params).each
loop to convert things. ;)
Hi, I'm new to coding and building a school project that connects to ebay trading. Keep trying to formulate an ebayApiGetRequest with this package but I always seem to run into this error after sending the request.
[SyntaxError: Unexpected token <] .
I've taken out lines individually and it seems to occur whenever I add my personal app id. Project wide search yielding no help. Are there any known issues/conflicts?
I'm a wee bit stuck and getting a bit tired of trying this and that, so I thought I'd ask the community.
If I'm building something that would change the country being searched per request, can I do something like the following?
var filters = {};
filters.ItemFilter = [
new ebay.ItemFilter("ListingType", "FixedPrice"),
new ebay.ItemFilter("AvailableTo", "AU")
];
var reqOptions = {};
reqOptions["X-EBAY-SOA-GLOBAL-ID"] = "EBAY-AU";
ebay.ebayApiGetRequest({
serviceName: 'FindingService',
opType: 'findItemsByProduct',
appId: credentials.prod.ebay.appId,
params: params,
filters: filters,
reqOptions: reqOptions,
parser: ebay.parseItemsFromResponse
},
// gets all the items together in a merged array
function itemsCallback(error, items) {
// handle it
}
);
Keeping track of TODOs following the refactor and 1.x release:
flatten
methodI always get the above error no matter if I use my production or sandbox keys. I also tried to add devId
and certId
.
Code:
inspect = require('eyespect').inspector({maxLength: null})
chalk = require('chalk')
ebay = require('ebay-api')
ebayConfig = require('../config/ebay.config.js')
appId = ebayConfig.getAppKey('AppID')
console.log appId
exports.getItems = (appUser, searchTerm, callback)->
options = {}
options.appId = ebayConfig.getAppKey('appId')
options.devId = ebayConfig.getAppKey('devId')
options.certId = ebayConfig.getAppKey('certId')
options.serviceName = "Finding"
options.opType = "findItemsAdvanced"
params = {
keywords: ["Canon", "Powershot"],
#add additional fields
outputSelector: ['AspectHistogram'],
paginationInput: {
entriesPerPage: 10
},
itemFilter: [
{name: 'FreeShippingOnly', value: true},
{name: 'MaxPrice', value: '150'}
],
domainFilter: [
{name: 'domainName', value: 'Digital_Cameras'}
]
}
options.params = params
inspect options #the appId, devId and certId are displayed correctly
ebay.xmlRequest(options, callback)
Error Msg:
{"err":{"name":"EbayClientError","message":"Bad response status code 500 <?xml version='1.0' encoding='UTF-8'?><errorMessage xmlns=\"http://www.ebay.com/marketplace/search/v1/services\"><error><errorId>11002</errorId><domain>Security</domain><severity>Error</severity><category>System</category><message>Authentication failed : Invalid Application: MYAPPID</message><subdomain>Authentication</subdomain><parameter name=\"Param1\">Invalid Application: MYAPPID</parameter></error></errorMessage>"}}
@benbuckman I have created another node module ebay-node-api for my personal use. But now I have open sourced. I think both repo serve the same purpose so we can merge both repo. If you are interested, you can transfer this repo and I can manage it.
ebay-api.ebayApiGetRequest({
serviceName: 'Trading',
opType: 'GetCategories',
appId: "xxx",
params: {
},
parser: ebay.parseItemsFromResponse
},
function allItemsCallback(error, items) {
console.error(error);
console.log(items);
}
});
I get this error:
[SyntaxError: Unexpected token <]
Is anyone else using webpack?
Has anyone successfully setup their eBay Partner Network to work with this library? Reading the docs it seems like a minefield.
Cheers
var xmlBody contains a xml request with a wrong syntax.
The ItemId it's wrong. The correct identificator is ItemID.
Would be nice to have a simple method or property that contains an ebay affiliate rover link
Here's is the manual link generator tool all it needs is a product id input:
https://epn.ebay.com/tools/link-generator
also found this...looks like there is an endpoint to generate an affiliate link?
http://developer.ebay.com/devzone/guides/ebayfeatures/Basics/eBay-AffiliateTrackingConcepts.html
I started using the current master branch that utilizes the request module...however I started having code failing giving me the error
{
"EBayTime": "2014-10-03 18:43:44",
"Errors": {
"Error": {
"Code": "2",
"Column": "0",
"ErrorClass": "RequestError",
"Line": "0",
"Severity": "SeriousError",
"SeverityCode": "1",
"ShortMessage": "Unsupported verb."
}
}
}
After fooling with this for a few hours and ensuring that everything was going to ebay as they expected...I reviewed the code around utilization of request.
In the ebayApiPostXmlRequest function there is an object called options.reqOptions which contains data
for the xml body and headers
for the request headers. However, when it is handed off to the request module the options.reqOptions
is passed into the request headers
parameter...which is incorrect
current (i assume broken?)
var request = requestModule.post({'url': url, 'headers': options.reqOptions}, function(error, response, result) {
working (assume fix?)
var request = requestModule.post({'url': url, body: options.reqOptions.data, 'headers': options.reqOptions.headers}, function(error, response, result) {
Hope this helps anyone that has seen this issue..
The module is trying to be smart in converting the input JSON params to XML.
See deep-to-array.test.js and xml-request.test.js.
So given an input param thing: ['a', 'b', 'c']
, it converts that to
<thing>a</thing>
<thing>b</thing>
<thing>c</thing>
But if we want to do something like,
<OrderIDArray>
<OrderID>aaaa</OrderID>
<OrderID>bbbb</OrderID>
</OrderIDArray>
This doesn't seem currently possible.
Should the module try to stay smart, and somehow differentiate these? Or should the input param structure simply follow the xml
module's pattern without conversion?
Like all platform API, old versions are likely to be deprecated from time to time, forcing the library author (you) to update the code just to keep the thing useful.
It would be best to allow specifying versions, along with version-specific opType handlers in params.
I can make a pull request in a week or two if you don't wanna bother with it. ๐
how can i use the "single" example to be shown in the browser and not in the console log?
Hello.
i want to specify a site ID (e.g 71 for france), usually i would put it the header of the xml request (X-EBAY-API-SITE-ID), but with the xmlRequest method i didn't manage to do that. The call returns me the data according to the default site ID = 0 (US).
here is my code:
const ebay = require('ebay-api');
const options = {
serviceName: 'Trading',
opType: 'GeteBayDetails',
devId: ebayApiCredentials.devId,
certId: ebayApiCredentials.certId,
appId: ebayApiCredentials.appId,
authToken: btas.token,
params: {
DetailName: detailName
},
reqOptions: {
headers: {
'X-EBAY-API-SITE-ID': btas.siteID
}
}
};
ebay.xmlRequest(options, (error, data) => {
return resolve(data);
});
i have tried also to insert it like this
reqOptions: {
headers: {
siteid : btas.siteID
}
and also just in the body.
thanks!
Hi
The API is Awesome !
I had one problem when trying to add a nested repeatable field.
e.g. GetOrders where I want to get a single order identified by it's OrderID ( ItemID - TransactionID).
This sits in an OrderIDArray element.
So should look like this
The code in index.js was passing the object directly and not as an array.
It may be the way I passed it in the first place but I tried the example line in index.js and it failed.
So I modified my index.js for the ebay-api slightly
This the array I am passing in from my Router app.js
var OrderIDArray = [];
var Orderelem = [{'OrderID' : orderID}];
params: {
'authToken': app.get('authToken'),
'OrderIDArray' : Orderelem
}
Line 158 ish in ebay-api index.js
// for repeatable fields, use array values.
// to keep this simpler, treat everything as an array value.
(params).each(function(values, key) {
if (!.isArray(values)) {
values = [values];
};
_(values).each(function(value){
var el = {};
// Added this to convert the json string to an array, in a similar way to the array test above.
if (_.isObject(value)) {
value = [value];
};
el[key] = value;
top.push(el);
});
});
As I stated, it may be me. However, just in case this helps anyone else.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.