home > support > API > Marketplace API > .Net Client Library

Fork me on GitHub

TourCMS API - .NET Client Library

Download VS 2010 solution (v0.7)  Fork on GitHub

The TourCMS API .NET Client Library class is intended to provide a simple wrapper for the TourCMS Marketplace API. It takes care of authentication and exposes wrapper functions for all methods currently available in the API.


Getting started

Step 1: Make sure you have some products available

If you have a Supplier account please review the checklist at the top of the API information page.

If you have a Partner account you will need to connect to at least one Supplier who has products available. You can check by logging in to your Partner account and clicking "Search & Book". If you can see some products visible then you are good to go, if not you will need to connect to some additional Suppliers, or ask your existing connections to load some products.

If you have downloaded the dll file continue to Step 2, if you have the full Visual Studio 2010 source code just open the solution in Visual Studio and load some settings for the TestApp.


Step 2: Add a Reference the wrapper library

Method A: NuGet

If you have NuGet package manager installed, search for TourCMS in the GUI, or Install-Package TourCMS in the console.

Method B: Manual download

Download the library from the link above, extract the .dll to your local machine and then just Add a Reference to it in Visual Studio. How to: Add or Remove References in Visual Studio.

Visual studio 2010 users will need to target the full version of ".NET Framework 4" (or 3.5), targetting ".NET Framework 4 Client Profile" will result in errors at build time. Troubleshooting .NET Framework Targeting Errors.


Step 3: Create a new instance of the TourCMS class

Description

object TourCMS.Utils.marketplaceWrapper ( int marketplaceId, string privateKey )

Parameters

marketplaceId
Your Marketplace Partner ID. If you are a Supplier set this to 0, if you are a Partner then you can find your ID by logging in the API settings page of your account.
 
privateKey
Your API Private Key. This can be found/set in the API settings page in your account.

Example

using TourCMS.Utils;
using System.Xml;
 
...

// Set your Marketplace ID
// For Suppliers this will be 0
// For Partners this can be found in the API settings page
int marketplaceId = 0;

// Create a new Instance of the TourCMS API class
marketplaceWrapper myTourCMS = new marketplaceWrapper(marketplaceId, "YOUR_PASSWORD_HERE");
Imports TourCMS.Utils
Imports System.Xml
   
...
  
' Set your Marketplace ID
' For Suppliers this will be 0
' For Partners this can be found in the API settings page
Dim marketplaceId As Integer = 0
  
' Create a new Instance of the TourCMS API class
Dim myTourCMS As New marketplaceWrapper(marketplaceId, "YOUR_PASSWORD_HERE")


Step 4: Call the API methods you are interested in

The simplest call is one to get back information on your current API rate limit:

// Set the Channel ID
// For Suppliers this can be found in the API settings page
// For Partners this will be 0
int channelId = 0;
 
// Query the TourCMS API
XmlDocument doc = myTourCMS.ApiRateLimitStatus(channelId);
 
// Print out the remaining hits
string limit = doc.SelectSingleNode("//remaining_hits").InnerText;
Console.WriteLine("Remaining hits: " + limit);
' Set the Channel ID
' For Suppliers this can be found in the API settings page
' For Partners this will be 0
Dim channelId As Integer = 0
  
' Query the TourCMS API
Dim doc As XmlDocument = myTourCMS.ApiRateLimitStatus(channelId)
  
' Print out the remaining hits
Dim limit As String = doc.SelectSingleNode("//remaining_hits").InnerText
Console.WriteLine("Remaining hits: " & limit)


Output:

Remaining hits: 500

The full source code for this example is included in the zip file. Additional .Net examples are available on the individual pages linked from the method list.


Licensing

The library is provided under an MIT license which allows you absolute flexibility in re-use and distribution, you may use the library in your own closed source or open source applications. If you would prefer to receive the library under another license please contact us.


Version history

0.7
Lots more wrappers (21 Mar 2013)
Now available via NuGet (Dec 2015)
0.6
Added wrappers for updating Tours/Hotels
0.5
Added wrappers for creating and updating bookings, customers and enquiries (28 Oct 2011)
0.4
Fix BST issue, moved code hosting to github
0.3
Fix signature creation for non GMT locales
0.2
Fix ApiRateLimitStatus for supplier accounts
0.1
Initial public release

More information