What Programming Languages Does Firecrawl Support?
Firecrawl provides official Software Development Kits (SDKs) for multiple programming languages, making it accessible to developers across different technology stacks. The platform supports Python, JavaScript/Node.js, Go, and Ruby through native SDKs, while also offering a REST API that can be used with any language that supports HTTP requests.
Official Firecrawl SDKs
1. Python SDK
Python is one of the most popular languages for web scraping, and Firecrawl provides comprehensive Python support through its official SDK.
Installation:
pip install firecrawl-py
Basic Usage Example:
from firecrawl import FirecrawlApp
# Initialize the Firecrawl client
app = FirecrawlApp(api_key='your_api_key')
# 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',
params={
'crawlerOptions': {
'maxDepth': 2,
'limit': 10
}
}
)
# Access crawled pages
for page in crawl_result['data']:
print(f"URL: {page['url']}")
print(f"Content: {page['markdown'][:100]}...")
Extract Structured Data with Python:
# Use LLM-powered extraction
schema = {
'type': 'object',
'properties': {
'title': {'type': 'string'},
'price': {'type': 'number'},
'description': {'type': 'string'}
}
}
result = app.scrape_url(
'https://example.com/product',
params={
'formats': ['extract'],
'extract': {
'schema': schema
}
}
)
print(result['extract'])
2. JavaScript/Node.js SDK
For JavaScript developers working with Node.js, Firecrawl offers a native SDK that integrates seamlessly into modern JavaScript applications.
Installation:
npm install @mendable/firecrawl-js
Basic Usage Example:
import FirecrawlApp from '@mendable/firecrawl-js';
// Initialize the client
const app = new FirecrawlApp({ apiKey: 'your_api_key' });
// Scrape a single page
async function scrapePage() {
const result = await app.scrapeUrl('https://example.com');
console.log(result.markdown);
}
// Crawl a website
async function crawlWebsite() {
const crawlResult = await app.crawlUrl('https://example.com', {
crawlerOptions: {
maxDepth: 2,
limit: 10
}
});
crawlResult.data.forEach(page => {
console.log(`URL: ${page.url}`);
console.log(`Title: ${page.metadata.title}`);
});
}
scrapePage();
crawlWebsite();
TypeScript Support:
The JavaScript SDK includes TypeScript definitions for type-safe development:
import FirecrawlApp, { ScrapeResponse, CrawlResponse } from '@mendable/firecrawl-js';
const app = new FirecrawlApp({ apiKey: process.env.FIRECRAWL_API_KEY! });
async function scrapeWithTypes(): Promise<void> {
const result: ScrapeResponse = await app.scrapeUrl('https://example.com', {
formats: ['markdown', 'html']
});
console.log(result.markdown);
console.log(result.html);
}
3. Go SDK
Go developers can leverage Firecrawl's official Go SDK for high-performance web scraping applications.
Installation:
go get github.com/mendableai/firecrawl-go
Basic Usage Example:
package main
import (
"fmt"
"log"
"github.com/mendableai/firecrawl-go"
)
func main() {
// Initialize client
app, err := firecrawl.NewFirecrawlApp("your_api_key")
if err != nil {
log.Fatal(err)
}
// Scrape a single page
scrapeResult, err := app.ScrapeURL("https://example.com", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(scrapeResult.Markdown)
// Crawl a website
crawlParams := map[string]interface{}{
"crawlerOptions": map[string]interface{}{
"maxDepth": 2,
"limit": 10,
},
}
crawlResult, err := app.CrawlURL("https://example.com", crawlParams)
if err != nil {
log.Fatal(err)
}
for _, page := range crawlResult.Data {
fmt.Printf("URL: %s\n", page.URL)
fmt.Printf("Content: %s\n", page.Markdown[:100])
}
}
4. Ruby SDK
Ruby developers can use Firecrawl's official Ruby gem for web scraping tasks.
Installation:
gem install firecrawl
Or add to your Gemfile:
gem 'firecrawl'
Basic Usage Example:
require 'firecrawl'
# Initialize the client
app = Firecrawl::FirecrawlApp.new(api_key: 'your_api_key')
# Scrape a single page
result = app.scrape_url('https://example.com')
puts result['markdown']
# Crawl a website
crawl_result = app.crawl_url('https://example.com', {
crawlerOptions: {
maxDepth: 2,
limit: 10
}
})
crawl_result['data'].each do |page|
puts "URL: #{page['url']}"
puts "Title: #{page['metadata']['title']}"
end
Using Firecrawl REST API Directly
While the official SDKs provide the most convenient way to use Firecrawl, you can also interact with the REST API directly using any programming language that supports HTTP requests. This approach is useful for languages without official SDK support, such as PHP, Java, C#, or Rust.
Example with cURL (Command Line)
# Scrape a single page
curl -X POST https://api.firecrawl.dev/v0/scrape \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_api_key' \
-d '{
"url": "https://example.com",
"formats": ["markdown", "html"]
}'
# Start a crawl job
curl -X POST https://api.firecrawl.dev/v0/crawl \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer your_api_key' \
-d '{
"url": "https://example.com",
"crawlerOptions": {
"maxDepth": 2,
"limit": 10
}
}'
Example with PHP
<?php
$apiKey = 'your_api_key';
$url = 'https://example.com';
$ch = curl_init('https://api.firecrawl.dev/v0/scrape');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'url' => $url,
'formats' => ['markdown']
]));
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result['markdown'];
?>
Example with Java
import java.net.http.*;
import java.net.URI;
import com.google.gson.Gson;
public class FirecrawlExample {
public static void main(String[] args) throws Exception {
String apiKey = "your_api_key";
String requestBody = """
{
"url": "https://example.com",
"formats": ["markdown"]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.firecrawl.dev/v0/scrape"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + apiKey)
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Advanced Features Across All Languages
Regardless of which programming language you choose, Firecrawl provides consistent features across all SDKs:
1. Multiple Output Formats
Request data in various formats to suit your needs:
# Python example
result = app.scrape_url('https://example.com', params={
'formats': ['markdown', 'html', 'rawHtml', 'links', 'screenshot']
})
2. Crawler Configuration
Fine-tune crawling behavior similar to how Puppeteer handles browser automation:
// JavaScript example
const result = await app.crawlUrl('https://example.com', {
crawlerOptions: {
maxDepth: 3,
limit: 50,
includes: ['blog/*'],
excludes: ['admin/*'],
allowBackwardCrawling: false,
allowExternalContentLinks: false
}
});
3. JavaScript Rendering
Handle dynamic content and AJAX requests with JavaScript execution:
# Ruby example
result = app.scrape_url('https://example.com', {
waitFor: 5000, # Wait 5 seconds for JavaScript to load
timeout: 30000
})
4. Custom Wait Conditions
Similar to Puppeteer's waitFor functionality, you can specify wait conditions:
// Go example
params := map[string]interface{}{
"waitFor": 3000, // milliseconds
"timeout": 60000,
}
result, err := app.ScrapeURL("https://example.com", params)
Choosing the Right Language for Firecrawl
When deciding which language to use with Firecrawl, consider:
- Python - Best for data science, machine learning pipelines, and rapid prototyping
- JavaScript/Node.js - Ideal for full-stack applications, serverless functions, and modern web apps
- Go - Excellent for high-performance applications, concurrent scraping, and microservices
- Ruby - Perfect for Rails applications and Ruby-based automation workflows
- REST API - Use for any other language or when you need maximum flexibility
Best Practices for Multi-Language Projects
If you're working with Firecrawl across multiple services in different languages:
- Consistent Configuration: Store API keys and configuration in environment variables
- Error Handling: Implement similar error handling patterns across languages
- Rate Limiting: Respect API rate limits regardless of the client language
- Logging: Maintain consistent logging formats for debugging
- Testing: Write integration tests in each language to ensure consistent behavior
Conclusion
Firecrawl's multi-language support makes it accessible to virtually any development team. Whether you're building a Python data pipeline, a Node.js web application, a Go microservice, or a Ruby on Rails app, Firecrawl provides native SDK support with consistent APIs. For languages without official SDKs, the REST API offers a straightforward integration path with comprehensive documentation.
The key to success with Firecrawl is understanding your project's requirements and choosing the language that best fits your existing infrastructure while leveraging Firecrawl's powerful web scraping and data extraction capabilities.