What's new

Major update on newest Trip partner API 2.0

Trip recently released a new hotel availability checking API 2.0 with enhanced performance and to make it easier to be docked by our partners.

The major updates on API 2.0 includes applying new data format and new encryption algorithm which can optimizing data transmission quantity and make the transmission become more protected. Meanwhile, several updates for improving user experience are also applied, Trip encourage all the partners to implement this new API 2.0.

  • Data format changing
    • To optimize the data transmission quantity, Trip applied JSON format instead of XML. Upgrading the new API 2.0 will make the analysis of response become faster and easier.
  • Adults and Children can be separately requested.
    • In new API 2.0, Adults and Children can be separately requested, Trip will accordingly check and response the rates under requested conditions.
  • "Query Key" as Log ID now available
    • Partner can generate Log ID in the request, and it can be used for debug and tracking the request detail in history.
  • Redirecting URL are setted in response.
    • By using API 2.0, the redirecting URL will be setted in response body, there is no need for partner to hard coding the relationship between redirecting URL and requested languages and other conditions.
  • Customized information are needed from Partners
    • In order to improve the user experience for both of our partners and us, we strongly recommend our partner to share some information that displayed on partner's site. For instance we would like to know the price, currency, price display mode, etc. that dispalyed on partner's site, by analyzing these information, we can technically reduce the price discrepancy and do our best to restore the information that displayed on partner's site in our end.

Get Started

Technical Requirements

  • API 2.0 requests from Partners are needed to be sent as a HTTP POST request. All parameters need to be application/json.
  • API 2.0 responses will conform to the JSON specification and be sent with the HTTP Content-Type header set to application/json.
  • API 2.0 responses will use UTF-8 encoding.

More Parameters in Future Response

By improving the functions of Trip partner API, Trip may response more information as new parameters at future dates. These parameters may not be documented at the time of partner's implementation, therefore, please do not validate against new parameters.

Web Service URL

Service URL

https://openservice.ctrip.com/openservice/serviceproxy.ashx?e=r6&aid={int}&sid={int}&token={string}&icode={string}&uuid={string}

Field Description

Filed Type Description Example
e string Version of API, fixed as "r6" in this version. e=r6
aid integer Unique ID to tracking the traffic and orders from different partner. aid=1234
sid integer ID to tracking the traffic and orders. sid=123456
token string Need to be generated by partner based on token algorithm. token=a74cf5fd9dd22c892ae723aaa4d32724ecced9818d676c07543b88b39027d900
icode string Fixed code to verify partner's identification.
Each 'sid' has unique 'icode' to be matched.
icode=46703c6fb11e4e7bbd7c129c612c258e
uuid string Generated by parter and need to be unique in each request uuid=1a49d15sde2s1fa8c

Token algorithm

Copy
                                

  class Program

    {

        static void Main(string[] args)

        {

            //Partner Account

            string allianceId = "12345";

            string sid = "987654";


            //Partner password, will be received from Trip

            string userKey = "af85s54f66s4fd5s64f112sf25";

            //Unique signature, will be received from Trip

            string icode = "95fs2sf123s1f23s1f56s4f1s3f";

            //Guid, generated by parter and need to be unique in each request.

            string uuid = Guid.NewGuid().ToString().Replace("-", "");

            string[] p = new string[] { allianceId, sid, userKey, icode, uuid };

            string data = string.Format("aid={0}&sid={1}&userkey={2}&icode={3}&uuid={4}", p);

            string encryptData = SHA256(data);

            System.Console.WriteLine(String.Format("orginal:{0}", data));

            System.Console.WriteLine(String.Format("encrypted:{0}", encryptData));

            System.Console.ReadLine();

        }


        #region  SHA256 encryption algorithm



        /// <summary>

        /// SHA256 function

        /// </summary>

        /// <param name="str">default string</param>

        /// <returns>SHA256 result(returning 44 bytes string)</returns>

        public static string SHA256(string str)

        {

            byte[] bytValue = System.Text.Encoding.UTF8.GetBytes(str);

            try

            {

                SHA256 sha256 = new SHA256CryptoServiceProvider();

                byte[] retVal = sha256.ComputeHash(bytValue);

                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < retVal.Length; i++)

                {

                    sb.Append(retVal[i].ToString("x2"));

                }

                return sb.ToString();

            }

            catch (Exception ex)

            {

                throw new Exception("GetSHA256HashFromString() fail,error:" + ex.Message);

            } 

        }

        #endregion

    }

Copy
                                

    import java.io.UnsupportedEncodingException;

    import java.security.MessageDigest;

    import java.security.NoSuchAlgorithmException;

    import java.util.UUID;

        

    public class Test {

        public static void main(String[] args){

           //Partner Account

           String allianceId = "12345";

           String sid = "987654";

           //Partner password, will be received from Trip

           String userKey = "af85s54f66s4fd5s64f112sf25";

           //Unique signature, will be received from Trip

           String icode = "5fd08a3e30c14fd49c5f4b11a6094b83";

           //Guid, generated by parter and need to be unique in each request.

           String uuid = UUID.randomUUID().toString().replaceAll("\\-", "");

           String[] p = new String[] { allianceId, sid, userKey, icode, uuid };

           String data = String.format("aid=%s&sid=%s&userkey=%s&icode=%s&uuid=%s", p);

           String encryptData = getSHA256StrJava(data);

           System.out.println(String.format("orginal:%s", data));

           System.out.println(String.format("encrypted:%s", encryptData));

        }

       

        public static String getSHA256StrJava(String str){

           MessageDigest messageDigest;

           String encodeStr = "";

           try {

               messageDigest = MessageDigest.getInstance("SHA-256");

               messageDigest.update(str.getBytes("UTF-8"));

               encodeStr = byte2Hex(messageDigest.digest());

           } catch (NoSuchAlgorithmException e) {

               return null;

               //e.printStackTrace();

           } catch (UnsupportedEncodingException e) {

               return null;

               //e.printStackTrace();

           }

               return encodeStr;

        }

             

         private static String byte2Hex(byte[] bytes){

            StringBuffer stringBuffer = new StringBuffer();

            String temp = null;

            for (int i=0;i < bytes.length;i++)

            {

               temp=Integer.toHexString(bytes[i]& 0xff );

               if (temp.length()= =1){

                  stringBuffer.append("0");

               }

               stringBuffer.append(temp);

            }

            return stringBuffer.toString();

        }

    }

Request

Request Body Sample

Copy
						

{

     "CheckInTime": "2025-09-20",

     "CheckOuttime": "2025-09-21",

     "HotelIDs": [

          996317

     ],

     "Language": "en_US",

     "Currency": "USD",

     "QueryType": "List",

     "Adults": 2,

     "ChildRen": [

          0

     ],

     "UserIPCountryCode": "US",

     "POS": "UK",

     "Device": "Desktop",

     "AllianceID": 10001,

     "SID": 0,

     "QueryKey": "60064e47870439d44556",

     "FunctionOptions": ["detailed_cancellation_policy"]

}

Parameters

Field Parameters Description
CheckInTime string The check-in date of the traveler using the hotel's time zone. The date is required to be in ISO8601 full-date format (YYYY-MM-DD).
CheckOuttime string The check-out date of the traveler using the hotel's time zone. The date is required to be in ISO8601 full-date format (YYYY-MM-DD).
HotelIDs array Up to 20 hotels are allowed to query in each of request.
Language string

Language code (see Supported Languages). Language codes are a combination of the ISO 639-1 language codes and the ISO 3166-1 country codes.


All supported language are listed below:


Language Code Language Name Corresponding Trip Domain
pt_PT Portuguese(Portugal) https://pt.trip.com
en_PH English(Philippines) https://ph.trip.com
en_ID English(Indonesia) https://id.trip.com/?language=enid&locale=en_ID
en_TH English(Thailand) https://th.trip.com/?language=enth&locale=en_TH
en_CA English(Canada) https://ca.trip.com
es_MX Spanish(Mexico) https://mx.trip.com
es_US Spanish(U.S.A) https://us.trip.com
uk_UA Ukrainian(Ukraine) https://ua.trip.com
sv_SE Swedish(Sweden) https://se.trip.com
de_CH German(Switzerland) https://ch.trip.com/?language=dech&locale=de_CH
de_AT German(Austria) https://at.trip.com
en_IE English(Ireland) https://ie.trip.com
nl_BE Dutch(Belgium) https://be.trip.com
en_XX English(Other areas) https://www.trip.com
en_SA English(Saudi Arabia) https://sa.trip.com
en_NZ English(New Zealand) https://nz.trip.com
en_IL English(Israel) https://il.trip.com
en_AE English(United Arab Emirates) https://ae.trip.com
de_DE German https://de.trip.com/
en_AU English (Australia) https://au.trip.com/
en_US English (United States) https://www.trip.com/
en_SG English (Singapore) https://sg.trip.com/
es_ES Spanish (Spain) https://es.trip.com/
fr_FR French (France) https://fr.trip.com/
id_ID Indonesian (Indonesia) https://id.trip.com/
ja_JP Japanese (Japan) https://jp.trip.com/
ko_KR Korean (Korea) https://kr.trip.com/
ru_RU Russian (Russia) https://ru.trip.com/
zh_TW Traditional Chinese (Taiwan) https://tw.trip.com/
zh_HK Traditional Chinese (Hong Kong) https://hk.trip.com/
en_HK English (Hong Kong) https://hk.trip.com/?language=EN&locale=en_hk
th_TH Thai (Thailand) https://th.trip.com/
ms_MY Malaysian (Malaysia) https://my.trip.com/
en_GB English (United Kingdom) https://uk.trip.com/
en_MY English (Malaysia) https://my.trip.com/?language=EN&locale=en_my
vi_VN Vietnamese (Viet Nam) https://vn.trip.com/
it_IT Italian (Italy) https://it.trip.com/
nl_NL Dutch (Netherlands) https://nl.trip.com/
pl_PL Polish (Poland) https://pl.trip.com/
tr_TR Turkish (Turkey) https://tr.trip.com/
pt_BR Portuguese (Brazil) https://br.trip.com/
el_GR Greek (Greece) https://gr.trip.com/
fr_CH French (Switzerland) https://ch.trip.com/?language=frch&locale=fr_CH
en_BE English (Belgium) https://be.trip.com/?language=enbe&locale=en_BE
fr_BE French (Belgium) https://be.trip.com/?language=frbe&locale=fr_BE
da_DK Dansk https://dk.trip.com/
fi_FI Suomi https://fi.trip.com/
NOTE:
It's not mandatory to fill in Language and the default is en_US if no selection is applied.
Currency string Use ISO 4217 currency code.

Currently Trip support following currencies:

Currency Alphabetic Code
Euro EUR
US Dollar USD
Australian Dollar AUD
Canadian Dollar CAD
Yuan Renminbi CNY
New Zealand Dollar NZD
Danish Krone DKK
Pound Sterling GBP
Hong Kong Dollar HKD
Rupiah IDR
Yen JPY
Won KRW
Swiss Franc CHF
Pataca MOP
Malaysian Ringgit MYR
Philippine Peso PHP
Singapore Dollar SGD
Swedish Krona SEK
New Taiwan Dollar TWD
Baht THB
Dong VND
Polish złoty PLN
Brazilian real BRL
Indian rupee INR
United Arab Emirates Dirham AED
Mexican Peso MXN
Saudi Riyal SAR
Turkish Lira TRY
Qatari Riyal QAR
Israeli New Shekel ILS
Russian Ruble RUB
Bahraini Dinar BHD
Jordanian Dinar JOD
Kuwaiti Dinar KWD
Omani Rial OMR
NOTE:
If requested currency is out of supported currencies, Trip will response in default as USD.
QueryType string
Query Type Description
SP If SP is applied, Trip will response starting price of the hotel with detail information of the room.
List If List is applied, Trip will response the lowest rate room of each roomtypes with detail information of the rooms.
NOTE:
If Query Tpe is other than 'SP' or 'List', Trip will response in default as List.
Adults integer The number of adults staying in the room.
Children array [Optional] The ages of any children staying in the room. For example: "children":[2,1] means two children are requested and the age of them are 1 year old and 2 years old; "children":[0] means one child is requested and the age of him is under 1 year old.

If no children are requested please send an empty children array.
UserIPCountryCode string The country code of user who requesting price on partner's site based on ip address.

Using ISO 3166-1 country code.

Reference: https://en.wikipedia.org/wiki/ISO_3166-1
POS string Point Of Sale, determined by partner to applying different price or rules.

Using ISO 3166-1 country code.

Reference: https://en.wikipedia.org/wiki/ISO_3166-1

For example, an user who based on Spain but visiting FR pos website of partner, the POS should be FR and UserIPCountryCode should be ES.
Device string
Supported Device Description
Desktop If user is using Desktop visiting partner's site
Mobile If user is using mobile device visiting partner's site
NOTE:
The default is Desktop if no selection is applied.
AllianceID integer Unique ID to tracking the traffic and orders from different partner.
SID integer ID to tracking the traffic and orders.
QueryKey string Can be used as Tracking ID if partner need to log and track the request.
FunctionOptions string array
Value Description
detailed_cancellation_policy Required, to enable the CancellationPolicy

Response

Response Body Sample

Copy
                    

{

  "ResponseStatus": {

    "Timestamp": "/Date(1505213219319+0800)/",

    "Ack": "Success",

    "Errors": [],

    "Extension": []

  },

  "ResultMessage": "",

  "DataResponse": {

    "Hotel": [

      {

        "HotelID": 123,

        "CityID": 0,

        "CheckInTime": "/Date(1505836800000+0800)/",

        "CheckOutTime": "/Date(1505923200000+0800)/",

        "Hotel_Availability": "Unavailable",

        "SubRoom": []

      },

      {

        "HotelID": 346401,

        "CityID": 2,

        "CityName": "Shanghai",

        "CheckInTime": "/Date(1505836800000+0800)/",

        "CheckOutTime": "/Date(1505923200000+0800)/",

        "Hotel_Availability": "Available",

        "SubRoom": [

          {

            "RoomID": 20030395,

            "RoomInfo": {

              "RoomName": "Grand Deluxe Room",

              "MaxOccupancy": 2,

              "BedInfo": [

                {

                  "BedType": "Twin bed",

                  "Wdith": 1,

                  "Unit": "meter"

                },

                {

                  "BedType": "Double Bed",

                  "Wdith": 1.8,

                  "Unit": "meter"

                }

              ],

              "RoomArea": {

                "Size": 38,

                "Unit": "square_meter"

              },

              "Holdroom": 9999

            },

            "RoomRates": {

              "Price": 58,

              "BasePrice": 50,

              "TaxFee": 8,

              "TotalPrice": 58,

              "TotalBasePrice": 50,

              "TotalTaxFee": 8,

              "Exchange": 6.0487,

              "DayCount": 1,

              "Currency": "USD"

            },

            "Inclusions": [

              {

                "type": "FreeBreakfast",

                "Value": "1"

              },

              {

                "type": "FreeWifi",

                "Value": "1"

              }

            ],

            "RulesandRestrictions": {

              "PaymentMethod": "Prepay online",

              "Cancellation": {

                "Guarantee": false,

                "Refundable": false,

                "Deadline": "/Date(-28800000-0000)/"

              }

            },

            "PayType": "PP",

            "BookURL": "https://hk.trip.com/hotels/redirect?hotelid=346401&city=2&Allianceid=10001&Sid=0&checkin=2017-09-20&checkout=2017-09-21&shoppingid=58f7d96facc24117bb8fc3932921d7ea&adult=2&roomid=20030395&swid=0&breakfast=0&pay=PP&pctoken=87fa956260064e47870439d445566a19",

            "IsSmoking": 0,

            "CancellationPolicy": {

              "PolicyType":"partiallycancellable",

              "CancelDeductDetailList": [

                {

                  "DeductionStartTime":"2022-01-24T00:00:00+08:00",

                  "DeductionEndTime":"2022-05-03T15:00:00+08:00",

                  "CancelDeductPriceInfo": {

                    "CNYPriceInfo":3.0

                  }

                },

                {

                  "DeductionStartTime":"2022-05-03T15:00:00+08:00",

                  "DeductionEndTime":"2022-05-03T21:00:00+08:00",

                  "CancelDeductPriceInfo": {

                    "CNYPriceInfo":15.0

                  }

                },

                {

                  "DeductionStartTime":"2022-05-03T21:00:00+08:00",

                  "DeductionEndTime":"2022-05-03T23:00:00+08:00",

                  "CancelDeductPriceInfo": {

                    "CNYPriceInfo":23.0

                  }

                }

              ],

               "LastCancelTime":"2022-05-03T23:00:00+08:00"

             }

          }

        ]

      }

    ]

  },

  "ShoppingID": "58f7d96facc24117bb8fc3932921d7ea"

}

Parameters

Field Parameters Description
HotelList HotelID Trip HotelID of requested hotel
CityID Trip cityid of requested hotel
CityName Trip city name of requested hotel
CheckInTime Requested date of check in.
CheckOutTime Requested date of check out.
Hotel_Availability
Value Description
Available The hotel is available
Unavailable The hotel is sold out or currently unavailable
SubRoom RoomID The unique ID of each room.
RoomInfo RoomName The name of room type.
MaxOccupancy The maximum number of adults who can stay in the room.
BedInfo The type of bed is served in the room, response in array.
For Example:
[{"BedType":"Queen Bed","Width":1.5","Unit":"meter"},{"BedType":"Single Bed":"width":1.1,"Unit":"meter"}] means the room has two beds, the one is 1.5 meter width Queen Bed, the other is 1.1 meter width Single Bed.

[{"BedType":"Queen Bed","Width":1.5","Unit":"meter"}],[{"BedType":"Twin Bed":"width":1.1,"Unit":"meter"}] means the room has one Queen Bed or has Two Single Bed (Twin Bed).

If Trip does not have the Width of Bed, "-1" will be responsed in API as unknown.
RoomRates RoomArea The size of room, unit is square meter.
Holdroom The availability amount of the room.
Price Average price of each room night including tax& fee.
BasePrice Average base price of each room night excluding tax& fee.
TaxFee Average tax& fee of each night.
TotalPrice Total price of all nights including tax& fee.
TotalBasePrice Total price of all nights excluding tax& fee.
TotalTaxFee Total tax& fee of all nights.
Exchange Foreign exchange rate CNY against requested currency.
DayCount Count of requested days of stay.
Inclusions type eg. breakfast
value
Value Description
0 No breakfast
1 With free breakfast
2 Partial free breakfast
RulesandRestrictions PaymentMethod Response is text in the requested language, if partner wants to display in own text,please refer the 'PayType'.

PaymentMethod Description
Prepay online Orders need to be paid online
Pay at hotel Orders need to be paid at hotel
Cancellation Guarantee
Guarantee Description
True Need to provide credit card information for preauthorization.
False Does not need to provide credit card information for preauthorization.
Refundable
Refundable Description
True The payment can be refunded if cancel the order before the deadline.
False The payment cannot be refunded.
Deadline The deadline to cancel the order and refund the payment.
PayType PayType
PayType Description
FG Orders need to be paid at hotel
PP Orders need to be paid online
BookURL BookURL The redirect link that responsed by Trip API, this url will determine the landing page based on partner's requests.

NOTE:
Using book url to redirect is necessary, partner are requested to add customized parameters in book url since Trip would need to know.

Trip may modifiy the BookURL in our end but will make sure the changes applies correctly.

Example:
https://hk.trip.com/hotels/redirect?shoppingid=27c1a3583eb74eea8181d0d4c4ac935d&checkin=2017-12-05&checkout=2017-12-06&aid=xxxx&sid=xxxx&city=2&hotelid=433698&RoomID=20118704&swid=0&breakfast=0&adult=2&pay=pp&pctoken=87fa956260064e47870439d445566a19
IsSmoking IsSmoking
IsSmoking Description
0 Smoking is forbidden
1 Smoking is available
2 Unknown
CancellationPolicy PolicyType
Value Description
free Orders can be cancelled without any charge
none Orders cannot be cancelled
timelimited Orders can be cancelled in limited time for free
partiallycancellable Cancellation at different times will result in different percentages of deduction
CancelDeductDetailList Details of cancellation deductions, indicating how much was deducted for which time periods of cancellation. This list will be only returned when PolicyType is "partiallycancellable"
Parameter Description
DeductionStartTime Time to start deducting rates for this time period. (Time is in UTC/GMT+08:00)
DeductionEndTime Time to end deducting rates for this time period(Time is in UTC/GMT+08:00) If CNYPriceInfo before a current deductionEndTime is 0, this deductionEndTime is the last time for free cancellation
CancelDeductPriceInfo
Parameter Description
CNYPriceInfo Currently only deduction price in CNY is provided
LastCancelTime The deadline to cancel the order and refund the payment.
ShoppingID ShoppingID Unique tacking ID for each request.
Shoppingid will be used to debug any cases that may occured

Errors

Error Code Error description Error Solutions
230 Missing necessary parameter(s) Fill in the missing parameter(s) and try again.
232 Invalid Token Failed to verify the token, token must generated by following "Token algorithm"
233 Request frequncy exceeded (Per Minutes) The default limitation of request frequency is 20,000 times per minutes. Partner can solve this error by reduce the request frequency. If partner need to adjust the limitation, please contact Trip business manager for more information.
234 Internal API error Temporaryly error occured by Trip internal error, if this error code appears too much or sustained for a long time, please contact Trip business manager for more information.
235 API overloaded Temporaryly error occured by Trip internal error, if this error code appears too much or sustained for a long time, please contact Trip business manager for more information.

Customized Parameters

Parameter Type Description
pri string Average Price of each night that shown on partner site, excluding tax& fees.
tf string Average Tax& fees of each night that shown on partner site.
curr string Currency that user selected on partner's site, this will determine the currency on landing page.
ouid string Unique click ID
display string The rule of price display on partner site:

display description
=inctotal Partner dispalying total price of all nights including tax& fees.
=incavg Partner displaying average price of each night including tax& fees.
=exavg Partner displaying average price of each night excluding tax& fees.
NOTE:

Trip will refer this parameter to determine the price displaying mode on landing page, the default is display average price for each night while failed to analyze the parameter.