Reputation: 786
I am trying to get all products from a user's ebay account, but when I run my code I am only getting a few hundred. I can confirm there are 2 000 products.
How can I pull all products without using the start and end time and date parameters?
If I remove the lines of code with the <StartTimeFrom>
to <EndTimeTo>
it shows no products at all.
$url = 'https://api.ebay.com/ws/api.dll';
$user_name = "{username is in here}";
$auth_token = "{token is in here}";
for ($i = 1; $i <= 10; $i++) {
$headers = array(
'Content-Type: text/xml',
'X-EBAY-API-COMPATIBILITY-LEVEL:877',
'X-EBAY-API-DEV-NAME:177b0624-2d99-428a-8659-7404d9043c76',
'X-EBAY-API-APP-NAME:PeteNayl-d415-49bb-a950-495237441c1c',
'X-EBAY-API-CERT-NAME:6c336965-1a1f-4d11-94b1-3843c3ac995b',
'X-EBAY-API-SITEID:3',
'X-EBAY-API-CALL-NAME:GetSellerList'
);
$xml = '<?xml version="1.0" encoding="utf-8"?>
<GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>'.$auth_token.'</eBayAuthToken>
</RequesterCredentials>
<Pagination ComplexType="PaginationType">
<EntriesPerPage>200</EntriesPerPage>
<PageNumber>'.$i.'</PageNumber>
</Pagination>
<StartTimeFrom>2014-06-01T21:59:59.005Z</StartTimeFrom>
<StartTimeTo>2014-06-02T21:59:59.005Z</StartTimeTo>
<EndTimeFrom>2014-09-29T21:59:59.005Z</EndTimeFrom>
<EndTimeTo>2014-09-30T21:59:59.005Z</EndTimeTo>
<DetailLevel>ItemReturnDescription</DetailLevel>
<UserID>'.$user_name.'</UserID>
</GetSellerListRequest>';
...
Upvotes: 4
Views: 7197
Reputation: 1605
Paging mechanism.
I came across the same problem.
To solve it I built a paging mechanism that starts at a particular EBAY_START_DATE, and loads 120 days worth of Products at a time. The date in question is based on the eBay Item's StartTime.
Here is the pseudo code
from_date = EBAY_START_DATE
while from_date < NOW:
to_date = from_date + 120 DAYS
call GetSellList (from_date, to_date)
Do something with the data
from_date = from_date + 120 DAYS
Here is the actual implementation in python. The code also calls GetItem to get the full data on each item. This code used Tim Keefer's excellent ebaysdk.trading library to make the calls.
def getProducts(self):
products = []
# loop thru seller list 120 days at a time
from_date = str2datetime(EBAY_START_DATE + ' 00:00:00')
while from_date < datetime.now():
# get seller list
to_date = from_date + timedelta(days=120)
request = {'StartTimeFrom': from_date, 'StartTimeTo': to_date}
resp = self.ebayApi.get('GetSellerList', request)
# get each product
if resp.reply.ItemArray:
items = resp.reply.ItemArray.Item
if not isinstance(items, list):
items = [items]
for item in items:
item_id = item.ItemID
request = {'ItemID': item_id}
resp = self.ebayApi.get('GetItem', request)
products.append(resp.dict()['Item'])
from_date = from_date + timedelta(days=120)
return products
I hope this is helpful. :-)
Upvotes: 0
Reputation: 875
I had this problem but I finally got the simple solution. The time range just shouldn't be set greater than 120 days apart. You can start from whatever year and month you want, as long as the the values shouldn't exceed 120 days between them. For instance, the query below returns the items from 2016.
<?xml version="1.0" encoding="utf-8"?>
<GetSellerListRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>High</WarningLevel>
<GranularityLevel>Coarse</GranularityLevel>
<StartTimeFrom>2016-03-21T06:38:48.420Z</StartTimeFrom>
<StartTimeTo>2016-07-15T06:38:48.420Z</StartTimeTo>
<IncludeWatchCount>true</IncludeWatchCount>
<Pagination>
<EntriesPerPage>2</EntriesPerPage>
</Pagination>
</GetSellerListRequest>
Upvotes: 1
Reputation:
You cannot send a request without a time range and that the period between the from and to cannot exceed 120 days. If you want to pull all the products back you are going to have to make multiple requests to GetSellerList where each request covers a particular 120 day period.
Information can be found in the eBay documentation for the both the EndTimeFrom and StartTimeFrom fields in the request. Note that the documentation does not say that the fields are required, but it you do not include them in your request a Failure value will be returned in the Ack field of the response.
Upvotes: 7
Reputation: 1506
Take a look at the official ebay doc you just have to adjust your paramters according to bold marked section below :)
GetSellerList
Use this call to retrieve items listed by the authenticated user, including item data.
GetSellerList returns an array of zero or more items, depending on the user's activity and the inputs used in the call. Input fields can increase or filter the data returned. See Browsing a Seller's Items for a detailed description of retrieving items using GetSellerList.
Usage Details In all calls, at least one date-range filter must be specified.
You can specify a DetailLevel to control the response data. If you set a DetailLevel, you must set pagination values.
GetSellerList returns a maximum of 5,000 items per call (this is possible if you do not specify a Detail Level, and thus return the smallest set of data for each item). However, if you specify any DetailLevel value (and thus increase the fields returned for each item), you might need to use Pagination values to obtain the complete result set. If you use a DetailLevel, the response can contain no more than 200 items per call.
Many item details (such as item descriptions and listing enhancements) don't change often, and getting these values adds to the overhead of your calls. After you initially download the details for a set of items, subsequent requests for those items should retrieve only the item information that is likely to change. It is best to avoid using a DetailLevel of ReturnAll or a GranularityLevel of Fine with GetSellerList. Or consider using GetSellerEvents instead of GetSellerList.
If you need to use ReturnAll to retrieve all the item details, use a smaller EntriesPerPage value to limit the number of items returned from the call. To improve performance, specify a shorter time range with EndTimeFrom and EndTimeTo.
You can specify either a DetailLevel or a GranularityLevel in your request, but not both. See Specifying Detail Levels and Granularity Levels for more information about detail levels.
Use Pagination to control the pages of data returned. The Pagination.EntriesPerPage field controls how many items are returned per call, and Pagination.PageNumber specifies which page of data to retrieve in the current call. The value specified for EntriesPerPage must be between 1 and 200.
You can use multiple date-range filters in the same call. For example, you can use StartTimeFrom and StartTimeTo if you want the response to contain listings that started between the two times. Use EndTimeFrom and EndTimeTo to return listings ending between the two times.
Working with the Response GetSellerList returns a list of the sellers items in an ItemArray container.
The response data contains ItemType objects, within the ItemArray. Each ItemType object contains the data for a listing. Store the item data needed by your application. In the output, the ReturnedItemCountActual property indicates how many items were returned by the call; Count indicates how many items could be returned. HasMoreItems, if true, indicates that there are more items to be returned, requiring one or more additional calls. PageNumber indicates the page of data returned and ItemsPerPage indicates the number of items returned per call.
Testing GetSellerList You can test this call in the Sandbox environment after you use AddItem to add at least two items.
Some values are only returned if the call requestor is the seller of the item. To test the call from the perspective of another user, call GetSellerList with a user other than the one who listed the item.
For applications that list different types of items (such as Chinese auctions and fixed-price items), create all possible types of listings using AddItem, then attempt to retrieve the data with GetSellerList.
If applicable to the application's use cases, list test items with flat and calculated shipping rates. Then retrieve the items with GetSellerList.
For applications that create competitive-bid item listings (Chinese auctions), bid on the items using the Sandbox user interface before retrieving the item using GetSellerList. This will populate the high bidder data for items in the result set.
Test calls to GetSellerList with different combinations of detail level, pagination, and date-based filtering to cover all of the possible scenarios the application might have to accommodate under real world conditions.
I'll hope I could help you.
Upvotes: 2