Travis API: Now connect seamlessly to your CRM through our API.

Written: 02/26/24

Updated on: 02/26/24

Category: Tutorial

Travis automatically transfers contact information gathered through your card directly into your CRM system via our secure API.

Written by shaquel Kothari Founder @ Traqr


This document showcases example code snippets in various programming languages demonstrating how to retrieve contact information captured by Travis through an API call.

https://traqr.co.uk/api-call-travis?api_key=YOUR_API_KEY

Replace YOUR_API_KEY with your actual API key obtained from the Traqr platform.

You can find your API KEY in your Travis Dashboard



Response:


The API returns data in JSON format, containing an array of objects. Each object represents a contact with the following properties:

  • id: Unique identifier for the contact (integer)
  • phone_number: Contact's phone number (string)
  • profile_name: Contact's name (string)
  • day: Preferred callback day (string)
  • time: Preferred callback time (string)
  • client_message: Message sent by the contact (string)

[
    {
        "id": 324241,
        "phone_number": "whatsapp:+4700000000",
        "profile_name": "Tom Wayne",
        "day": "Monday",
        "time": "Morning",
        "client_message": "I'm interested in getting a social media manager"
    },
    {
        "id": 1322131,
        "phone_number": "whatsapp:+4470000000",
        "profile_name": "Steve Manson",
        "day": "Monday",
        "time": "Morning",
        "client_message": null
    },
    {
        "id": 323433213,
        "phone_number": "whatsapp:+447700000000",
        "profile_name": "Craig",
        "day": "Monday",
        "time": "Afternoon",
        "client_message": "Please call me around 2pm"
    }
]


Code Examples:


1. Ruby:

Ruby
require 'net/http'
require 'uri'
require 'json'

# Replace with your API key
api_key = 'YOUR_API_KEY'

url = URI("https://traqr.co.uk/api-call-travis?api_key=#{api_key}")

req = Net::HTTP::Get.new(url)

res = Net::HTTP.start(url.host, url.port, use_ssl: true) { |http|
  http.request(req)
}

if res.is_a?(Net::HTTPSuccess)
  data = JSON.parse(res.body)
  puts data
else
  puts "Error: #{res.code}"
end

2. PHP:

PHP
<?php

$apiKey = 'YOUR_API_KEY';

$url = "https://traqr.co.uk/api-call-travis?api_key=" . $apiKey;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$response = curl_exec($ch);

if (curl_errno($ch)) {
  echo "Error: " . curl_error($ch);
} else {
  $data = json_decode($response, true);
  print_r($data);
}

curl_close($ch);

3. C++ (using cURL library):

C++
#include <iostream>
#include <curl/curl.h>
#include <jsoncpp/json.h>

#define API_URL "https://traqr.co.uk/api-call-travis?api_key="

int main() {
  CURL *curl;
  CURLcode res;
  std::string apiKey = "YOUR_API_KEY";
  std::string url = API_URL + apiKey;
  std::string response;

  curl = curl_easy_init();
  if (curl) {
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);

    res = curl_easy_perform(curl);

    if (res != CURLE_OK) {
      std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
    } else {
      Json::Reader reader;
      Json::Value root;
      if (reader.parse(response, root)) {
        std::cout << root << std::endl;
      } else {
        std::cerr << "Failed to parse JSON response" << std::endl;
      }
    }

    curl_easy_cleanup(curl);
  }

  return 0;
}

size_t WriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata) {
  std::string *str = (std::string*)userdata;
  str->append(ptr, size * nmemb);
  return size * nmemb;


4. Javascript:

JavaScript
// Replace with your API key
const apiKey = 'YOUR_API_KEY';

// Construct the API URL
const url = `${API_URL}${apiKey}`;

// Fetch data using async/await
async function getContacts() {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`API call failed with status ${response.status}`);
    }
    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Call the function to retrieve contacts
getContacts();