How do I get a Firecrawl API key?
Getting a Firecrawl API key is straightforward and requires just a few steps. Firecrawl provides API keys to authenticate your requests and track usage across their web scraping and crawling services. This guide walks you through the complete process of obtaining, configuring, and using your Firecrawl API key.
Creating a Firecrawl Account
Before you can get an API key, you need to create a Firecrawl account:
- Visit the Firecrawl Website: Navigate to firecrawl.dev and click on the "Sign Up" or "Get Started" button
- Choose Your Authentication Method: You can sign up using:
- Email and password
- GitHub OAuth
- Google OAuth
- Verify Your Email: If you signed up with email, check your inbox for a verification link
- Complete Your Profile: Fill in any required information about your intended usage
Obtaining Your API Key
Once your account is created and verified, follow these steps to get your API key:
Step 1: Access the Dashboard
Log into your Firecrawl account and navigate to the dashboard. You should see a sidebar or navigation menu with various options.
Step 2: Navigate to API Keys Section
Look for the "API Keys" or "Settings" section in the dashboard. This is typically found in: - The main navigation menu - Account settings - Developer settings
Step 3: Generate Your API Key
Click on "Create API Key" or "Generate New Key". You may be prompted to: - Name your API key (useful if you'll have multiple keys for different projects) - Set permissions or rate limits (depending on your plan) - Confirm the creation
Step 4: Copy and Store Your API Key
Important: Once generated, copy your API key immediately. For security reasons, Firecrawl typically only shows the full key once. Store it securely in: - A password manager - Environment variables (recommended for production) - Secure configuration files (never commit to version control)
Your API key will look something like this:
fc-1234567890abcdef1234567890abcdef1234567890abcdef
Using Your Firecrawl API Key
Once you have your API key, you can start making authenticated requests to the Firecrawl API. Here's how to use it in different programming languages:
Python Example
import requests
import os
# Store your API key in an environment variable
api_key = os.getenv('FIRECRAWL_API_KEY')
# Scrape endpoint example
url = "https://api.firecrawl.dev/v0/scrape"
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
payload = {
'url': 'https://example.com',
'formats': ['markdown', 'html']
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
data = response.json()
print(data['data']['markdown'])
else:
print(f"Error: {response.status_code} - {response.text}")
JavaScript/Node.js Example
const axios = require('axios');
// Store your API key in an environment variable
const apiKey = process.env.FIRECRAWL_API_KEY;
async function scrapeWithFirecrawl(targetUrl) {
try {
const response = await axios.post(
'https://api.firecrawl.dev/v0/scrape',
{
url: targetUrl,
formats: ['markdown', 'html']
},
{
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
}
);
console.log(response.data.data.markdown);
return response.data;
} catch (error) {
console.error('Scraping failed:', error.response?.data || error.message);
throw error;
}
}
scrapeWithFirecrawl('https://example.com');
Using the Official Firecrawl SDK
Firecrawl provides official SDKs that simplify authentication and API calls:
Python SDK:
from firecrawl import FirecrawlApp
# Initialize with your API key
app = FirecrawlApp(api_key='your-api-key-here')
# Scrape a single page
result = app.scrape_url('https://example.com')
print(result['markdown'])
# Crawl an entire website
crawl_result = app.crawl_url('https://example.com', {
'crawlerOptions': {
'maxDepth': 2,
'limit': 10
}
})
JavaScript SDK:
import FirecrawlApp from '@mendable/firecrawl-js';
// Initialize with your API key
const app = new FirecrawlApp({ apiKey: 'your-api-key-here' });
// Scrape a single page
const scrapeResult = await app.scrapeUrl('https://example.com');
console.log(scrapeResult.markdown);
// Crawl an entire website
const crawlResult = await app.crawlUrl('https://example.com', {
crawlerOptions: {
maxDepth: 2,
limit: 10
}
});
Best Practices for API Key Management
Environment Variables
Never hardcode API keys in your source code. Use environment variables instead:
Linux/macOS:
export FIRECRAWL_API_KEY="your-api-key-here"
Windows (PowerShell):
$env:FIRECRAWL_API_KEY="your-api-key-here"
Using .env files: ```
.env file
FIRECRAWL_API_KEY=your-api-key-here ```
Then load it in your application:
# Python with python-dotenv
from dotenv import load_dotenv
load_dotenv()
// Node.js with dotenv
require('dotenv').config();
Security Considerations
- Never commit API keys to version control: Add
.env
and configuration files containing keys to your.gitignore
- Use different keys for different environments: Have separate keys for development, staging, and production
- Rotate keys regularly: Especially if a key may have been compromised
- Monitor usage: Regularly check your API usage in the Firecrawl dashboard to detect unauthorized access
- Set up rate limits: Configure appropriate rate limits for your API keys to prevent abuse
Managing Multiple API Keys
As your projects grow, you may need multiple API keys:
- Project-based keys: Create separate keys for different applications or services
- Team-based keys: Assign keys to different team members for accountability
- Environment-based keys: Use different keys for development, testing, and production
To create additional keys, simply repeat the generation process in your Firecrawl dashboard. Give each key a descriptive name like:
- production-web-app
- development-testing
- data-pipeline-service
Troubleshooting Common Issues
Authentication Errors
If you receive a 401 Unauthorized
error:
- Verify your API key is correct (no extra spaces or characters)
- Ensure you're using the correct header format: Authorization: Bearer YOUR_KEY
- Check if your API key has been revoked or expired
Rate Limit Errors
If you receive a 429 Too Many Requests
error:
- Check your current plan's rate limits in the dashboard
- Implement exponential backoff in your code
- Consider upgrading your plan for higher limits
Invalid API Key Format
Ensure your API key:
- Starts with the correct prefix (typically fc-
)
- Contains only valid characters
- Is the complete key (wasn't truncated when copying)
Upgrading and Plan Limits
Different Firecrawl plans come with different features and limits:
- Free Tier: Limited requests per month, basic features
- Starter Plan: Higher rate limits, more requests
- Professional Plan: Advanced features, priority support
- Enterprise: Custom limits, dedicated support
Check your current usage and limits in the Firecrawl dashboard to determine if you need to upgrade.
Alternative Authentication Methods
While API keys are the primary authentication method, Firecrawl may support additional options for enterprise customers:
- OAuth 2.0: For more complex authentication flows
- IP Whitelisting: Additional security layer for production environments
- Webhook Authentication: For event-driven architectures
Contact Firecrawl support to learn about advanced authentication options for your specific use case.
Integrating with Other Tools
Once you have your API key configured, you can integrate Firecrawl with various tools and platforms. For instance, if you're building browser automation workflows, you might combine Firecrawl's API capabilities with tools like Puppeteer to handle dynamic content and AJAX requests or to monitor network activity during your scraping operations.
Testing Your API Key
Before deploying to production, test your API key with a simple request:
curl -X POST https://api.firecrawl.dev/v0/scrape \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com"
}'
A successful response confirms your API key is working correctly.
Conclusion
Obtaining and using a Firecrawl API key is a simple process that unlocks powerful web scraping capabilities. By following the security best practices outlined above—using environment variables, rotating keys regularly, and monitoring usage—you can safely integrate Firecrawl into your applications. Whether you're building a data pipeline, monitoring competitors, or extracting structured data from websites, your Firecrawl API key is the gateway to efficient, scalable web scraping.
Remember to keep your API keys secure, monitor your usage regularly through the dashboard, and choose the right plan for your project's needs. With proper configuration and authentication, you'll be ready to leverage Firecrawl's full suite of web scraping features.