# Downloading Media from OnlyFans CDN URL: /introduction/guides/downloading-media Learn how to download photos/videos/audio from OnlyFans CDN URLs and store them locally or in your cloud storage. *** title: Downloading Media from OnlyFans CDN description: "Learn how to download photos/videos/audio from OnlyFans CDN URLs and store them locally or in your cloud storage." icon: Download -------------- OnlyFans API makes it easy to download media files directly from OnlyFans CDN URLs. You can download photos, videos, and audio files by calling our download endpoint with the CDN URL. ## Download media from OnlyFans CDN The full media download endpoint documentation can be found [here](/api-reference/media/download-media-from-the-only-fans-cdn). Media can be downloaded by calling GET `https://app.onlyfansapi.com/api/{account}/media/download/{ONLYFANS_CDN_URL}`. The `{ONLYFANS_CDN_URL}` parameter should be a URL from OnlyFans CDN (e.g., `https://cdn2.onlyfans.com/files/e/e5/123/600x400_123.jpg?Tag=2&u=123&Policy=123&Signature=signature&Key-Pair-Id=123`). You can just enter the OnlyFans CDN URL after the `.../media/download/{ONLYFANS_CDN_URL}` without any need for encoding the URL. ```bash tab="cURL" curl --location 'https://app.onlyfansapi.com/api/{account}/media/download/https://cdn2.onlyfans.com/files/e/e5/123/600x400_123.jpg?Tag=2&u=123&Policy=123&Signature=signature&Key-Pair-Id=123' \ --header 'Authorization: Bearer {token}' \ --output 'downloaded-media.jpg' ``` ```ts tab="JavaScript (Fetch)" const myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer {token}"); const cdnUrl = "https://cdn2.onlyfans.com/files/e/e5/123/600x400_123.jpg?Tag=2&u=123&Policy=123&Signature=signature&Key-Pair-Id=123"; const requestOptions = { method: "GET", headers: myHeaders, }; fetch( `https://app.onlyfansapi.com/api/{account}/media/download/${cdnUrl}`, requestOptions ) .then((response) => response.blob()) .then((blob) => { // Save the blob to a file or process it const url = window.URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = "downloaded-media.jpg"; a.click(); }) .catch((error) => console.error(error)); ``` ```js tab="Node.js (Axios)" const axios = require("axios"); const fs = require("fs"); const cdnUrl = "https://cdn2.onlyfans.com/files/e/e5/123/600x400_123.jpg?Tag=2&u=123&Policy=123&Signature=signature&Key-Pair-Id=123"; let config = { method: "get", url: `https://app.onlyfansapi.com/api/{account}/media/download/${cdnUrl}`, headers: { Authorization: "Bearer {token}", }, responseType: "stream", }; axios .request(config) .then((response) => { response.data.pipe(fs.createWriteStream("downloaded-media.jpg")); }) .catch((error) => { console.log(error); }); ``` ```php tab="PHP (Guzzle)" $client = new Client(); $headers = [ 'Authorization' => 'Bearer {token}' ]; $cdnUrl = "https://cdn2.onlyfans.com/files/e/e5/123/600x400_123.jpg?Tag=2&u=123&Policy=123&Signature=signature&Key-Pair-Id=123"; $request = new Request('GET', "https://app.onlyfansapi.com/api/{account}/media/download/{$cdnUrl}", $headers); $res = $client->sendAsync($request)->wait(); file_put_contents('downloaded-media.jpg', $res->getBody()); ``` The endpoint will return the media file directly, which you can then save to your local storage or process as needed.