Core ConceptsAuthentication
Core Concepts

Authentication and API Keys

Learn how to securely authenticate with the FetchMedia API using API keys and handle permissions for accessing video fetching and processing endpoints.

const response = await fetch('https://api.example.com/v1/videos/tiktok?url=https://www.tiktok.com/@user/video/123', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({})
});
const data = await response.json();
console.log(data);
{
  "error": {
    "code": "invalid_token",
    "message": "Invalid or expired API key"
  }
}

Overview

FetchMedia uses simple API key authentication to secure access to video fetching and processing endpoints. You generate an API key from your dashboard and include it in the Authorization header of every request. This method grants permissions for actions like downloading TikTok videos, editing with FFmpeg, or repurposing Instagram Reels.

All requests to https://api.example.com require a valid key. Keys have built-in rate limits and expiration to protect your account.

New accounts include one free API key with generous trial limits. Upgrade for production use.

Generating and Managing API Keys

Access your FetchMedia dashboard at https://dashboard.example.com to create and manage keys.

Log In

Visit https://dashboard.example.com and sign in with your credentials.

Navigate to Keys

Click API Keys in the sidebar.

Create Key

Click Generate New Key. Copy the key immediately—it displays only once.

Set Permissions

Assign scopes like video:fetch or video:process. Save changes.

Manage keys by viewing usage stats, regenerating, or revoking them. Revoke compromised keys immediately.

Including API Keys in Requests

Add your key to the Authorization header as Bearer YOUR_API_KEY.

header
Authorizationstring
Required

Bearer token for authentication. Format: Bearer sk_YourKeyHere.

Use these examples to fetch a TikTok video:

Replace YOUR_API_KEY with your actual key.

Authentication Methods

Choose based on your setup:

Use header auth in tools like Postman or Insomnia.

Best Practices and Security

Never commit API keys to Git. Use environment variables like process.env.FETCHMEDIA_API_KEY.

  • Store keys in secure vaults (e.g., AWS Secrets Manager).
  • Rotate keys every 90 days.
  • Use least-privilege scopes.
  • Monitor usage in your dashboard.

Next Steps

Was this page helpful?
Built with Documentation.AI

Last updated today