Written: 02/26/24
Updated on: 11/05/24
Category: Tutorial
Explore the Traqr API to effortlessly integrate Traqr’s powerful tracking and engagement tools with your CRM.
Written by shaquel Kothari
https://traqr.co.uk/api-call-travis?api_key=YOUR_API_KEY
[ { "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" } ]
Rubyrequire '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
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);
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;
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();