This document explains how to use the get_session_downloads tool to retrieve files downloaded during a HyperBrowser session.
The get_session_downloads tool allows you to retrieve files that were downloaded by the browser during a HyperBrowser session. This is useful for automating downloads of reports, documents, images, or any other files from websites.
For this feature to work, you must enable download tracking when creating your session:
{
"task": "Download the latest report from example.com",
"sessionOptions": {
"saveDownloads": true
}
}The saveDownloads: true option tells HyperBrowser to capture and store any files downloaded during the session.
- Create a session with downloads enabled: Use any browser automation tool (browser_use_agent, openai_computer_use_agent, claude_computer_use_agent) with
saveDownloads: truein sessionOptions - Complete the task: Let the agent complete the task that involves downloading files
- Retrieve the downloads: Use
get_session_downloadswith the session ID to get access to the downloaded files
When you call the HyperBrowser downloads API, you get a response like:
{
"status": "completed",
"downloadsUrl": "https://temporary-url-to-downloads.zip",
"error": null
}pending: Session is still runningin_progress: Downloads are being processedcompleted: Downloads are ready to retrievefailed: Something went wrong
{
"sessionId": "session_abc123xyz"
}This returns the status and a temporary URL to download the zip file containing all session downloads.
{
"sessionId": "session_abc123xyz",
"downloadZip": true,
"outputPath": "./downloads/my-session-files.zip"
}This will:
- Get the downloads URL from the API
- Download the zip file
- Save it to the specified local path
// Using browser_use_agent
{
"task": "Go to https://example.com/reports and download the Q4 2024 report",
"sessionOptions": {
"saveDownloads": true // IMPORTANT: Enable download tracking
},
"maxSteps": 25
}
// Response includes session ID
{
"sessionId": "session_abc123xyz",
// ... other response data
}// Option A: Just get the download URL
{
"sessionId": "session_abc123xyz"
}
// Response
{
"status": "completed",
"downloadsUrl": "https://temporary-storage.hyperbrowser.ai/downloads/abc123.zip"
}
// Option B: Download the zip file locally
{
"sessionId": "session_abc123xyz",
"downloadZip": true,
"outputPath": "./reports/q4-2024-report.zip"
}
// Response
{
"status": "completed",
"message": "Downloads zip file saved to: ./reports/q4-2024-report.zip"
}-
Temporary URLs: The
downloadsUrlis temporary and will expire after some time. Download the file promptly if you need it. -
Session Options: You must set
saveDownloads: truein the session options BEFORE running the task. You cannot enable it retroactively. -
File Format: All downloaded files are packaged into a single ZIP file.
-
Tool Compatibility: The
saveDownloadsoption works with all browser automation tools:browser_use_agentopenai_computer_use_agentclaude_computer_use_agent
-
Path Requirements: When using
downloadZip: true, you must provide anoutputPath. The directory will be created automatically if it doesn't exist.
"No downloads available"
- The session hasn't completed yet, or
- No files were actually downloaded during the session, or
saveDownloadswas not enabled for the session
"Session not found"
- Invalid session ID
- Session has expired
"API Error: 404"
- The session ID doesn't exist
- Downloads have expired
- Report Downloads: Automate downloading financial reports, analytics dashboards, or business intelligence exports
- Data Collection: Download CSV/Excel files from data portals
- Document Retrieval: Download PDFs, invoices, or contracts from web applications
- Media Downloads: Save images, videos, or audio files from websites
- Batch Processing: Download multiple files in a single session and process them locally
// Step 1: Create session with multiple downloads
{
"task": "Go to https://example.com/documents, download all PDFs from January 2024",
"sessionOptions": {
"saveDownloads": true
},
"maxSteps": 50
}
// Step 2: Wait for completion, then retrieve
{
"sessionId": "session_xyz789",
"downloadZip": true,
"outputPath": "./jan-2024-documents.zip"
}
// Step 3: Extract and process locally
// All downloaded PDFs will be in the zip fileThe tool uses the HyperBrowser API endpoint:
GET https://api.hyperbrowser.ai/v1/sessions/{sessionId}/downloads
Uses the same API key as other HyperBrowser tools (from environment variables HB_API_KEY or HYPERBROWSER_API_KEY).
axios: For making HTTP requests- Node.js
fsmodule: For file system operations when downloading zip files - Node.js
pathmodule: For handling file paths
Q: I'm getting "No downloads available" but files were downloaded
A: Make sure you set saveDownloads: true in the sessionOptions when creating the session. This cannot be added after the session starts.
Q: The download URL expired
A: Download URLs are temporary. Use the downloadZip: true option immediately after the session completes, or download from the URL quickly.
Q: Can I retrieve downloads from an old session?
A: There's a retention period for session downloads. Very old sessions may have expired downloads. Check with HyperBrowser documentation for the current retention policy.
Q: The zip file is empty
A: This means no files were actually downloaded during the session. Verify that your automation task correctly triggered file downloads in the browser.
For issues specific to the HyperBrowser API or download functionality, consult: