Skip to main content

Quick Start

Get your first SealMetrics API request working in under 5 minutes.


Prerequisites

  • A SealMetrics account (sign up here)
  • Your email and password for API authentication
  • A tool to make HTTP requests (cURL, Postman, or your programming language of choice)

Step 1: Authenticate

First, obtain an access token by calling the login endpoint:

curl -X POST https://app.sealmetrics.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "your-email@example.com",
"password": "your-password"
}'

Response:

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"token_type": "Bearer",
"expires_at": "2024-12-31T23:59:59Z"
}
Token Management

Save the access_token and expires_at values. Implement automatic token refresh before expiration to avoid interruptions.


Step 2: Get Your Account ID

List all accounts linked to your credentials:

curl https://app.sealmetrics.com/api/auth/accounts \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response:

{
"status": "ok",
"data": {
"000000000000000000001234": "My E-commerce Store",
"000000000000000000005678": "Marketing Agency Client"
}
}

Copy the account ID you want to query data for.


Step 3: Fetch Analytics Data

Now you can query any analytics endpoint. Here are common examples:

Get Page Views

curl "https://app.sealmetrics.com/api/report/pages?account_id=YOUR_ACCOUNT_ID&date_range=last_7_days&limit=10" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get Conversions

curl "https://app.sealmetrics.com/api/report/conversions?account_id=YOUR_ACCOUNT_ID&date_range=last_30_days" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get ROAS Evolution

curl "https://app.sealmetrics.com/api/report/roas-evolution?account_id=YOUR_ACCOUNT_ID&date_range=last_30_days&time_unit=daily" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Complete Example

Here's a full working example that authenticates and fetches data:

import requests
from datetime import datetime

# Configuration
EMAIL = "your-email@example.com"
PASSWORD = "your-password"
BASE_URL = "https://app.sealmetrics.com/api"

class SealMetricsAPI:
def __init__(self, email, password):
self.base_url = BASE_URL
self.token = None
self.expires_at = None
self._authenticate(email, password)

def _authenticate(self, email, password):
response = requests.post(
f"{self.base_url}/auth/login",
json={"email": email, "password": password}
)
response.raise_for_status()
data = response.json()
self.token = data["access_token"]
self.expires_at = datetime.fromisoformat(data["expires_at"].replace("Z", "+00:00"))
print(f"Authenticated. Token expires: {self.expires_at}")

def _headers(self):
return {"Authorization": f"Bearer {self.token}"}

def get_accounts(self):
response = requests.get(
f"{self.base_url}/auth/accounts",
headers=self._headers()
)
response.raise_for_status()
return response.json()["data"]

def get_conversions(self, account_id, date_range="last_30_days"):
response = requests.get(
f"{self.base_url}/report/conversions",
headers=self._headers(),
params={"account_id": account_id, "date_range": date_range}
)
response.raise_for_status()
return response.json()["data"]

def get_pages(self, account_id, date_range="last_7_days", limit=100):
response = requests.get(
f"{self.base_url}/report/pages",
headers=self._headers(),
params={
"account_id": account_id,
"date_range": date_range,
"limit": limit
}
)
response.raise_for_status()
return response.json()["data"]

# Usage
if __name__ == "__main__":
api = SealMetricsAPI(EMAIL, PASSWORD)

# Get accounts
accounts = api.get_accounts()
print("\nAccounts:")
for account_id, name in accounts.items():
print(f" {name} ({account_id})")

# Use first account
account_id = list(accounts.keys())[0]

# Get conversions
conversions = api.get_conversions(account_id)
total_revenue = sum(c["amount"] for c in conversions)
print(f"\nLast 30 days:")
print(f" Conversions: {len(conversions)}")
print(f" Revenue: ${total_revenue:,.2f}")

# Get top pages
pages = api.get_pages(account_id, limit=5)
print("\nTop 5 pages:")
for page in pages[:5]:
print(f" {page['url']}: {page['views']} views")

Common Date Ranges

ValueDescription
todayCurrent day
yesterdayPrevious day
last_7_daysPast 7 days
last_30_daysPast 30 days
this_monthCurrent month
last_monthPrevious month
20241101,20241130Custom range (YYYYMMDD,YYYYMMDD)

Error Handling

Always check for errors in your API calls:

response = requests.get(url, headers=headers, params=params)

if response.status_code == 401:
print("Token expired - re-authenticate")
elif response.status_code == 429:
retry_after = response.headers.get("Retry-After", 60)
print(f"Rate limited - wait {retry_after} seconds")
elif response.status_code != 200:
error = response.json()
print(f"Error: {error.get('message', 'Unknown error')}")
else:
data = response.json()["data"]

Next Steps