Steps to Get Started
1
Prerequisites
- Bright Data API Key
- Node.js 20.18.1+
- TypeScript (recommended)
2
Installation
Install the required packages:
3
Create Bright Data Tools
Create a file
brightdata-tools.ts
with the following content:brightdata-tools.ts
4
Usage Examples
- Next.js App Router
- Node.js Script
- Exclude Specific Tools
- Advanced: Multiple Datasets
Create an API route that uses Bright Data tools with any AI provider:Then use it in your component:
app/api/chat/route.ts
app/page.tsx
Example Output
Scraping Example
User Input: “Scrape https://example.com and tell me what it’s about” AI Response:Search Example
User Input: “Search for best mechanical keyboards 2024” AI Response:Amazon Product Example
User Input: “Get information about Amazon product B0D2Q9397Y” AI Response:Available Tools
Tool | Description | Use Cases |
---|---|---|
scrape | Scrape any website and return markdown | Content extraction, monitoring, and data collection |
search | Search Google, Bing, or Yandex | Research, competitive analysis, trend monitoring |
amazonProduct | Get Amazon product details | Price monitoring, product research, and comparison |
linkedinCollectProfiles | Get LinkedIn profile details | Data enrichment, people research |
Additional Dataset Tools
The Bright Data SDK supports many more datasets that you can integrate:- LinkedIn: Profiles, companies, jobs, posts
- Instagram: Profiles, posts, reels, comments
- Facebook: Posts, marketplace, events, reviews
- Twitter/X: Posts and profiles
- TikTok: Videos, profiles, comments
- Google Maps: Reviews and business information
- E-commerce: Walmart, eBay, Best Buy, Etsy, Zara
Best Practices
- Error Handling: Always wrap tool executions in try-catch blocks
- Rate Limiting: Be mindful of API rate limits when making multiple requests
- Data Format: Use
markdown
format for scraping to get clean, readable content - Async Operations: For large datasets, use
async: true
to avoid timeouts - Country Targeting: Use country codes for localized results when needed
Environment Variables
.env.local