The TGI Partner API is a self-serve data exchange service. We offer a library of RESTful API endpoints, which can be consumed to exchange data, fetch clients, transactions and more.
All requests sent to the API must include an x-tgi-key header, along with your unique API key. Contact your TGI account rep to obtain API access.
Keep your secret key within a server environment. It is not for use within client-facing applications. Never share your key with anyone outside your team/organization.
<?phptry{$curlOptions=[CURLOPT_URL=>'https://api.transglobalinsurance.ca/endpoint',CURLOPT_RETURNTRANSFER=>true,CURLOPT_CUSTOMREQUEST=>'POST',CURLOPT_HTTPHEADER=>['Content-Type: application/json','x-tgi-key: <your_secret_key>'],CURLOPT_POSTFIELDS=>json_encode(['hello'=>'world'])];# initalize session$ch=curl_init();# set optionscurl_setopt_array($ch,$curlOptions);# execute to fetch result$response=curl_exec($ch);# check for errorsif(curl_errno($ch)){thrownewException("cURL error: ".curl_error($ch));}# close curl sessioncurl_close($ch);# decode responseif($response){$responseData=json_decode($response,true);return$responseData;}catch(Exception$e){// log the error: $e->getMessage()returnfalse;}
1 2 3 4 5 6 7 8 9101112131415161718192021
importrequests# Make the request using the requests libraryresponse=requests.post('https://api.transglobalinsurance.ca/endpoint',json={'hello':'world'},headers={'Content-Type':'application/json','x-tgi-key':'<your_secret_key>'})# Successful requestifresponse.ok:response_data=response.json()print('Response data:',response_data)else:print('Request failed with status code:',response.status_code)print('Error message:',response.text)
usingSystem;usingSystem.Net.Http;usingSystem.Text;usingSystem.Threading.Tasks;classProgram{staticasyncTaskMain(){// Create an instance of HttpClientusing(HttpClienthttpClient=newHttpClient()){// Add 'x-tgi-key' headerhttpClient.DefaultRequestHeaders.Add("x-tgi-key","<your_secret_key>");// Request payloadStringContentcontent=newStringContent(Newtonsoft.Json.JsonConvert.SerializeObject({hello="world"}),Encoding.UTF8,"application/json");// Execute requestHttpResponseMessageresponse=awaithttpClient.PostAsync("https://api.transglobalinsurance.ca/endpoint",content);// Check if the request was successful (status code 200)if(response.IsSuccessStatusCode){// Read and display the response contentstringresponseContent=awaitresponse.Content.ReadAsStringAsync();Console.WriteLine("Response data: "+responseContent);}else{// Print the error message for unsuccessful requestsConsole.WriteLine("Request failed with status code: "+response.StatusCode);Console.WriteLine("Error message: "+awaitresponse.Content.ReadAsStringAsync());}}}}
Paginated Results
Many of our API endpoints are structured to allow you to query large data sets. We return a standard response model from which you can easily navigate result sets, and build UI elements like prev/next buttons and page indicators.
{"query":{"limit":50,// query limit"results":50,// result count"totalRecords":3200// total table records},"page":{"total":64,// total number of pages"current":1,// current page number"next":2,// next page number"prev":1// previous page number},"cursor":{"prevUrl":null,// fetch prev result set"nextUrl":"/endpoint?limit=50&page=2"// fetch next result set},"data":[{"id":"HIWRLD",...}]}
To consume paginated results, use nextUrl. This will be a string value for as long as there are more results. As soon as nextUrl is null, there are no more results and you should exit your loop.