GET
https://jmpy.me/api/v1
/
analytics
/
recent
Recent Activity
curl --request GET \
  --url https://jmpy.me/api/v1/analytics/recent \
  --header 'Authorization: Bearer <token>'
{
  "data": [
    {
      "id": "<string>",
      "short_code": "<string>",
      "name": "<string>",
      "original_url": "<string>",
      "click_count": 123,
      "created_at": "<string>",
      "last_clicked_at": "<string>",
      "tracking_enabled": true
    }
  ]
}
Get a list of your short URLs ordered by their most recent click. Perfect for monitoring real-time activity and identifying currently active links.

Query Parameters

limit
integer
default:10
Maximum number of URLs to return (1-100).

Response

data
array
Array of recently clicked URLs.

Request Examples

# Get 10 most recently clicked URLs
curl -X GET "https://jmpy.me/api/v1/analytics/recent?limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Get 5 most recently clicked URLs
curl -X GET "https://jmpy.me/api/v1/analytics/recent?limit=5" \
  -H "Authorization: Bearer YOUR_API_KEY"

Response Examples

{
  "success": true,
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "short_code": "abc123",
      "name": "Spring Sale Landing Page",
      "original_url": "https://example.com/spring-sale",
      "click_count": 4523,
      "stored_clicks": 4520,
      "actual_clicks": 4523,
      "created_at": "2024-01-15T10:30:00Z",
      "last_clicked_at": "2024-01-07T14:32:15Z",
      "tracking_enabled": true
    },
    {
      "id": "661f9511-f3ac-52e5-b827-557766551111",
      "short_code": "def456",
      "name": "Product Launch",
      "original_url": "https://example.com/new-product",
      "click_count": 2345,
      "stored_clicks": 2345,
      "actual_clicks": 2345,
      "created_at": "2024-02-01T14:00:00Z",
      "last_clicked_at": "2024-01-07T14:28:42Z",
      "tracking_enabled": true
    },
    {
      "id": "772f0622-g4bd-63f6-c938-668877662222",
      "short_code": "ghi789",
      "name": "Newsletter Signup",
      "original_url": "https://example.com/newsletter",
      "click_count": 1876,
      "stored_clicks": 1876,
      "actual_clicks": 1876,
      "created_at": "2024-01-20T09:00:00Z",
      "last_clicked_at": "2024-01-07T14:15:33Z",
      "tracking_enabled": true
    }
  ]
}

Use Cases

Build a live activity feed showing recent clicks.
async function createActivityFeed(containerId, refreshInterval = 30000) {
  const container = document.getElementById(containerId);
  
  async function refresh() {
    const response = await fetch(
      'https://jmpy.me/api/v1/analytics/recent?limit=10',
      { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
    );
    const { data } = await response.json();
    
    container.innerHTML = data.map(url => {
      const lastClick = new Date(url.last_clicked_at);
      const ago = formatTimeAgo(lastClick);
      
      return `
        <div class="activity-item">
          <div class="activity-dot ${getRecencyClass(lastClick)}"></div>
          <div class="activity-content">
            <strong>${url.name || url.short_code}</strong>
            <span class="time">${ago}</span>
          </div>
          <div class="click-count">${url.click_count}</div>
        </div>
      `;
    }).join('');
  }
  
  function getRecencyClass(date) {
    const minutes = (new Date() - date) / 60000;
    if (minutes < 5) return 'live';
    if (minutes < 60) return 'recent';
    return 'old';
  }
  
  await refresh();
  setInterval(refresh, refreshInterval);
}
Send notifications when specific URLs receive clicks.
interface WatchedURL {
  id: string;
  name: string;
  lastKnownClick: string;
}

async function watchForNewClicks(
  watchedUrls: WatchedURL[],
  onNewClick: (url: WatchedURL, newClicks: number) => void
) {
  const response = await fetch(
    'https://jmpy.me/api/v1/analytics/recent?limit=50',
    { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }
  );
  const { data } = await response.json();
  
  for (const recent of data) {
    const watched = watchedUrls.find(w => w.id === recent.id);
    if (watched && recent.last_clicked_at !== watched.lastKnownClick) {
      // New click detected
      const newClickTime = new Date(recent.last_clicked_at);
      const oldClickTime = new Date(watched.lastKnownClick);
      
      if (newClickTime > oldClickTime) {
        onNewClick(watched, recent.click_count);
        watched.lastKnownClick = recent.last_clicked_at;
      }
    }
  }
}

// Example usage
const urlsToWatch: WatchedURL[] = [
  { id: 'uuid-1', name: 'Important Campaign', lastKnownClick: '' }
];

setInterval(() => {
  watchForNewClicks(urlsToWatch, (url, clicks) => {
    console.log(`🔔 New click on "${url.name}"! Total: ${clicks}`);
    // Send push notification, Slack message, etc.
  });
}, 10000);
Create a compact widget showing recent activity at a glance.
import requests
from datetime import datetime, timezone

def get_quick_glance():
    response = requests.get(
        'https://jmpy.me/api/v1/analytics/recent',
        headers={'Authorization': 'Bearer YOUR_API_KEY'},
        params={'limit': 5}
    )
    
    urls = response.json()['data']
    now = datetime.now(timezone.utc)
    
    # Calculate stats
    total_clicks = sum(u['click_count'] for u in urls)
    
    # Find most recent click
    if urls:
        most_recent = max(urls, key=lambda u: u['last_clicked_at'])
        last_click = datetime.fromisoformat(
            most_recent['last_clicked_at'].replace('Z', '+00:00')
        )
        seconds_ago = (now - last_click).total_seconds()
    else:
        seconds_ago = float('inf')
    
    # Determine activity level
    if seconds_ago < 300:
        activity = "🟢 Very Active"
    elif seconds_ago < 3600:
        activity = "🟡 Active"
    elif seconds_ago < 86400:
        activity = "🟠 Moderate"
    else:
        activity = "⚪ Quiet"
    
    return {
        'activity_level': activity,
        'top_5_total_clicks': total_clicks,
        'most_recent_link': urls[0]['name'] if urls else None,
        'seconds_since_last_click': int(seconds_ago)
    }

# Usage
stats = get_quick_glance()
print(f"Activity: {stats['activity_level']}")
print(f"Recent 5 URLs: {stats['top_5_total_clicks']} total clicks")