question

lillitronics avatar image
0 Likes"
lillitronics asked ·

eBay API returning data inconsistently - sometimes missing items

Hello everyone :-) I have a problem and hope that somebody can help me with it. I have written some code which displays eBay items that meet certain search requirements. The search criteria is very strict so only 2 listings are left (which is how it should be). However, sometimes one of the items will be missing. If I refresh the page, they come back (sometimes 1 at a time, requiring 2 clicks of refresh). Sometimes it's 1 item that's not there, sometimes it's both of them. It's very strange and quite frustrating! My code is as follows: function _cb_findItemsAdvanced(root) { items = root.findItemsAdvancedResponse[0].searchResult[0].item || []; var html = []; html.push(' '); var usernames = []; var shipping = []; var price = []; var format = []; var condition = []; for (var i = 0; i < items.length; ++i) { var item = items[i]; usernames[i] = items[i].sellerInfo[0].sellerUserName; shipping[i] = items[i].shippingInfo[0].shippingType; price[i] = items[i].sellingStatus[0].currentPrice[0].__value__; format[i] = items[i].listingInfo[0].listingType; condition[i] = items[i].condition[0].conditionId; if (shipping[i] == "FreePickup") { if (price[i] < 23.01) { if (format[i] == "Auction" || format[i] == "AuctionWithBIN") { if (condition[i] != "7000" && condition[i] != "1000") { var title = item.title; var pic = item.galleryURL; var viewitem = item.viewItemURL; if (null != title && null != viewitem) { html.push(' ' + '' + '' + ' ' + title + '' + ' ' + "Current price - " + price[i] + ''); sellers[counter] = usernames[i]; counter += 1; } } } } } } html.push(' '); document.getElementById("results").innerHTML = html.join(""); } My src is: https://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=MYKEY&GLOBAL-ID=EBAY-GB&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsAdvanced&REST-PAYLOAD&outputSelector=SellerInfo&sortOrder=StartTimeNewest&categoryId=139971&keywords=(ps2%2Cplaystation%202)+(slim%2Cslimline) It seems to work when it wants to. I am fairly certain that this is a problem on eBay's end, but hope for some opinions on why this might be happening. Thank you for reading :-)
finditemsadvancedjavascripthtmldatainconsistent
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

davidtsadler avatar image
1 Like"
davidtsadler answered ·
You search request is resulting in more than two items been returned. Due to the fact that items are constantly been listed and ended you are going to see the number of returned items change every time you refresh the page. You also have to remember that by default findItemsAdvanced will only return the first page of 100 items. If there are more than 100 items they will be on multiple pages. You code is only requesting the first page and is not asking for more pages. The reason you may not be seeing the two items is that they may have moved to another page. Change you code to the following to see what I mean. function _cb_findItemsAdvanced(root) { document.write('Page number ' + root.findItemsAdvancedResponse[0].paginationOutput[0].pageNumber[0]); document.write(' Entires per page ' + root.findItemsAdvancedResponse[0].paginationOutput[0].entriesPerPage[0]); document.write(' Total number of pages ' + root.findItemsAdvancedResponse[0].paginationOutput[0].totalPages[0]); document.write(' Total number of entries ' + root.findItemsAdvancedResponse[0].paginationOutput[0].totalEntries[0]); } If you are getting a lot of unexpected items in the result I can only assume that the search criteria is to broad. Looking at you last request. http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-NAME=FindingService&SERVICE-VERSION=1.12.0&SECURITY-APPNAME=___&RESPONSE-DATA-FORMAT=JSON&callback=_cb_findItemsAdvanced&REST-PAYLOAD&outputSelector=SellerInfo&sortOrder=StartTimeNewest&categoryId=139971&keywords=%28ps2%2Cplaystation%202%29+%28slim%2Cslimline%29⁢emFilter%280%29.name=Condition⁢emFilter%280%29.value%280%29=1500⁢emFilter%280%29.value%281%29=2000⁢emFilter%280%29.value%282%29=2500⁢emFilter%280%29.value%282%29=3000⁢emFilter%281%29.name=ListingType⁢emFilter%281%29.value%280%29=Auction⁢emFilter%281%29.value%281%29=AuctionWithBIN⁢emFilter%282%29.name=MaxPrice⁢emFilter%282%29.value%280%29=23.01 I can see that you are asking for items that match the following. - Items must be in the category 139971 - Item must match any of the following conditions 1500, 2000, 2500, 3000 - Items must be either an auction or an auction with Buy It Now. - The maximum current price should be 23.01 - They should match the keywords (ps2,playstation 2) (slim,slimline) After a quick look at the items that are been returned I can see that they match the search criteria. If you can't narrow the search so that only the two items are returned you are going have to change you code to handle subsequent pages by making multiple requests to findItemsAdvanced.
· 1 · Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi @davidtsadler :-) Thank you very much for your detailed reply, it's very much appreciated! I just wonder, as my filters (always) return less than 100 items, there is only 1 page of results. Can they still move to another page? If so, how can this be?
0 Likes 0 · ·
helios825 avatar image
1 Like"
helios825 answered ·
Here's the REST URL I'm using, with the updates I talked about, and also changed they keyword character "+" to %20 for consistency. Also, I didn't bother changing the () to encoded-(), as it may actually be unnecessary, now that I've started playing with it. https://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsAdvanced&SERVICE-NAME=FindingService&SERVICE-VERSION=1.12.0&SECURITY-APPNAME=_____________&RESPONSE-DATA-FORMAT=XML&GLOBAL-ID=EBAY-GB&REST-PAYLOAD&outputSelector=SellerInfo&sortOrder=StartTimeNewest&categoryId=139971&keywords=(ps2%2Cplaystation%202)%20(slim%2Cslimline) I'm getting the first 100 of ~340 results. What about you?
· 1 · Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello again :-) I'm also getting the first 100 results, but as soon as I add my if statements to refine the results, the same thing happens :-( Maybe the same thing is happening before, but as there are so many results it's hard to see it happening. I have tried everything I can think of, I just don't understand it. Sometimes, it will work perfectly for 10 page refreshes in a row and then all of a sudden one item will go, only to come back a few times later.
0 Likes 0 · ·
lillitronics avatar image
0 Likes"
lillitronics answered ·
@tony.developersupport @davidtsadler @helios825 Okay, after countless hours of testing and trying different things, I am 100% sure there is a bug within the Finding API that results in listings 'going missing' from the results, only to come back again a minute later. There are less than 100 results, so it is definitely not a case of an item jumping to a different page and then back again. As my search is so specific, the number of results should remain the same (or at least very similar, in case of a listing ending or being made). Here is a link to a live eBay site search, which returns 93 items at time of writing: http://www.ebay.co.uk/sch/Consoles-/139971/i.html?_from=R40&LH_Auction=1&_nkw=%28playstation%202%2C%20ps2%29%20%28slim%2C%20slimline%29&_dcat=139971&rt=nc&_pppn=r1&LH_ItemCondition=1500|2500|3000&_udlo&_udhi=23.01 My code, included below, should return exactly the same number of items...which it does fairly often but is certainly not reliable (as demonstrated in my comments above). Please try my code - if it writes the same number 10 times, it is behaving as expected (which it sometimes does!). However, please try running it again either immediately afterwards or a bit later and you will almost certainly see what I am talking about. The reason I am calling the URL 10 times in a row is so the problem can be reproduced more quickly. PLEASE support me and help to identify/confirm the problem. I would submit a bug, but every time I try it just takes me to the support centre where you have to buy an hour of support for $75! So I really, really hope a member of the appropriate eBay team can read this somehow! :-)
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lillitronics avatar image
0 Likes"
lillitronics answered ·

If I copy and paste the src URL 10 times, this is the result:

Total number of entries 89 Total number of entries 93 Total number of entries 85 Total number of entries 93 Total number of entries 93 Total number of entries 85 Total number of entries 85 Total number of entries 93 Total number of entries 83 Total number of entries 79
· 2 · Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Can you clarify if you are expecting the search request to only return the 2 items when pasting the URL into the address bar? Or are you expecting multiple items to be returned which you will then pass to your code to iterate through and locate the two that you are interested in?
0 Likes 0 · ·
For this particular request, I am not only expecting 2 items - I removed (if shippingType == "FreePickup") which is the filter that narrows it down to 2 items. I am expecting 93 items, which it only comes back with approximately half the time as above :-) Just to make sure, here is a screenshot of a live eBay site search: http://imgur.com/e5CjAGk 93 items, with the next one set to end in 4 hours (so the number should only go up or stay the same until then, it should never be 85, 83 or 79).
0 Likes 0 · ·
lillitronics avatar image
0 Likes"
lillitronics answered ·

This just says everything! Watch the number jump about all over the place (it went randomly between 74 and 92 in the few times I refreshed!):

· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lillitronics avatar image
0 Likes"
lillitronics answered ·
If you copy and paste this in to a blank HTML file (and edit AppID!) you should see what I mean. If you refresh the page, more often than not one or both sellers disappear!
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lillitronics avatar image
0 Likes"
lillitronics answered ·
Hi @helios825 :-) Firstly, thank you! I'm so glad somebody is willing to help! So you're getting different results just by using XML instead of JSON? Even with all my filters and "&GLOBAL-ID=EBAY-GB"? That within itself seems strange, but at least hopefully suggests it's a problem on my end (or a problem I can overcome). I did try to update the SERVICE-VERSION before and since, but it didn't seem to make any difference. I have changed it back to '1.12.0' since posting though. I didn't even know about adding "&SERVICE-NAME=FindingService" so thank you for that :-) I have swapped "( and )" for "%28 and %29), I hope I've done it right (it still works so I think I have!). I have now noticed something else - I changed everything from "findItemsAdvanced" to "findItemsByKeywords" and still get 2 results. However, 1 of them is a completely different listing! The listing meets my criteria, so I just don't understand why it's not showing up in both "findItemsAdvanced" and "findItemsByKeywords". Do you know why? :-)
· 1 · Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Actually I've just realised one of the items was coming through because it was in the wrong category (when findItemsByKeywords doesn't deal with categories). I'm still not sure why the one that did come through in 'findItemsAdvanced' didn't come through in 'findItemsByKeywords' though! Also, I tried to convert my 'answer' in to a comment but so far it hasn't changed. Sorry about that.
0 Likes 0 · ·
helios825 avatar image
0 Likes"
helios825 answered ·
I don't work with JSON, so I did a quick test and changed to XML and removed the callback param. I get dozens of results in my XML response, so I wasn't able to replicate the same just-2 results. Quick things to update before testing any more: get your SERVICE-VERSION current and add &SERVICE-NAME=FindingService to your call. In other words, don't give the API any reason to balk at you by having all of your basic parameters present and current. Also try URL encoding the parentheses in your keywords, as that may help.
· Share
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.