curl --request GET \
--url https://jmpy.me/api/v1/analytics/geographic/:shortUrlId \
--header 'Authorization: Bearer <token>'{
"data": [
{
"country": "<string>",
"country_code": "<string>",
"region": "<string>",
"city": "<string>",
"clicks": 123,
"percentage": 123
}
],
"total_locations": 123
}Get geographic analytics for a short URL
curl --request GET \
--url https://jmpy.me/api/v1/analytics/geographic/:shortUrlId \
--header 'Authorization: Bearer <token>'{
"data": [
{
"country": "<string>",
"country_code": "<string>",
"region": "<string>",
"city": "<string>",
"clicks": 123,
"percentage": 123
}
],
"total_locations": 123
}550e8400-e29b-41d4-a716-446655440000abc123my-custom-link# Get location analytics by UUID
curl -X GET "https://jmpy.me/api/v1/analytics/geographic/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_API_KEY"
# Get location analytics by short code
curl -X GET "https://jmpy.me/api/v1/analytics/geographic/abc123" \
-H "Authorization: Bearer YOUR_API_KEY"
# Get location analytics by custom alias
curl -X GET "https://jmpy.me/api/v1/analytics/geographic/my-promo-link" \
-H "Authorization: Bearer YOUR_API_KEY"
const fetch = require('node-fetch');
const shortUrlId = '550e8400-e29b-41d4-a716-446655440000';
const response = await fetch(
`https://jmpy.me/api/v1/analytics/geographic/${shortUrlId}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
const data = await response.json();
// Display top countries
console.log('Top Countries:');
data.data.data.slice(0, 5).forEach(loc => {
console.log(` ${loc.country}: ${loc.clicks} clicks (${loc.percentage}%)`);
});
import axios from 'axios';
interface LocationData {
country: string;
country_code: string;
region: string;
city: string;
clicks: number;
percentage: number;
}
interface LocationAnalyticsResponse {
data: LocationData[];
total_locations: number;
}
const shortUrlId = '550e8400-e29b-41d4-a716-446655440000';
const response = await axios.get<{ success: boolean; data: LocationAnalyticsResponse }>(
`https://jmpy.me/api/v1/analytics/geographic/${shortUrlId}`,
{
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
}
);
// Group by country
const byCountry = response.data.data.data.reduce((acc, loc) => {
acc[loc.country] = (acc[loc.country] || 0) + loc.clicks;
return acc;
}, {} as Record<string, number>);
import requests
short_url_id = '550e8400-e29b-41d4-a716-446655440000'
response = requests.get(
f'https://jmpy.me/api/v1/analytics/geographic/{short_url_id}',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
data = response.json()['data']
locations = data['data']
print(f"Total unique locations: {data['total_locations']}")
print("\nTop 5 Countries:")
# Aggregate by country
countries = {}
for loc in locations:
country = loc['country']
countries[country] = countries.get(country, 0) + loc['clicks']
for country, clicks in sorted(countries.items(), key=lambda x: -x[1])[:5]:
print(f" {country}: {clicks} clicks")
<?php
$client = new GuzzleHttp\Client();
$shortUrlId = '550e8400-e29b-41d4-a716-446655440000';
$response = $client->request('GET',
"https://jmpy.me/api/v1/analytics/geographic/{$shortUrlId}", [
'headers' => [
'Authorization' => 'Bearer YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
$locations = $data['data']['data'];
echo "Top Locations:\n";
foreach (array_slice($locations, 0, 10) as $loc) {
echo " {$loc['country']}, {$loc['city']}: {$loc['clicks']} clicks\n";
}
?>
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
shortUrlId := "550e8400-e29b-41d4-a716-446655440000"
url := fmt.Sprintf(
"https://jmpy.me/api/v1/analytics/geographic/%s",
shortUrlId,
)
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.URI;
import java.net.http.HttpResponse;
String shortUrlId = "550e8400-e29b-41d4-a716-446655440000";
String url = String.format(
"https://jmpy.me/api/v1/analytics/geographic/%s",
shortUrlId
);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
{
"success": true,
"data": {
"data": [
{
"country": "United States",
"country_code": "US",
"region": "California",
"city": "San Francisco",
"clicks": 534,
"percentage": 11.8
},
{
"country": "United States",
"country_code": "US",
"region": "New York",
"city": "New York",
"clicks": 489,
"percentage": 10.8
},
{
"country": "United Kingdom",
"country_code": "GB",
"region": "England",
"city": "London",
"clicks": 423,
"percentage": 9.4
},
{
"country": "Germany",
"country_code": "DE",
"region": "Berlin",
"city": "Berlin",
"clicks": 312,
"percentage": 6.9
},
{
"country": "Canada",
"country_code": "CA",
"region": "Ontario",
"city": "Toronto",
"clicks": 287,
"percentage": 6.3
}
],
"total_locations": 127
}
}
{
"success": false,
"error": {
"code": "FEATURE_DISABLED",
"message": "Geographic analytics is not available on your current plan",
"details": {
"feature": "Geographic analytics",
"currentPlan": "Free",
"upgradeRequired": true
}
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Short URL not found",
"details": "No short URL found with code or alias: invalid-code"
}
}
GET /analytics/user-locations
curl -X GET "https://jmpy.me/api/v1/analytics/user-locations?days=30" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"success": true,
"data": {
"data": {
"countries": [
{ "country": "United States", "country_code": "US", "clicks": 8234, "percentage": 45.2 },
{ "country": "United Kingdom", "country_code": "GB", "clicks": 3456, "percentage": 19.0 },
{ "country": "Germany", "country_code": "DE", "clicks": 2134, "percentage": 11.7 },
{ "country": "Canada", "country_code": "CA", "clicks": 1567, "percentage": 8.6 },
{ "country": "Australia", "country_code": "AU", "clicks": 892, "percentage": 4.9 }
],
"cities": [
{ "city": "New York", "country": "United States", "clicks": 1234 },
{ "city": "London", "country": "United Kingdom", "clicks": 987 },
{ "city": "San Francisco", "country": "United States", "clicks": 876 }
]
}
}
}
Create a geographic heatmap
async function getMapData(shortUrlId) {
const response = await fetch(
`https://jmpy.me/api/v1/analytics/geographic/${shortUrlId}`,
{ headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);
const { data } = await response.json();
// Group by country for country-level heatmap
const countryData = {};
data.data.forEach(loc => {
if (!countryData[loc.country_code]) {
countryData[loc.country_code] = {
country: loc.country,
code: loc.country_code,
clicks: 0
};
}
countryData[loc.country_code].clicks += loc.clicks;
});
// Convert to array sorted by clicks
return Object.values(countryData)
.sort((a, b) => b.clicks - a.clicks);
}
Identify target markets
import requests
def identify_target_markets(short_url_id, threshold=5):
"""
Identify countries with >threshold% of traffic as target markets.
"""
response = requests.get(
f'https://jmpy.me/api/v1/analytics/geographic/{short_url_id}',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
locations = response.json()['data']['data']
# Aggregate by country
countries = {}
total_clicks = sum(loc['clicks'] for loc in locations)
for loc in locations:
code = loc['country_code']
countries[code] = countries.get(code, 0) + loc['clicks']
# Identify target markets
target_markets = []
for code, clicks in countries.items():
percentage = (clicks / total_clicks) * 100
if percentage >= threshold:
target_markets.append({
'country_code': code,
'clicks': clicks,
'percentage': round(percentage, 1)
})
return sorted(target_markets, key=lambda x: -x['percentage'])
Regional performance comparison
interface RegionPerformance {
region: string;
totalClicks: number;
topCities: Array<{ city: string; clicks: number }>;
}
async function compareRegions(shortUrlId: string): Promise<RegionPerformance[]> {
const response = await fetch(
`https://jmpy.me/api/v1/analytics/geographic/${shortUrlId}`,
{ headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
);
const { data } = await response.json();
// Group by region
const regions: Record<string, RegionPerformance> = {};
data.data.forEach(loc => {
const key = `${loc.country} - ${loc.region}`;
if (!regions[key]) {
regions[key] = {
region: key,
totalClicks: 0,
topCities: []
};
}
regions[key].totalClicks += loc.clicks;
regions[key].topCities.push({ city: loc.city, clicks: loc.clicks });
});
// Sort cities within each region and return top regions
return Object.values(regions)
.map(r => ({
...r,
topCities: r.topCities.sort((a, b) => b.clicks - a.clicks).slice(0, 3)
}))
.sort((a, b) => b.totalClicks - a.totalClicks);
}