Get QR Code Metrics by Country

POST /api/v1/analytics

Common errors include:

  • "Bad Request" if body parameters are not passed
  • "DNS_CONFIGURATION_ERROR" if custom domain DNS is misconfigured.

The createQrCodeHandler creates a qr code for the input body and returns the reponse to users

Request

Method : POST
Content-Type : Application/json

URL Parameters Schema

shortlink string
Default: N/A
The URL to analyze (e.g. 'https://kut.lu/d3i1t1')
startDate string
Default: N/A
Start date in YYYY-MM-DD format
endDate string
Default: N/A
End date in YYYY-MM-DD format
plan string
Default: N/A
User's plan type ("STARTER", "PRO", etc.)
linkAnalytics number
Default: null
Max number of analytics entries
kind string
Default: null
Country
LANGUAGE
REQUEST
 curl -X POST \
  'https://divsly-backend.vercel.app/api/v1/analytics' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
	"shortlink": "https://kut.lt/d3i1t",
	"startDate": "2024-03-01",
	"endDate": "2024-03-25",
	"plan": "STARTER",
	"linkAnalytics": 5,
	"kind": "country"
  }'

API REQUEST
 const getCountryAnalytics = (analyticsData) => {
  return new Promise((resolve, reject) => {
	fetch('https://divsly-backend.vercel.app/api/v1/analytics', {
  	method: 'POST',
  	headers: {
    	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
    	'Content-Type': 'application/json'
  	},
  	body: JSON.stringify({
    	shortlink: analyticsData.shortlink,
    	startDate: analyticsData.startDate,
    	endDate: analyticsData.endDate,
    	plan: analyticsData.plan,
    	linkAnalytics: analyticsData.linkAnalytics,
    	kind: analyticsData.kind
  	})
	})
  	.then(response => response.json())
  	.then(data => resolve(data))
  	.catch(error => reject(error));
  });
};

const countryAnalyticsData = {
  shortlink: "https://kut.lt/d3i1t",
  startDate: "2024-03-01",
  endDate: "2024-03-25",
  plan: "STARTER",
  linkAnalytics: 5,
  kind: "country"
};

getCountryAnalytics(countryAnalyticsData)
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

API REQUEST
const axios = require('axios');

const getCountryAnalytics = (analyticsData) => {
  return new Promise((resolve, reject) => {
	axios({
  	method: 'post',
  	url: 'https://divsly-backend.vercel.app/api/v1/analytics',
  	headers: {
    	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
    	'Content-Type': 'application/json'
  	},
  	data: {
    	shortlink: analyticsData.shortlink,
    	startDate: analyticsData.startDate,
    	endDate: analyticsData.endDate,
    	plan: analyticsData.plan,
    	linkAnalytics: analyticsData.linkAnalytics,
    	kind: analyticsData.kind
  	}
	})
  	.then(response => resolve(response.data))
  	.catch(error => reject(error.response.data));
  });
};

const countryAnalyticsData = {
  shortlink: "https://kut.lt/d3i1t",
  startDate: "2024-03-01",
  endDate: "2024-03-25",
  plan: "STARTER",
  linkAnalytics: 5,
  kind: "country"
};

getCountryAnalytics(countryAnalyticsData)
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
API REQUEST
 $data = array(
	'shortlink' => 'https://kut.lt/d3i1t',
	'startDate' => '2024-03-01',
	'endDate' => '2024-03-25',
	'plan' => 'STARTER',
	'linkAnalytics' => 5,
	'kind' => 'country'
);

$ch = curl_init('https://divsly-backend.vercel.app/api/v1/analytics');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	'Authorization: Bearer YOUR_JWT_TOKEN_HERE',
	'Content-Type: application/json'
));

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);

API REQUEST
 import requests
 import json

  url = 'https://divsly-backend.vercel.app/api/v1/analytics'
  headers = {
	'Authorization': 'Bearer YOUR_JWT_TOKEN_HERE',
	'Content-Type': 'application/json'
 }
 data = {
	'shortlink': 'https://kut.lt/d3i1t',
	'startDate': '2024-03-01',
	'endDate': '2024-03-25',
	'plan': 'STARTER',
	'linkAnalytics': 5,
	'kind': 'country'
}

 try:
	response = requests.post(
    	url,
    	headers=headers,
    	json=data
	)
	response.raise_for_status()
	print(response.json())
 except requests.exceptions.RequestException as e:
	print(f"Error: {e}")

RESPONSE
  {
    "message": "Analytics fetched successfully",
    "success": true,
    "resultData": {
      "country": [
        {
          "country": "United States",
          "_count": {
            "_all": 150,
            "country": 150
          }
        },
        {
          "country": "India",
          "_count": {
            "_all": 85,
            "country": 85
          }
        }
      ]
    }
}
        
 {
	"message": "Unauthorized!"
}

 {
	"message": "Quota not found.!"
}

    

    { "message": "Internal server error." }