A FastAPI-based LinkedIn Profile Scraper REST Server that provides intelligent profile scraping with RAMS (Redis Agent Memory System) caching and BrightData fallback.
- 🚀 Smart Scraping Strategy: RAMS-first approach with BrightData fallback
- 💾 Intelligent Caching: Stores profile data and activities in RAMS for fast retrieval
- 🔄 Automatic Fallback: Falls back to BrightData API when cached data is unavailable
- 📊 Activity Tracking: Captures and stores recent LinkedIn activities
- 🌐 REST API: Clean HTTP endpoints for easy integration
- ⚡ Fast Response: Cached profiles return instantly
- Python 3.13+
- uv package manager
- Access to RAMS (Redis Agent Memory System)
- BrightData API credentials
-
Clone the repository
git clone <repository-url> cd linkedin-ai-copilot
-
Initialize the project with uv
uv init --name linkedin-ai-copilot
-
Install dependencies
uv add fastapi pydantic python-dotenv requests uvicorn agent-memory-client
-
Configure environment variables Create a
.envfile in the project root:MEMORY_SERVER_URL=http://localhost:8000 # Add other environment variables as needed
-
Start the server
uv run python linkedin_scraper_server.py
Or if port 8001 is already in use:
uv run python -c " import uvicorn import sys sys.path.insert(0, '.') from linkedin_scraper_server import app uvicorn.run(app, host='0.0.0.0', port=8002, log_level='info') "
- Default:
http://localhost:8001 - Alternative:
http://localhost:8002(if port 8001 is in use)
GET /Returns API information and available endpoints.
GET /healthChecks server health and RAMS connection status.
POST /scrape
Content-Type: application/json
{
"url": "https://www.linkedin.com/in/username/",
"user_id": "api_user"
}GET /scrape/{username}?user_id=api_userScrape a LinkedIn profile:
curl -X GET "http://localhost:8002/scrape/niels-schmidt-890b96303" \
-H "accept: application/json"Response format:
{
"success": true,
"profile_data": {
"id": "username",
"name": "Full Name",
"city": "City, State, Country",
"followers": 123,
"connections": 456,
"current_company": {...},
"activity_summary": "User has X recent activities: Y liked, Z commented."
},
"formatted_output": "...",
"cached": false,
"error": null
}- Check RAMS: Search for cached profile data
- BrightData Fallback: If no cache found, scrape from BrightData API
- Store Results: Cache new data in RAMS for future requests
- Activity Processing: Store individual activities as separate memories
- FastAPI: Web framework for REST API
- Pydantic: Data validation and serialization
- python-dotenv: Environment variable management
- requests: HTTP client for BrightData API
- uvicorn: ASGI server
- agent-memory-client: RAMS integration
linkedin-ai-copilot/
├── linkedin_scraper_server.py # Main server application
├── pyproject.toml # Project configuration
├── README.md # This file
├── .env # Environment variables (create this)
└── .venv/ # Virtual environment (auto-created)
# Activate virtual environment
source .venv/bin/activate
# Run server directly
python linkedin_scraper_server.py
# Or with custom port
uvicorn linkedin_scraper_server:app --host 0.0.0.0 --port 8002 --reload| Variable | Description | Default |
|---|---|---|
MEMORY_SERVER_URL |
RAMS server URL | http://localhost:8000 |
[Add your license information here]
[Add contributing guidelines here]