Cover by Toby Segaran

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Using Real Data—the eBay API

eBay is an online auction site and one of the most popular sites on the Internet. It has millions of listings and millions of users bidding and jointly setting prices, making it a great example of collective intelligence. As it happens, eBay also has a free XML-based API that you can use to perform searches, get detailed item information, and even post items for sale. In this section, you'll see how to use the eBay API to get price data and convert the data so that the algorithms in this chapter can be used for prediction.

Getting a Developer Key

The process of accessing eBay's API takes several steps, but it's relatively simple and automatic. A good overview of the process is in the Quick Start Guide, which is online at http://developer.ebay.com/quickstartguide.

This guide will take you through the process of creating a developer account, getting your production keys, and creating a token. When you're finished, you should have four strings that will be needed for the example in this chapter:

  • A developer key

  • An application key

  • A certificate key

  • An authentication token, which is very long

Create a new file called ebaypredict.py and add the following code, which imports some modules and includes the abovementioned strings:

import httplib
from xml.dom.minidom import parse, parseString, Node

devKey = 'developerkey'
appKey = 'applicationkey'
certKey = 'certificatekey'
userToken = 'token'
serverUrl = 'api.ebay.com'

There is no official Python API for eBay, but there ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required