Skip to content

prio/tourcms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tourcms

A simple wrapper for connecting to TourCMS Marketplace API. This wrapper mirrors the TourCMS PHP library.

Build Status

Install

pip install tourcms

Usage

Using the library is as simple as creating a Connection object:

conn = tourcms.Connection(marketplace_id, private_key, result_type)

Your Marketplace ID and Private Key can be found in the TourCMS Partner Portal. The result type can be one of dict or raw where raw will return the raw XML from the API and dict will return a dictionary of the result. Dict requires xmltodict to be installed.

Working with your connection in Raw mode

    # Instantiate the connection
    import os
    from tourcms import Connection

    conn = Connection(0, os.getenv('TOURCMS_PRIVATE_KEY'))

    # Check we're working
    conn.api_rate_limit_status(channel_id)
    => "<?xml version="1.0" encoding="utf-8" ?><response><request>GET /api/rate_limit_status.xml</request>
        <error>OK</error><remaining_hits>1999</remaining_hits><hourly_limit>2000</hourly_limit></response>"

    # List the channels we have access to
    conn.list_channels(channel_id)
    => ""<?xml version="1.0" encoding="utf-8" ?><response><request>GET /p/channels/list.xml</request>
        <error>OK</error><channel>(...)</channel><channel>(...)</channel><channel>(...)</channel></response>"
    
    # Show a particular channel
    conn.show_channel(1234567)
    => ""<?xml version="1.0" encoding="utf-8" ?><response><request>GET /p/channels/list.xml</request>
        <error>OK</error><channel>(...)</channel></response>"

Working with your connection in Dictionary mode

Requires xmltodict to be installed

pip install xmltodict
    # Instantiate the connection
    conn = Connection(0, os.getenv('TOURCMS_PRIVATE_KEY'), "dict")

    # Check we're working
    conn.api_rate_limit_status(channel_id)
    => OrderedDict([(u'request', u'GET /api/rate_limit_status.xml?'), (u'error', u'OK'), (u'remaining_hits', u'1999'), (u'hourly_limit', u'2000')])
    obj["hourly_limit"]
    => 2000   

Passing parameters

Many TourCMS methods accept parameters. Most methods take a dictionary of parameters like so:

obj = conn.search_tours({"country": "GB", "lang": "en"})

List of functions in tourcms.Connection

  • api_rate_limit_status
  • list_channels
  • show_channel
  • search_tours
  • search_hotels_range
  • search_hotels_specific
  • list_tours
  • list_tour_images
  • show_tour
  • show_tour_departures
  • show_tour_freesale
  • show_supplier

Dependencies

None. xmltodict optional. Tested with Python 2.6, 2.7 & 3.3.

Copyright

Copyright (c) 2012 Jonathan Harrington. See LICENSE.txt for further details.

About

Python wrapper class for TourCMS.com Rest API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages