Docs/API REFERENCE/Get your API key

Get your API key

Your API key lets you access your TrackFox analytics data without using the app. This guide will show you how to obtain and configure your API key.

Prerequisites

Before you can get your API key, you need:

  • A TrackFox account
  • At least one website added to your account
  • Admin access to the website (not a teammate access)

Step 1: Navigate to Website Settings

  1. Go to your dashboard and select your website
  2. Click on the dropdown menu for your website in the top left of your dashboard
  3. Click on "Site Settings"

Site Settings screenshot

Step 2: Generate API Key

  1. Under "API" tab, you'll be able to generate your API key for that website
  2. Be sure to copy it immediately as we won't be able to show it to you again for security reasons
  3. Do NOT commit this key to source control and keep it safe

Get API Key from API Settings

Step 3: Configure Environment Variables

Add your API key to your environment variables:

# .env.local
TRACKFOX_API_KEY=your_api_key_here
TRACKFOX_WEBSITE_ID=your_website_id_here

Using Your API Key

Basic Authentication

Include your API key in the Authorization header:

const response = await fetch("https://trackfox.app/api/v1/realtime", {
  headers: {
    Authorization: `Bearer ${process.env.TRACKFOX_API_KEY}`,
    "Content-Type": "application/json",
  },
});

Example: Fetching Real-time Data

async function getRealtimeVisitors() {
  const response = await fetch("https://trackfox.app/api/v1/realtime", {
    headers: {
      Authorization: `Bearer ${process.env.TRACKFOX_API_KEY}`,
      "Content-Type": "application/json",
    },
  });

  const data = await response.json();
  return data;
}

Troubleshooting

Invalid API Key Error

If you receive an "Invalid API Key" error:

  1. Verify the API key is correct
  2. Check that the key hasn't expired
  3. Ensure you're using the correct website ID
  4. Contact support if the issue persists

Next Steps

Now that you have your API key, you can:

Need help? Contact us for assistance.

Suggest features? We'd love your feedback