Developer
Statistics

Top values by column and interval

Top values by column and interval with the ShortFreeURL REST API: POST /statistics/domain/42/top by interval. Compare top values across time buckets.

Complete this task in your own workspace. The screenshots use demonstration data.

1. Prepare your workspace and API key

Open Dashboard → Integrations & API → API. Create a named secret key with the smallest required scope. Use a read-only key for reporting. Store it as SHORTFREEURL_API_KEY in your environment. The secret is shown once.

ShortFreeURL API keys in a demonstration workspace
Select the scope before creating your key. Never share the secret in a screenshot. · Demo workspace. Click to enlarge.

2. Find the correct resource

Open Statistics. Select your domain. A link editor URL contains id=; use that link ID in requests. Get domain IDs from GET /api/domains. Replace example IDs 42 and 918 and the example hostname with your own values.

ShortFreeURL Statistics in a demonstration workspace
Statistics · Demo workspace. Click to enlarge.

3. Review the operation

Compare top values across time buckets. Use include and exclude dimension arrays when your plan supports advanced filters.

POST /statistics/domain/42/top_by_interval. This reads data. Inspect upgradeRequired in responses: a successful update can leave unsupported fields unchanged.

4. Choose a language and run the request

Terminal setup with PowerShell, Bash and screenshots →

Shell uses curl. Node requires a runtime with fetch. Python uses its standard library. Other examples list their required HTTP library in code. Set the API host to this installation’s deployed HTTPS origin, then run the example from your terminal or backend.

curl --request POST 'https://api.shortfreeurl.com/statistics/domain/42/top_by_interval' \
  --header "Authorization: Bearer $SHORTFREEURL_API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "period": "last30",
  "column": "country",
  "interval": "day",
  "limit": 10
}'

5. Verify the result

  1. Read the HTTP status and response. For QR exports, save the returned image instead of parsing JSON.
  2. Check the returned IDs, filters and pagination. Empty analytics on a new link is valid.
  3. For targeting, expiry or password changes, make a controlled test visit. A real visit may add to analytics. For deletion, verify the record is absent before retrying.

6. Troubleshoot safely

  • 401: check key expiry, revocation and workspace membership.
  • 403/402: check role, key scope, feature access and subscription.
  • 404: confirm the resource belongs to your workspace and domain.
  • 429: wait for Retry-After, reduce concurrency and check plan limits.
  • Timeout after a write: read the resource first; avoid creating duplicates.

Try a request in the API reference · All workflow guides