Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Build a marketplace with the eBay SDK and web services, Part 1

List items for sale on eBay

Rob Chappelle (rob@robnsarah.com), Managing Partner, Arpeggio Consulting
Rob has been programming since he was 8 years old. He went through the dot-com boom and bust, and he was even around back when Archie was the way you searched for something. In those days, google was just a weird number. He has worked on various Web services applications for the last several years. He co-owns Arpeggio Consulting with his wife, Sarah. They reside in Seattle, Washington.

Summary:  Get your own marketplace started with the help of the eBay SDK and web services. Over forty percent of eBay's listings come through API calls. eBay now has Windows and Java SDKs to wrap those APIs, making it even easier for you to build custom applications to access the eBay marketplace. This first paper in a series shows you how to list items for sale on eBay.

Date:  15 Oct 2004
Level:  Intermediate
Also available in:   Japanese

Activity:  7936 views
Comments:  

eBay web services

eBay is a great place to buy and sell stuff. But, if you're like me and have boxes of stuff sitting around labeled sell on eBay, they've probably been sitting around for quite a while. It just seems like too much work to go to the web site and create a listing for each one of those different items. The eBay listing interface is great for listing one item at a time. I've often wished, though, that I could just enter information about my items into a spreadsheet or database and somehow have those items automatically listed on eBay.

That's where eBay's web services come in. Fortunately for me, eBay has web services that provide easy access to the eBay marketplace. There is an XML API that uses XML documents sent across HTTPS, which has been available since 2000. And, earlier this year, they released a SOAP API that uses SOAP and WSDL to specify an eBay schema that simplifies access to the eBay platform. Both of these APIs use eBay's web services and provide access to the same functionality and data. They make it easy to build custom applications interfacing with eBay.

The power of the API is apparent in the fact that over 40% of eBay's listings now come through API calls.

To make it even easier to build custom applications using eBay's web services, eBay provides 2 SDKs to wrap their APIs, giving you the choice of whether to develop in Windows using .NET or in native Java language. The eBay SDK is a powerful, flexible, and ridiculously easy-to-use toolkit for interfacing directly with eBay. Before the SDK, you had to format your own XML to make eBay API calls, but it was still a powerful way to access eBay's database.

For several years there was only an eBay SDK for Windows, but now there is also an eBay SDK for Java technology. The SDK for Windows encapsulates the XML API, and the SDK for Java technology encapsulates the SOAP API. They both provide you with easy-to-use objects to wrap the XML/SOAP API calls to eBay. All other languages can still make API calls directly and have the same access to the eBay web services.

Figure 1 illustrates eBay's web services architecture.


Figure 1. eBay web services architecture
eBay web services architecture

Get started

In order to use eBay's web services you must join the eBay Developers Program, so the first step is to set up your account at eBay.

You can sign up for a free Individual account, or a fee-based Commercial account, depending on your needs. The current fees are listed in Table 1. For full, up-to-date pricing information see membership services and fees at eBay.


Table 1. eBay Developers Program fees
IndividualBasicProfessionalEnterprise
API
License type Individual Commercial Commercial Commercial
API calls included 50 per day 30,000 Per month None None
Fees
Annual membership fee Free $500 $1,000 $5,000
Monthly API usage fee None $2.90 per 1,000 over 30,000 limit $1.60 per 1,000 $1.25 per 1,000
Certification fee (per application) $100 $200 $200 Included (1 per year)

Note that "API calls included" refers to calls other than AddListItem and ReListItem, both of which are always free.

The Developers Program account activation happens instantly, with the security keys to use the Sandbox test environment arriving by email within 12 hours.

Once your account is setup, you will be able to download and install the eBay SDKs, as well as have access to a lot of useful developer information. You can use either the Windows version or the Java technology version SDK.

The version of the eBay SDK to use will mainly be determined by the language you are using to develop your application. They both provide very similar sets of objects as well as the same functionality and data. The primary difference is that the Windows version stores items in a local integration database, and then sends the entire set of items to eBay's database when you synchronize. In the Java version, each call is done directly to eBay in real-time, with no integration database.

Once you have your security keys, you need to set up test users in order to test your application in the Sandbox. This is also very quick and all you have to do is follow the instructions on eBay.


List an item

Now that you're setup to test your application, let's walk through listing an item using the SDK.

Table 2 shows a list of some of my items. The data could easily be in a simple text file, a spreadsheet, or a database and be created by a variety of applications. Assume that, whatever the implementation, the application appropriately parses the data and makes it available to the SDK objects through an object called MyStuff. MyStuff has a property corresponding to each column heading, such as MyStuff.Description for the Description. The code samples below assume this object exists.


Table 2. Sample items to sell on eBay
TitleDescriptionLocationCategoryIDStart PriceBuyItNow PriceDuration
Code Complete book Great book by Steve McConnell, good condition. Seattle, WA 2228 $10.00 $25.00 7
TiVo TiVo with 10 hours of recording time. Works great. Seattle, WA 79865 $30.00 $75.00 7
Sony Ericsson T610 cell phone T-Mobile cell phone, excellent condition. Seattle, WA 64355 $50.00 $125.00 7

Step 1: Set up the execution environment

To set up the execution environment, create an API call context object, authenticate the requesting user, and specify the URL for the eBay web services.

Listing 1 shows you how to set up the execution environment to list a new item using AddItemCall.


Listing 1. Set up the execution environment
// Import the applicable libraries 
import com.ebay.sdk.*; 
import com.ebay.sdk.call.AddItemCall; 
import com.ebay.soap.eBLBaseComponents.*; 
import com.ebay.soap.CoreComponentTypes.AmountType; 
... 
// Create an ApiCallContext object for the call 
ApiContext apiContext = new ApiContext(); 
 
ApiCredential cred = apiContext.getApiCredential(); 
ApiAccount ac = cred.getApiAccount(); 
eBayAccount ec = cred.geteBayAccount(); 
// Authenticate the requesting user: 
// Specify the eBay SOAP server URL 
apiContext.setApiServerUrl(mServerURL);

Step 2: Define the new item

Next, define the new item and set its properties as shown in Listing 2. This example uses the object MyStuff described above.


Listing 2. Define the new item
ItemType item = new ItemType(); 
item.setListingType(ListingTypeCodeType.Chinese); 
item.setCurrency(CurrencyCodeType.USD); 
item.setCountry(CountryCodeType.US); 
item.setPaymentMethods(new BuyerPaymentMethodCodeType[] 
    {BuyerPaymentMethodCodeType.PaymentSeeDescription});
item.setRegionID("0"); 
item.setListingDuration(MyStuff.Duration); 
 
item.setTitle(MyStuff.Title); 
item.setDescription(MyStuff.Description); 
item.setLocation(MyStuff.Location); 
item.setQuantity(1); 
item.setStartPrice(new AmountType(new Double(MyStuff.StartPrice)); 
item.setBuyItNowPrice(new AmountType(new Double(MyStuff.BuyItNowPrice)); 
CategoryType cat = new CategoryType(); 
cat.setCategoryID(MyStuff.CategoryID); 
item.setPrimaryCategory(cat);

Step 3: Make the API call

The final step in adding an item is to make the API call to the web service. To make the API call follow these steps:

  • Declare a FeesType object.
  • Assign the ItemType object to the AddItemCall.ItemToAdd object.
  • Call the AddItemCall.addItem() method.
  • Store the return value of the addItem() method into the FeesType object.

Note that API calls must always be in Try. . .Catch blocks, in case there is an error.


Listing 3. Making the API Call
try { 
    // Create the AddItemCall object 
    AddItemCall api = new AddItemCall(apiContext); 
    api.setSite(siteID); 
    // Declare the FeesType object to hold the returned 
    // estimated listing fees data 
    FeesType fees; 
 
    // Make the call 
    fees = api.addItem(item); 
    // Store the fees to a database 
    ... 
} 
catch(Exception e) { 
    ... error handling ... 
} 

That's all there is to it. Those are the basics of listing items using eBay web services. There are also many other features available, such as auction management, searching, and managing feedback. See the SDK documentation (comes with SDK download) for full details.


Conclusion

The eBay SDKs let you create applications with easy access to eBay web services, whether you're a Windows developer or a Java developer. The support provided on the Developer Program web site is very helpful, and the SDK documentation is excellent. Now get out there and start making your own applications!

This is the first in a series of articles looking into practical ways to use eBay's web services, such as managing item listings, completing transactions, and managing feedback. Check back for future articles including more application examples.


Resources

  • Visit the eBay Developer Zone Home Page for general information.

  • Set up your account for the eBay Developers Program.

  • Find the best type of account for your needs by browsing the eBay Developers Program Fees.

  • Talk with other eBay developers in the eBay Developer Zone Community.

  • Download the eBay Java SDK (no charge).

  • Download the eBay Windows SDK (no charge).

  • Code samples are based on the examples in the SDK documentation (included in SDK download), which is also an excellent resource.

  • Access web services knowledge, tools, and skills with Speed-start web services, which offers the latest Java-based software development tools and middleware from IBM (trial editions), plus online tutorials and articles, and an online technical forum.

  • Browse for books on these and other technical topics.

  • Want more? The developerWorks SOA and web services zone hosts hundreds of informative articles and introductory, intermediate, and advanced tutorials on how to develop web services applications.

About the author

Rob has been programming since he was 8 years old. He went through the dot-com boom and bust, and he was even around back when Archie was the way you searched for something. In those days, google was just a weird number. He has worked on various Web services applications for the last several years. He co-owns Arpeggio Consulting with his wife, Sarah. They reside in Seattle, Washington.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and web services
ArticleID=18047
ArticleTitle=Build a marketplace with the eBay SDK and web services, Part 1
publish-date=10152004
author1-email=rob@robnsarah.com
author1-email-cc=