Skip to main content
Your API key authenticates every request you make to the ScrapeGraphAI API. Keep it secure and rotate it if you suspect it has been compromised.

Finding your API key

  1. Log in to the ScrapeGraphAI dashboard.
  2. Navigate to Settings.
  3. Your API key is displayed in the API Key section.

Using your API key

Pass the key in the SGAI-APIKEY header for direct API calls, or provide it when initialising the SDK:
from scrapegraph_py import Client

client = Client(api_key="your-api-key")

Keeping your key secure

  • Never commit your API key to a public repository. Use environment variables instead:
# .env
SGAI_API_KEY=your-api-key-here
import os
from scrapegraph_py import Client

client = Client(api_key=os.getenv("SGAI_API_KEY"))
  • Never expose your key in frontend code. Make API calls from a server or backend function.
  • Add .env to your .gitignore to avoid accidentally committing secrets.

Rotating your API key

If your key has been exposed or you want to rotate it for security:
  1. Go to Settings in the dashboard.
  2. Click Regenerate API Key.
  3. Copy the new key immediately — it will only be shown once.
  4. Update all services and environment variables that use the old key.
  5. The old key will be invalidated immediately.
Rotating your key will invalidate the old one. Any service still using the old key will start receiving 401 Unauthorized errors.