INNER CODE UNIT · Python

fetch_linkedin_profile

sunithvs/devb.io · api/main.py:139

async def fetch_linkedin_profile(username: Annotated[str, Depends(verify_linkedin_username)]):
    """Fetch LinkedIn profile data"""
    try:
        cache_key = f"linkedin_profile:{username}"
        if Settings.CACHE_ENABLED:
            cached_response = await redis_client.get(cache_key)
        
            if cached_response and not Settings.DEBUG:
                return json.loads(cached_response)

        fetcher = LinkedInProfileFetcher()
        profile_data = await fetcher.fetch_profile_async(username)
        
        if "error" in profile_data:
            raise HTTPException(status_code=400, detail=profile_data["error"])
        if Settings.CACHE_ENABLED:
            await redis_client.setex(name=cache_key, value=json.dumps(profile_data), time=Settings.DEFAULT_CACHE_TTL)
        return profile_data

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…