API Keys

Authenticate calls to the Besökskollen Public API with API keys.

Do I need an API key?

API keys are needed if you want to display visitor-based data (e.g. "Popular Products") automatically on your site. This requires a developer or agency who can integrate the API into your site.

If you just want to see statistics in the Besökskollen dashboard, you don't need an API key.

What are API keys?

API keys are used to authenticate calls to our Public API. Each key is linked to a specific site and has a rate limit of 1000 calls per hour.

With API keys you can:

  • Fetch popular products based on visitor data
  • Display trending categories on your site
  • Analyze which partners drive the most traffic
  • Build dashboards and integrations

Create an API key

  1. 1. Log in to Besökskollen and go to Settings
  2. 2. Click on API Keys
  3. 3. Click Create API Key
  4. 4. Choose which site the key should be linked to
  5. 5. Give the key a name (e.g. "Production" or "Backup")
  6. 6. Click Create

Important

Copy and save the API key immediately. It is only shown once and cannot be recovered. If you lose the key, you must create a new one.

Using the API key

Simply explained

The API key is like a password that proves you have the right to fetch data. Your developer puts the key in the code so your site can "talk to" Besökskollen.

Give the key to your developer - they know how to use it.

For developers: Send the key in the Authorization header as a Bearer token:

curl -H "Authorization: Bearer bk_din_api_nyckel_här" \
  "https://besokskollen.se/api/v1/popular/products?site_id=din-sajt"

Available endpoints

EndpointDescription
GET /api/v1/popular/productsPopular products based on clicks
GET /api/v1/popular/categoriesPopular categories
GET /api/v1/popular/partnersPartner statistics and traffic shares
POST /api/v1/batchFetch multiple endpoints in one call

Rate limiting

Each API key has a rate limit of 1000 calls per hour. If you exceed the limit, you'll get a 429 Too Many Requests response.

Rate limit status is returned in response headers:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1704067200

Example

Fetch the 10 most popular products from the last 7 days:

curl -H "Authorization: Bearer bk_abc123..." \
  "https://besokskollen.se/api/v1/popular/products?site_id=mobildelar-se&days=7&limit=10"

Response:

{
  "data": [
    {
      "product_id": "iphone-15-skal-svart",
      "product_slug": "iphone-15-skal-svart",
      "clicks": 47
    },
    {
      "product_id": "samsung-s24-skarmskydd",
      "product_slug": "samsung-s24-skarmskydd",
      "clicks": 35
    }
  ],
  "meta": {
    "period": {
      "from": "2025-01-01T00:00:00Z",
      "to": "2025-01-07T23:59:59Z"
    },
    "total_clicks": 523,
    "confidence": "high"
  }
}

Security tips

  • Never store API keys in client-side code or public repositories
  • Use environment variables to store keys
  • Create separate keys for different purposes
  • Rotate keys regularly for increased security
  • Delete unused keys