Skip to content

Get Started

Using this documentation

Navigate between endpoint collections from the left menu. The right menu will list all sub-content and endpoints.

TGI Partner API


Main website

If you're looking for the main website, visit www.transglobalinsurance.ca

Need Help?

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.

api.transglobalinsurance.ca

  Authentication


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.

Examples:

1
2
3
4
5
curl -X POST \
    -H "Content-Type: application/json" \
    -H "x-tgi-key: <your_secret_key>" \
    -d '{"hello":"world"}' \
    https://api.transglobalinsurance.ca/endpoint
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Request options
const options = {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'x-tgi-key': '<your_secret_key>'
    },
    body: JSON.stringify({
        hello: 'world'
    })
}

// Make the request
fetch('https://api.transglobalinsurance.ca/endpoint', options)
    .then(response => {
        if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`)
        }
        return response.json()
    })
    .then(data => {
        console.log('Response data:', data)
    })
    .catch(error => {
        console.error('Fetch error:', error)
    })
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

$client = new GuzzleHttp\Client();

try {
    $res = $client->request(
        'POST',
        'https://api.transglobalinsurance.ca/endpoint',
        [
            'headers' => [
                'Content-Type' => 'application/json',
                'x-tgi-key'    => '<your_secret_key>'
            ],
            'json' => [
                'hello' => 'world'
            ]
        ]
    );

    if ($res->getStatusCode() !== 200) {
        throw new Exception("HTTP error! Status: {$res->getStatusCode()}")
    }

    $responseData = json_decode($res->getBody(), true);
    return $responseData;
}
catch (Exception $e) {
    // log the error:  $e->getMessage()
    return false;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

try {
    $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 options
    curl_setopt_array($ch, $curlOptions);

    # execute to fetch result
    $response = curl_exec($ch);

    # check for errors
    if (curl_errno($ch)) {
        throw new Exception("cURL error: " . curl_error($ch));
    }

    # close curl session
    curl_close($ch);

    # decode response
    if ($response) {
        $responseData = json_decode($response, true);
        return $responseData;
    }

catch (Exception $e) {
    // log the error:  $e->getMessage()
    return false;
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import requests

# Make the request using the requests library
response = requests.post(
    'https://api.transglobalinsurance.ca/endpoint',
    json={
        'hello': 'world'
    },
    headers={
        'Content-Type': 'application/json',
        'x-tgi-key': '<your_secret_key>'
    }
)

# Successful request
if response.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)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        // Create an instance of HttpClient
        using (HttpClient httpClient = new HttpClient())
        {
            // Add 'x-tgi-key' header
            httpClient.DefaultRequestHeaders.Add("x-tgi-key", "<your_secret_key>");

            // Request payload
            StringContent content = new StringContent(
                Newtonsoft.Json.JsonConvert.SerializeObject({
                    hello = "world"
                }),
                Encoding.UTF8,
                "application/json"
            );

            // Execute request
            HttpResponseMessage response = await httpClient.PostAsync(
                "https://api.transglobalinsurance.ca/endpoint",
                content
            );

            // Check if the request was successful (status code 200)
            if (response.IsSuccessStatusCode)
            {
                // Read and display the response content
                string responseContent = await response.Content.ReadAsStringAsync();
                Console.WriteLine("Response data: " + responseContent);
            }
            else
            {
                // Print the error message for unsuccessful requests
                Console.WriteLine("Request failed with status code: " + response.StatusCode);
                Console.WriteLine("Error message: " + await response.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.

{
    page: {
        nextUrl: "/endpoint?limit=50&page=2",
    }
}