Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ebay FindingAPI how to find items specified within a given day range

Tags:

c#

ebay-api

I am using this code portion to find all items which are in Auction type using ebay FindingAPI . Now I want to filter those items which have been started within a specified day (e.g: 2 days) . How can I add this preference??

Check this link and preference type . Here is the code portion :

IPaginationInput pagination = new PaginationInput();

pagination.entriesPerPageSpecified = true;
pagination.entriesPerPage = 100;
pagination.pageNumberSpecified = true;
pagination.pageNumber = curPage;
request.paginationInput = pagination;

ItemFilter if1 = new ItemFilter();
ItemFilter if2 = new ItemFilter();
if1.name = ItemFilterType.ListingType;
if1.value = new string[] { "Auction" };




ItemFilter[] ifa = new ItemFilter[1];
ifa[0] = if1;
request.itemFilter = ifa;

FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


foreach (var item in response.searchResult.item)
{

    tw.WriteLine(item.viewItemURL.ToString());
    links.Add(item.viewItemURL.ToString());
}
like image 753
Quazi Marufur Rahman Avatar asked May 13 '12 20:05

Quazi Marufur Rahman


People also ask

How do I retrieve data from eBay API?

To retrieve the data for a single item, use GetItem. Doing this involves three general steps: setting up the execution environment, specifying the data to return (based on the item ID), and making the API call. Retrieving the data for a single item entails specifying the item ID for the item to return.

Does eBay have a search API?

eBay Shopping API The Shopping API provides calls to search for products and reviews, user info, and popular items and searches. It also provides data that can be used by the Finding API.

What can I do with eBay API?

Commerce APIsRetrieve account profile information for an authenticated user. Create, upload, and manage video resources. Explore, subscribe to, and process eBay notifications.

Are eBay APIs free?

Yes, eBay API is open and free, but the access to the developer account is granted only after approval, and to certain kinds of APIs – after submitting a production application process.


1 Answers

This should get you roughly what you need. Set the two dates used to compare to whatever you want.

IPaginationInput pagination = new PaginationInput();

                    pagination.entriesPerPageSpecified = true;
                    pagination.entriesPerPage = 100;
                    pagination.pageNumberSpecified = true;
                    pagination.pageNumber = curPage;
                    request.paginationInput = pagination;

                    ItemFilter if1 = new ItemFilter();
                    ItemFilter if2 = new ItemFilter();
                    if1.name = ItemFilterType.ListingType;
                    if1.value = new string[] { "Auction" };




                    ItemFilter[] ifa = new ItemFilter[1];
                    ifa[0] = if1;
                    request.itemFilter = ifa;

                    FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);


                    foreach (var item in response.searchResult.item)
                    {
                         // EDIT
                         if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow) > -1) // -1 is earlyer; 0 is same; +1 is later then
                         {
                           if (item.listingInfo.startTime.CompareTo(DateTime.UtcNow.AddDays(-2)) == -1 )
                           {
                               // You have an Item that was started between now and two days ago.
                               // Do something

                           }
                        }
                        // END EDIT

                        tw.WriteLine(item.viewItemURL.ToString());
                        links.Add(item.viewItemURL.ToString());
                    }
like image 155
SH- Avatar answered Oct 03 '22 14:10

SH-