Tradera Developer Program

Executing your first SOAP API call

This section walks through the basics of executing a call - specifically, the GetOfficalTime call - for the Tradera SOAP API. The GetOfficalTime call is the simplest call in the API. It is used to get the offical Tradera time, which can then for example be used to calculate how much time is left before an auction ends.

Prerequisites

Before you execute your first API call you must create an API Developer account. You will then have to register an Application, and note down the service key and the application Id.

Step 1: Setup a programming environment

C# Microsoft Visual Studio .NET

The specific steps that you must perform to set up your environment will vary depending on what programming language you use. The first example was written in C# Microsoft Visual Studio .NET.

In Visual Studio, create a console application project, then add a web reference to the Tradera PublicService (Solution Explorer, right-click, Add Web Reference). Enter the URL to the latest Tradera PublicService WSDL:

https://api.tradera.com/v3/PublicService.asmx?WSDL

Then, click Add Reference. This generates stubs from the Tradera PublicService WSDL and adds them to the project so that they are available to your source files. You can see them in the Class View.

Step 2: Add the code

C# Microsoft Visual Studio .NET

In the main method, add the following code:

  0:
  1:
  2:
  3:
  4:
  5:
  6:
  7:
  8:
  9:
 10:
 11:
 12:
 13:
 14:
 15:
 16:
 17:
 18:
 19:
 20:
 21:
 22:
[STAThread]
static void Main(string[] args) {

	try {
		string appId = "yourAppId"; // Use your application Id
		string appServiceKey = "yourAppServiceKey"; // Use your application service key

		Tradera.Api.PublicService publicService = new Tradera.Api.PublicService();
		publicService.Url += string.Format("?appId={0}&appKey={1}", appId, appServiceKey);

		DateTime officalTraderaTime = publicService.GetOfficalTime();

 		Console.WriteLine("The offical Tradera time is: {0}", officalTraderaTime);
 		Console.ReadLine();

	} catch(Exception exception) {

		Console.WriteLine("Error: {0}", exception.Message);
		Console.WriteLine(exception.StackTrace);
		Console.ReadLine();
	}
}

You must modify some of the code with your information in order for it to work:

  • Add your application Id and application service key on lines 5 and 6.
  • Use the name you gave your web reference in place of the Tradera.Api prefix.

Step 3: Run the sample

C# Microsoft Visual Studio .NET

Now you can build and run the sample.

  • From the menu, choose Build, then Build Solution.
  • Choose Debug, then Start Without Debugging

Thats it!

You should see output like this:

01: The offical Tradera time is: 2007-06-29 12:16:50     

Congratulations! You have just made your first Tradera API call.

If you prefer, you can use SOAP headers instead of sending the application Id and service key on the querystring. For instructions, please see the sample SOAP requests.

XHTML CSS