API reference

Link analytics

Query click analytics for your shortened links using the same query API, with link_id instead of website_id.

External ID

Links support an optional external ID, a third-party identifier (e.g. company ID, campaign ID, partner ID) you can use to:

  • Filter invites: companies can tag invite links with their ID and list all links for that company
  • Attribute traffic: query which external entity drove clicks
  • Integrate: sync with your CRM, partner dashboard, or internal systems

Set externalId when creating or updating a link. Use externalId in the list endpoint to filter:

json
// Create link with external ID
{
"organizationId": "org_123",
"name": "Creator invite",
"targetUrl": "https://app.example.com/signup",
"externalId": "company_acme"
}

// List links filtered by external ID
{
"organizationId": "org_123",
"externalId": "company_acme"
}
http
POST /v1/query?link_id={link_id}

Request body:

json
{
"parameters": ["link_total_clicks", "link_clicks_by_day", "link_top_referrers"],
"startDate": "2024-01-01",
"endDate": "2024-01-31",
"granularity": "daily",
"limit": 10
}

Granularity

Time-series queries support hourly or daily granularity:

json
{
"parameters": ["link_clicks_by_day"],
"startDate": "2024-01-01",
"endDate": "2024-01-07",
"granularity": "hourly"
}
  • "daily": group by day (default)
  • "hourly": group by hour (max 30 day range)

When using hourly granularity, link_clicks_by_day returns data points for each hour instead of each day.

Available query types

TypeDescriptionGranularity
link_total_clicksTotal click count for the linkNone
link_clicks_by_dayTime-series breakdown of clickshour, day
link_referrers_by_dayTime-series count of unique referrershour, day
link_countries_by_dayTime-series count of unique countrieshour, day
link_top_referrersTop traffic sourcesNone
link_top_countriesTop countries by clicksNone
link_top_regionsTop regions by clicksNone
link_top_citiesTop cities by clicksNone
link_top_devicesDevice type breakdown (mobile, desktop, tablet)None
link_top_browsersBrowser breakdownNone

Example response

json
{
"success": true,
"queryId": "",
"data": [
  {
    "parameter": "link_total_clicks",
    "success": true,
    "data": [{ "total": 1542 }]
  },
  {
    "parameter": "link_clicks_by_day",
    "success": true,
    "data": [
      { "date": "2024-01-01", "clicks": 125 },
      { "date": "2024-01-02", "clicks": 143 }
    ]
  },
  {
    "parameter": "link_top_referrers",
    "success": true,
    "data": [
      { "name": "twitter.com", "referrer": "twitter.com", "clicks": 523 },
      { "name": "Direct", "referrer": "Direct", "clicks": 412 }
    ]
  }
],
"meta": {
  "parameters": ["link_total_clicks", "link_clicks_by_day", "link_top_referrers"],
  "total_parameters": 3,
  "page": 1,
  "limit": 10,
  "filters_applied": 0
}
}

Hourly response example

With "granularity": "hourly", time-series queries return data points for each hour:

json
{
"parameter": "link_clicks_by_day",
"success": true,
"data": [
  { "date": "2024-01-01 00:00:00", "clicks": 12 },
  { "date": "2024-01-01 01:00:00", "clicks": 8 },
  { "date": "2024-01-01 02:00:00", "clicks": 5 }
]
}

For tracking which external links users click on your website (not link shortener), use these query types with website_id:

bash
curl -X POST -H "x-api-key: dbdy_your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "parameters": ["outbound_links", "outbound_domains"],
  "startDate": "2024-01-01",
  "endDate": "2024-01-31",
  "limit": 20
}' \
"https://api.databuddy.cc/v1/query?website_id=web_123"
json
{
"success": true,
"data": [
  {
    "parameter": "outbound_links",
    "success": true,
    "data": [
      {
        "href": "https://github.com/example/repo",
        "text": "View on GitHub",
        "total_clicks": 245,
        "unique_users": 189,
        "unique_sessions": 210,
        "percentage": 15.2,
        "last_clicked": "2024-01-31T15:42:00.000Z"
      }
    ]
  },
  {
    "parameter": "outbound_domains",
    "success": true,
    "data": [
      {
        "domain": "github.com",
        "total_clicks": 523,
        "unique_users": 412,
        "unique_links": 8,
        "percentage": 32.5
      }
    ]
  }
]
}
FeatureLink shortener (link_id)Outbound links (website_id)
PurposeClicks on your shortened URLsClicks on external links from your site
Query parameterlink_idwebsite_id
Query typeslink_*outbound_links, outbound_domains
Data sourceLink redirect trackingWebsite visitor tracking

Continue with this workflow

For the dashboard workflow behind these endpoints, read the campaign links guide. The UTM tracking walkthrough explains how to verify website conversions separately from the click counts returned by link analytics.

How is this guide?