Mining eBay Web Services
By John Paul Mueller
John Wiley & Sons ISBN: 0-7821-4339-3
Chapter One Learning about eBay Web Services
One of the most successful online businesses in the world is eBay. With 85.5 million (and growing) users, it's easily the most used Web site anywhere. Given the complex set of rules that many buyers and sellers follow, plus all of the functionality that eBay provides, it's only natural that eBay would eventually come out with a Web services package. Web services can help you automate and reduce the complexity of the tasks you perform with eBay. In short, you become faster and more accurate, while reducing the risk of a missed opportunity.
Web services are very useful, but they can also become quite confusing. In fact, of all the Web services that I've used, eBay Web Services is easily the most complex, yet well thought out, product. Fortunately, eBay understands the problems that developers could face. When other Web services leave you scratching your head trying to figure out what to do next, eBay Web Services does provide some level of help.
This chapter is your introduction to eBay Web Services. It won't show you how to write code, but it will tell you about Web services in general and eBay Web Services in specific. You'll want to read this chapter even if you already have Web services experience because eBay Web Services can be a little overwhelming at first, even with eBay's stellar support system. The documentation you get from eBay doesn't really provide a gentle introduction to the topic-that's what you get from this chapter.
You'll also get a wealth of practical information from this chapter. For example, many of you probably don't know how to set up a development system for maximum flexibility. This chapter tells you how I've set up my system and provides guidelines on how you can set up your system to make it easier to use. After all, no one wants to make the development process difficult. Part of the setup and installation process includes pointers on getting the eBay Web Services Kit and installing it on your machine.
Understanding the eBay Web Services
Whenever a new technology appears on the scene, it's important to compare it with other technologies. The comparison process often helps you decide how this new technology differs from what you used in the past and reduces problems caused by hype. The media might try to convince you that a new product or service is something completely different, when in fact it's merely an update or a new implementation of an existing technology.
Currently, there's a lot of hype about Web services that makes them sound like something new and very complex. This section of the chapter defines Web services generally, examines eBay Web Services specifically, and compares this technology to older technologies. What you'll find might surprise you because Web services are really a new implementation of an old technique.
NOTE Don't confuse new with useful. Web services are very useful because they add new functionality to an existing idea that has worked for a long time. They're also new in that they use a different process from other technologies. However, the technology itself builds on other techniques that you've already used in some way. In sum, the implementation is new, the process is useful, but the technique is the same one you've used in the past.
What Is a Web Service?
You can look at a Web service from a number of perspectives. The easiest way to view a Web service is as a means of obtaining access to information. Essentially, you ask the server for information and the server returns that information in some form. The request and the returned information normally appear in eXtensible Markup Language (XML) form. Using XML preserves the meaning behind the information, regardless of the diversity of the platforms involved, so that you receive not only the information, but understand the context in which the information is used. The "Understanding XML Basics" section of Chapter 4 tells you more about XML. All you need to know now is that you receive information in XML format.
From an eBay Web Services perspective, you request information based on any of a number of search, buy, sell, management, or comment criteria (feedback). Many of your interactions with eBay will begin with some type of search. eBay supports a number of search techniques and not every technique works well for every kind of search. Chapter 2 discusses search techniques in detail. For now, just think of the search criteria as a form of request. The request defines the kind of information you want to know and how detailed that information will be. eBay Web Services returns the information you request (when available) in a standardized format.
A Web service also performs some type of useful work. The useful work might be something as simple as interpreting your request, calculating the answer, and sending the result back. In the case of eBay Web Services, the Web service accepts your request in the form of a search string, bid for a product, upload of a new product or change to an existing product, account or other configuration, or a comment. The Web service interacts with the database through a search engine to obtain the information you requested and sends the information back to you. The search can take various forms. For example, you don't have to search all product categories-you can concentrate on just one. You might want to look for product pictures rather than text. For that matter, you might have an interest in payment or shipping options rather than a product description at first. The rest of the book shows how to perform all of these tasks. The main idea is that you can submit a variety of search request types-the request type affects the information you receive back from eBay.
The final consideration for a Web service (at least from the Web service user perspective) is that it executes on the remote machine, not on your machine. In short, this means you're using resources on that other machine with the permission of the machine's owner. The remote machine can set requirements for using the Web service, as well as require you to perform specific setup and security checks as part of your request. In the case of eBay Web Services, you need to obtain this permission by requesting a license. You also need to download the eBay Web Services Kit to ensure you follow the terms of the licensing agreement. The "Downloading and Installing the Kit" section of this chapter tells how to obtain the required permission and what this permission means to you.
TIP You may find that eBay Web Services is so indispensable that you'll want to work with Web services from other vendors. For example, Microsoft supports the MapPoint Web Service (microsoft.com/mappoint/net/). In time, standards organizations will set up directories of these Web services that you can access with ease. In the meantime, you can search for companies that offer Web services using the Web Services Finder page at 15seconds.com/WebService/. Some people have problems using the Web Services Finder; it might produce an error instead of presenting a list of Web services. In some cases, you'll need to use a specialty Web service list such as the one at flash-db.com/services/. The Web services on this site are special because many of them perform one task well, such as providing you with a location based on a domain name.
How Do Web Services Work?
Many people fear new technology because they don't understand how it works, and many of those who do know how it works enjoy the mystique of knowledge too much to share it with anyone else. Web services are actually quite easy to understand if you look at them in a way that relates the task to everyday occurrences. For example, you might compare the operation of a Web service to making a withdrawal at the bank-the process really is the same. The one thing to remember is that the process a Web service uses to perform a task is always the same. No matter what technology you use to make a request or receive a response, the steps are still the same. Here are the steps that most Web services, including eBay Web Services, use to complete a transaction.
1. The client discovers the Web service. During the act of discovery, the client might do things like download a file that tells how to interact with the Web service. This step is the same as someone walking into the bank. The person knows the bank exists and the bank teller might have noticed the person. The bank posts the rules for making a withdrawal or the teller might help a first-time customer understand the rules.
2. The client makes a request based on the rules delivered during the discovery phase. The rules might specify that the request has to appear in a certain form and the client must provide specific data. This step is the same as the person walking up to the teller's window with a withdrawal request. The request must contain the person's account number, the amount they wish to withdraw, and other identifying information. The bank specifies the format of the request and the information it must contain.
3. The server might ask the client for credentials depending on the openness of the Web service. eBay Web Services is public but still requires that you supply a developer license (account) number as identification. This step is the same as the bank teller asking you for a driver's license or other form of identification before honoring your withdrawal request.
4. The Web service performs the work required to honor your request. In most cases, the Web service accesses a database for information, it could enter an order, and it might even provide some level of formatting information about the original information (such as the typeface used for a word-processed document). eBay Web Services performs a number of tasks depending on the request you make. The easiest request is a general search, but you can also perform checks such as learning about a buyer or seller. This step equates to the bank teller getting the money from the drawer and counting it.
5. The Web service sends the data to the client. The content of the information depends on the Web service. eBay Web Services provides data in a very specific format based on the content of the associated database and the nature of the request. This step equates to the teller handing the person their money. In general, the teller orders the money in a specific way and counts it out to the person, rather than simply handing the money over.
6. The client logs out of the Web service or the Web service disconnects the client after some period of inactivity. This step equates to the person leaving the bank, money in hand. If the person doesn't leave the bank (they just hang out in the lobby), you can be sure that someone will ask them to leave.
7. The client does something with the data it receives. In many cases, it formats the data and presents it on screen for the user. This step equates to the person spending the money they receive from the bank.
You can add any amount of complexity needed to the individual steps, but these seven steps define the process every Web server follows. When you break a Web service down into these seven steps, the process that used to appear as magic suddenly becomes quite doable. Chapters 6 through 11 are essentially options you can use to perform these seven steps using different technologies. This book explores the seven steps using various languages and platforms-eBay Web Services makes information available to just about anyone who needs it. However, it's important to remember that everything comes down to a client making a request and the Web server returning data.
TIP You don't have to be a programmer to work with eBay Web Services. In fact, Chapters 6 and 7 are specifically designed for people who want to automate tasks without developing extensive programming skills. Of course, you can do a lot more with eBay as you learn some programming techniques.
Considering the Usage Requirements
There's no free lunch. Some people would have you believe that the Web service does everything for you and that the client does nothing at all. However, the client interacts with the Web service, which means the client must possess some intelligence to perform the task. To use a Web service, you must understand the usage requirements.
From a client perspective, the type of device you use to access the Web service (including the connection type and speed it offers) determines the access speed, as well as what you can do with the data once you receive it. Although a PDA such as the Pocket PC can access eBay Web Services just fine, you wouldn't want to use it to perform detailed searches or attempt complex activities such as uploading new products for sale. A PDA or cellular telephone do work well enough to bid on products or check the status of an auction. You could possibly use these devices to check the price of an item as well. On the other hand, a desktop or laptop machine has all of the processing power, screen real estate, and functionality to perform any task. eBay Web Services hasn't changed, but the capability of the client has.
NOTE This book discusses a number of mobile devices. The Pocket PC provides additional functionality and features that make it a better target for some types of applications than devices such as the Palm. On the other hand, most Palm devices are much easier to carry and cost less than the Pocket PC. This book examines the entire range of mobile devices to ensure you understand the limitations of using a specific device to access eBay Web Services. I'm not saying one device is better than another-simply that one device works better than the other for a given application.
eBay Web Services also has some usage requirements, and these requirements might change the way that you use your client. The limitations on your account depend on the kind of license you purchase from eBay. Most developers will begin with the Individual license that limits you to 50 API calls per day. These limitations assure that the eBay servers won't become overwhelmed with calls. You can learn more about the eBay licensing levels at developer.ebay.com/DevProgram/membership/services.asp. One of the issues the terms listed on this Web page doesn't make clear is that the 50 API calls apply to work performed with the actual Web service. In addition, even if you exceed the 50 call limit, you can still make listing and relisting calls. You can make up to 5,000 sandbox (test environment) API calls per day (see the "What Is Sandbox Mode?" section for a description of sandbox calls). Since all of your work with eBay is in sandbox mode until you get an application approved, the 50 API call limit shouldn't pose much of a problem.
WARNING If you violate the licensing terms, eBay Web Services simply denies your request. In addition, you might receive a message from eBay requesting that you adhere to the terms of usage for the Web service.
Often, you can get around the licensing requirements for a Web service by using smart programming techniques. For example, using good caching techniques means that you can create applications that are lightning fast, unless the request is new or the data is too old. Obviously, given the fast-paced nature of eBay auctions, you'll need to weigh the costs of making your application fast and resource friendly against the possibility of losing an auction to a competitor.
Excerpted from Mining eBay Web Services by John Paul Mueller Excerpted by permission.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.