outgoing calls route
Build and Push Docker Images / build-and-push (push) Successful in 2m33s

This commit is contained in:
2025-07-10 18:02:42 +02:00
parent e295cde9e3
commit 5f5941703c
2 changed files with 149 additions and 1 deletions
+31 -1
View File
@@ -7,7 +7,8 @@ from app.services.browser import (
visit_url_service,
extract_seo_service,
extract_meta_tags_service,
detect_pagination_service
detect_pagination_service,
capture_outgoing_calls_service
)
router = APIRouter()
@@ -122,4 +123,33 @@ async def detect_pagination(url: str, skipCache: bool = False, x_api_key: Option
return result
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@router.get("/outgoing-calls")
async def capture_outgoing_calls(url: str, skipCache: bool = False, x_api_key: Optional[str] = Header(None)):
"""Capture outgoing API calls from a website"""
# Validate API key
if not x_api_key or x_api_key != API_KEY:
raise HTTPException(status_code=401, detail="Invalid API key")
# Decode URL if it's encoded
decoded_url = unquote(url)
# Check cache first (unless skipCache is True)
if not skipCache:
cached_result = get_cached_data(decoded_url, "outgoing_calls")
if cached_result:
return cached_result
try:
# Call the service function
result = await capture_outgoing_calls_service(decoded_url)
# Save to cache
if(result["status"] == "success"):
save_to_cache(decoded_url, "outgoing_calls", result)
return result
except Exception as e:
print(f"Error capturing outgoing calls for URL {decoded_url}: {e}")
raise HTTPException(status_code=500, detail=str(e))