Skip to main content

What is P2P Download?

P2P downloads let you receive a real-time notification the moment a file is downloaded in your browser session, then fetch the file directly from the active session — no polling, no waiting for Anchor to process the file, no storage APIs required.

How It Works

Traditional downloads:
Browser downloads file → Anchor stores the file → You poll GET /downloads → Fetch from Anchor storage
P2P downloads:
Browser downloads file → Anchor.downloadReady CDP event fires → You fetch directly from the browser
When a file is downloaded, the browser emits a custom CDP event (Anchor.downloadReady) over your existing WebSocket connection. The event includes a pre-built fetch URL that streams the file bytes directly from the browser’s disk.

Implementation

1

Connect to the session and listen for the CDP event

Connect Playwright over CDP as usual, then open a CDPSession on the page to listen for the Anchor.downloadReady event.
2

Trigger the download

Use Playwright as normal to navigate and click the download link.
3

Receive the event and fetch the file

Wait for the Anchor.downloadReady event, then use the p2pDownloadUrl from the event params to fetch the file.

The Anchor.downloadReady Event

The event is emitted on the CDP WebSocket connection as soon as the file lands on disk.

Fetch Endpoint

This endpoint streams the file directly from the active session. It is only available while the session is active. Once the session ends, use the standard session downloads API to retrieve files from Anchor storage.

Limitations

  • The P2P fetch URL is only valid while the session is running. After the session ends, the file is no longer accessible via this endpoint.
  • Files are still stored by Anchor in the background as a fallback. Once the session completes, they are accessible via the standard list session downloads API.
  • Blob and data URL downloads (files generated client-side in JavaScript) are supported.