Skip to main content

Visits

/api/v1/visits End Point - reads visits data from your cbsplit account and return as json data.

Make an api request to visits endpoint#

http://YOUR_CBSPLIT_HOST/api/v1/visits

Every request should provide API Key via X-API-Key header.

API will return 100 results per page. Use page param for pagination.

Response#

API will return a JSON object like bellow:

{ entries: [], totalEntries: Number, page: Number, totalPages: Number }

Every entry will have the following structure:

  • id: Integer
  • created_at: UTC Timestamp - 2020-02-03T17:16:00.485Z
  • user_id: Integer
  • page_id: Integer
  • page_version: One char (a to z)
  • country: Two chars (ISO country code)
  • mobile: true / false
  • referrer: String
  • referrer_name: String (Referrer name, like Google, Facebook etc.)
  • referrer_medium: String (Referrer medium, like Email, Search, Social etc.)
  • exit_url: String
  • affiliate: String
  • client_ip: IP Address
  • utm_source: String
  • utm_medium: String
  • utm_campaign: String
  • utm_content: String
  • fbclid: String
  • fbp: String
  • fbc: String

API Call Rate Limits#

Maximum 60 Requests Per Minute per IP Address. If limit reached 429 status code returned with an empty body.

Filters#

  • id
  • created_at
  • user_id
  • page_id
  • page_version
  • country
  • mobile
  • referrer_name
  • referrer_medium
  • affiliate
  • utm_source
  • utm_medium
  • utm_campaign
  • utm_content

By default any column will filter by exact value. e.g. { "created_at": "2020-02-03T17:16:00.485Z" } will return entries created at that exact timestamp.

To get entries created after specific time use gt/gte modifier: { "created_at.gt": "2020-02-03" } or { "created_at.gte": "2020-02-03" }

To get entries created before specific time use lt/lte modifier: { "created_at.lt": "2020-02-03" } or { "created_at.lte": "2020-02-03" }

To get entries created within specific timespan use between modifier, providing two comma separated values: { "created_at.between": "2020-02-03,2020-03-03" }

It's also possible to filter by multiple exact values by using in modifier and providing comma separated values: { "country.in": "US,CA" }

This same logic applies to all columns, except Boolean ones. To filter by Boolean columns use t for true and f for false. { "mobile": "t" } or { "mobile": "f" }

Filter Requests Examples#

/api/v1/visits?created_at.gt=2020-02-03/api/v1/visits?created_at.between=2020-02-03,2020-03-01/api/v1/visits?country.in=US,CA&mobile=t

Code Samples#

cURL - Command Line#

curl -H "X-API-Key: XXXXXXXXXXXXXXXX" https://YOUR_CBSPLIT_HOST/api/v1/visitscurl -H "X-API-Key: XXXXXXXXXXXXXXXX" https://YOUR_CBSPLIT_HOST/api/v1/visits?page=2

NodeJs Code#

fetch("https://YOUR_CBSPLIT_HOST/api/v1/visits", {  method: "get",  headers: {     'X-API-Key': 'XXXXXXXXXXXXXX',    'User-Agent': 'Mozilla/5.0 (compatible; cURL/7.68.0)'  }})  .then(res => res.json())  .then(data => console.log(data))  .catch(err => console.log(err))

PHP Code#

<?php
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "https://YOUR_CBSPLIT_HOST/api/v1/visits");$headers = [    'X-API-Key: XXXXXXXXXXXXXX',];curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; cURL/7.68.0)');curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$response = curl_exec($ch);
if(curl_errno($ch)) {    echo "curl error: " . curl_error($ch);} else {    $data = json_decode($response, true);    print_r($data);}curl_close($ch);
?>

Python code#

import requests
url = "https://YOUR_CBSPLIT_HOST/api/v1/visits"headers = {    "X-API-Key": "XXXXXXXXXXXX",    "User-Agent": "Mozilla/5.0 (compatible; cURL/7.68.0)"}
response = requests.get(url, headers=headers)if response.status_code == 200:    data = response.json()    for obj in data['entries']:        print (obj)else:    print(f"Error: {response.status_code}")

Ruby code#

require 'net/http'require 'uri'
url = URI.parse("https://YOUR_CBSPLIT_HOST/api/v1/visits")
http = Net::HTTP.new(url.host, url.port)http.use_ssl = (url.scheme == "https")
request = Net::HTTP::Get.new(url.path)request["X-API-Key"] = "xxxxxxxxxxx" # Replace with your actual API keyrequest["User-Agent"] = "Mozilla/5.0 (compatible; cURL/7.68.0)"
response = http.request(request)
puts response.body