saverapi-client 1.0.3__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 SaverAPI.NET
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: saverapi-client
3
+ Version: 2.0.0
4
+ Summary: Official Python SDK for SaverAPI.NET — video downloader API for YouTube (4K, MP3), Instagram, TikTok, Facebook, X, Pinterest and Threads, Telegram bot file_id, Shazam, music search, NSFW scan. Sync, async, CLI.
5
+ Author-email: "SaverAPI.NET" <saverapinet@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://saverapi.net
8
+ Project-URL: Documentation, https://saverapi.net/docs
9
+ Project-URL: API catalog, https://saverapi.net/all-in-one-downloader-api
10
+ Project-URL: YouTube Downloader API, https://saverapi.net/youtube-downloader-api
11
+ Project-URL: Instagram Downloader API, https://saverapi.net/instagram-downloader-api
12
+ Project-URL: TikTok Downloader API, https://saverapi.net/tiktok-downloader-api
13
+ Project-URL: Shazam API, https://saverapi.net/shazam-api
14
+ Project-URL: Tutorials, https://saverapi.net/blog
15
+ Project-URL: Pricing, https://saverapi.net/pricing
16
+ Project-URL: Changelog, https://saverapi.net/whats-new
17
+ Project-URL: Telegram, https://t.me/SaverAPI
18
+ Keywords: saverapi,social media downloader api,video downloader api,all in one downloader,instagram downloader,instagram reels downloader,instagram api,instagram profile api,tiktok downloader,tiktok video api,tiktok no watermark,youtube downloader,youtube api python,youtube video download,youtube mp3,youtube to mp3 api,youtube 4k,youtube 4k downloader,youtube downloader python,telegram file_id,yt-dlp alternative,facebook video downloader,twitter video downloader,x video downloader,pinterest downloader,threads downloader,snapchat downloader,vimeo downloader,soundcloud downloader,shazam api,song recognition,music recognition api,music search api,shazam charts,nsfw scanner,nsfw detection api,telegram bot downloader,telegram bot youtube,aiogram,python-telegram-bot,instagram reels api,social media api,async api client,python sdk,rest api client
19
+ Classifier: Development Status :: 5 - Production/Stable
20
+ Classifier: Intended Audience :: Developers
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3 :: Only
25
+ Classifier: Programming Language :: Python :: 3.8
26
+ Classifier: Programming Language :: Python :: 3.9
27
+ Classifier: Programming Language :: Python :: 3.10
28
+ Classifier: Programming Language :: Python :: 3.11
29
+ Classifier: Programming Language :: Python :: 3.12
30
+ Classifier: Programming Language :: Python :: 3.13
31
+ Classifier: Framework :: AsyncIO
32
+ Classifier: Typing :: Typed
33
+ Classifier: Topic :: Internet :: WWW/HTTP
34
+ Classifier: Topic :: Multimedia :: Video
35
+ Classifier: Topic :: Multimedia :: Sound/Audio
36
+ Classifier: Topic :: Communications :: Chat
37
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
38
+ Requires-Python: >=3.8
39
+ Description-Content-Type: text/markdown
40
+ License-File: LICENSE
41
+ Requires-Dist: requests>=2.25
42
+ Provides-Extra: async
43
+ Requires-Dist: httpx>=0.24; extra == "async"
44
+ Dynamic: license-file
45
+
46
+ <div align="center">
47
+
48
+ # SaverAPI Python SDK
49
+
50
+ ### Social media video downloader API for Python — YouTube (up to 4K), Instagram, TikTok, Facebook, X and more
51
+
52
+ Official client for **[SaverAPI.NET](https://saverapi.net)**: download videos, Reels and audio, get YouTube in up to 4K or as a ready Telegram `file_id`, read YouTube metadata, look up Instagram profiles, recognise songs with Shazam and scan media for NSFW content — with one API key, from sync code, `asyncio` or the command line.
53
+
54
+ [![PyPI](https://img.shields.io/pypi/v/saverapi-client.svg?color=6f42c1&label=pypi&logo=pypi&logoColor=white)](https://pypi.org/project/saverapi-client/)
55
+ [![Python](https://img.shields.io/pypi/pyversions/saverapi-client.svg?color=3776ab&logo=python&logoColor=white)](https://pypi.org/project/saverapi-client/)
56
+ [![License](https://img.shields.io/badge/license-MIT-success.svg)](#license)
57
+ [![Downloads](https://img.shields.io/pypi/dm/saverapi-client.svg?color=0ea5e9&label=downloads)](https://pypi.org/project/saverapi-client/)
58
+ [![Docs](https://img.shields.io/badge/docs-saverapi.net-4f46e5)](https://saverapi.net/docs)
59
+ [![Telegram](https://img.shields.io/badge/telegram-@SaverAPI-26a5e4?logo=telegram&logoColor=white)](https://t.me/SaverAPI)
60
+
61
+ </div>
62
+
63
+ ```bash
64
+ pip install -U saverapi-client # sync client + CLI
65
+ pip install -U "saverapi-client[async]" # + AsyncSaverAPI (httpx)
66
+ ```
67
+
68
+ Get a free API key at **[saverapi.net](https://saverapi.net/auth/register)** — no card needed.
69
+
70
+ **Why SaverAPI**
71
+
72
+ - **One API for every major platform** — Instagram Reels and posts, TikTok, YouTube video and MP3, Facebook, X (Twitter), Pinterest, Threads, Snapchat, Vimeo, SoundCloud and more behind a single key.
73
+ - **YouTube from 144p to 4K** — `2160`, `1440`, `1080`, `720`… or `mp3` audio, with no yt-dlp, ffmpeg, proxies or cookies to maintain.
74
+ - **Built for Telegram bots** — get a ready `file_id` for your own bot and send a YouTube video instantly, without downloading or re-uploading it.
75
+ - **Sync, async and CLI** — `SaverAPI` (requests), `AsyncSaverAPI` (httpx, for aiogram / FastAPI) and a `saverapi` terminal command.
76
+ - **Production ready** — automatic retries, typed exceptions, type hints, Python 3.8–3.13.
77
+
78
+ **Contents:** [Quick start](#quick-start) · [Supported platforms](#supported-platforms) · [Examples](#examples) · [Async](#async-aiogram-fastapi-asyncio) · [Command line](#command-line) · [Errors and retries](#errors-and-retries) · [FAQ](#faq) · [Changelog](#changelog)
79
+
80
+ ---
81
+
82
+ ## Quick start
83
+
84
+ ```python
85
+ from saverapi import SaverAPI
86
+
87
+ api = SaverAPI(api_key="YOUR_API_KEY") # or export SAVERAPI_KEY=...
88
+
89
+ media = api.download("https://www.instagram.com/reel/DPOi9V-CAqH/")
90
+ print(media["hosting"], media["type"], media["download_url"])
91
+
92
+ api.save_file(media["download_url"], "downloads/reel.mp4")
93
+ ```
94
+
95
+ One call, one parameter: the **All-in-One downloader** recognises the platform from the link. The response's `hosting` field tells you which network it was, `type` is `video` or `image`, and `download_url` points at the file.
96
+
97
+ ## Supported platforms
98
+
99
+ | Platform | Method | REST endpoint |
100
+ |---|---|---|
101
+ | Instagram (posts, Reels) | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/instagram-downloader-api) |
102
+ | TikTok | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/tiktok-downloader-api) |
103
+ | Facebook | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/facebook-video-api) |
104
+ | Twitter / X | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/twitter-video-api) |
105
+ | Snapchat, Pinterest, Likee, Threads, Twitch, Weibo, Vimeo, SoundCloud, Spotify | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/all-in-one-downloader-api) |
106
+ | YouTube video (144p–4K) / MP3 | `api.youtube(url, format)` | [`/youtube-api`](https://saverapi.net/youtube-downloader-api) |
107
+ | YouTube as a Telegram `file_id` | `api.youtube_telegram(url, format, bot_username)` | `/youtube-telegram-base` |
108
+ | YouTube metadata | `api.youtube_info(url)` · `api.youtube_info_basic(url)` | `/youtube-info-v2` · `/youtube-info` |
109
+ | Instagram profile | `api.instagram_profile(username)` | `/instagram-profile` |
110
+ | Shazam song recognition | `api.shazam_recognize(url)` | [`/shazam-recognize`](https://saverapi.net/shazam-api) |
111
+ | Shazam top charts | `api.shazam_top(country)` | `/shazam-music-top` |
112
+ | Music search | `api.music_search(query, limit)` | `/music-search` |
113
+ | NSFW scanner | `api.nsfw_scan(url)` | `/nsfw-scanner-api` |
114
+ | Account balance (free) | `api.info_balance()` | `/infobalans` |
115
+ | Key statistics (free) | `api.api_keys_statistics()` | `/api-keys/all-statistics` |
116
+
117
+ Full parameter reference and response samples: **[saverapi.net/docs](https://saverapi.net/docs)**. Endpoints added to the catalog later can be called with `api.request("/endpoint-path", {"param": "value"})`.
118
+
119
+ ## Examples
120
+
121
+ ### Download a YouTube video (up to 4K) or MP3 in Python
122
+
123
+ ```python
124
+ video = api.youtube("https://youtu.be/OORSiK8ScTI", format="720")
125
+ api.save_file(video["url"], "video.mp4")
126
+
127
+ audio = api.youtube("https://youtu.be/OORSiK8ScTI", format="mp3")
128
+ uhd = api.youtube("https://youtu.be/OORSiK8ScTI", format="2160") # 4K, when the video has it
129
+
130
+ info = api.youtube_info("https://youtu.be/OORSiK8ScTI")
131
+ print(info["title"], info["duration"])
132
+ ```
133
+
134
+ `format` is one of `2160`, `1440`, `1080`, `720`, `480`, `360`, `240`, `144` or `mp3` (also available as `saverapi.YOUTUBE_FORMATS`).
135
+
136
+ ### YouTube straight into a Telegram bot (`file_id`)
137
+
138
+ Pass your bot's username and the response carries a `file_id` that is valid for that bot — send it without downloading or re-uploading anything, and store it to reuse later.
139
+
140
+ ```python
141
+ import time
142
+
143
+ res = api.youtube_telegram("https://youtu.be/OORSiK8ScTI", format="720", bot_username="@MyBot")
144
+ while res.get("status") == "processing": # a new video is still being prepared
145
+ time.sleep(res.get("retry_after", 5))
146
+ res = api.youtube_telegram("https://youtu.be/OORSiK8ScTI", format="720", bot_username="@MyBot")
147
+
148
+ if res["media_type"] == "video":
149
+ bot.send_video(chat_id, res["file_id"]) # your Telegram library's sendVideo
150
+ else:
151
+ bot.send_audio(chat_id, res["file_id"]) # format="mp3" → sendAudio
152
+ ```
153
+
154
+ Formats here: `1080`, `720`, `480`, `360`, `240`, `144` or `mp3`. The response also has `title`, `author`, `duration`, `size`, `width`, `height` and `thumbnail_url`. Your bot may receive service messages while the file is delivered — do not reply to them.
155
+
156
+ ### Download TikTok, Instagram, Facebook or X videos
157
+
158
+ ```python
159
+ for link in [
160
+ "https://www.tiktok.com/@user/video/7300000000000000000",
161
+ "https://www.facebook.com/watch/?v=1234567890",
162
+ "https://x.com/user/status/1234567890",
163
+ ]:
164
+ media = api.download(link)
165
+ print(media["hosting"], media["download_url"])
166
+ ```
167
+
168
+ ### Instagram profile data
169
+
170
+ ```python
171
+ profile = api.instagram_profile("cristiano")
172
+ print(profile["user"]["full_name"], profile["user"]["is_verified"])
173
+ ```
174
+
175
+ ### Recognise a song, search music, read charts
176
+
177
+ ```python
178
+ song = api.shazam_recognize("https://example.com/clip.mp3")
179
+ print(song["track"]["title"], "—", song["track"]["subtitle"])
180
+
181
+ results = api.music_search("Hello Adele", limit=5)
182
+ top = api.shazam_top("united-states")
183
+ ```
184
+
185
+ ### Check your plan and credits (free)
186
+
187
+ ```python
188
+ print(api.info_balance())
189
+ ```
190
+
191
+ ## Async (aiogram, FastAPI, asyncio)
192
+
193
+ ```python
194
+ import asyncio
195
+ from saverapi import AsyncSaverAPI
196
+
197
+ async def main():
198
+ async with AsyncSaverAPI() as api: # reads SAVERAPI_KEY
199
+ results = await asyncio.gather(
200
+ api.download("https://www.instagram.com/reel/DPOi9V-CAqH/"),
201
+ api.youtube_info("https://youtu.be/OORSiK8ScTI"),
202
+ )
203
+ print(results)
204
+
205
+ asyncio.run(main())
206
+ ```
207
+
208
+ ### Telegram downloader bot (aiogram 3)
209
+
210
+ ```python
211
+ from aiogram import Bot, Dispatcher, F
212
+ from aiogram.types import Message
213
+ from saverapi import AsyncSaverAPI, SaverAPIError
214
+
215
+ bot = Bot("TELEGRAM_BOT_TOKEN")
216
+ dp = Dispatcher()
217
+ api = AsyncSaverAPI() # SAVERAPI_KEY from the environment
218
+
219
+ @dp.message(F.text.startswith("http"))
220
+ async def on_link(message: Message):
221
+ try:
222
+ media = await api.download(message.text.strip())
223
+ except SaverAPIError as exc:
224
+ await message.answer(f"Could not download: {exc.message}")
225
+ return
226
+ if media.get("type") == "image":
227
+ await message.answer_photo(media["download_url"])
228
+ else:
229
+ await message.answer_video(media["download_url"])
230
+
231
+ dp.run_polling(bot)
232
+ ```
233
+
234
+ Step-by-step guide: **[Build a Telegram video downloader bot](https://saverapi.net/blog/build-telegram-video-downloader-bot)**.
235
+
236
+ ## Command line
237
+
238
+ ```bash
239
+ export SAVERAPI_KEY=your_key
240
+ saverapi download https://www.instagram.com/reel/DPOi9V-CAqH/
241
+ saverapi youtube https://youtu.be/OORSiK8ScTI --format mp3
242
+ saverapi youtube-telegram https://youtu.be/OORSiK8ScTI --bot @MyBot
243
+ saverapi youtube-info https://youtu.be/OORSiK8ScTI
244
+ saverapi instagram cristiano
245
+ saverapi shazam https://example.com/clip.mp3
246
+ saverapi balance
247
+ ```
248
+
249
+ Prints the JSON response; exits with status 1 on an API error.
250
+
251
+ ## Errors and retries
252
+
253
+ Rate limits (`429`) and temporary server errors (`5xx`) are retried automatically with exponential backoff (`max_retries=2` by default). Failed 5xx calls are not charged. Everything else raises a specific exception:
254
+
255
+ ```python
256
+ from saverapi import (
257
+ SaverAPIError, AuthenticationError, InsufficientCreditsError,
258
+ RateLimitError, NotFoundError, ServerError, NetworkError,
259
+ )
260
+
261
+ try:
262
+ api.download(link)
263
+ except AuthenticationError: # 401/403 — wrong or disabled key
264
+ ...
265
+ except InsufficientCreditsError: # 402 — top up or upgrade at saverapi.net/pricing
266
+ ...
267
+ except RateLimitError as exc: # 429 after retries
268
+ ...
269
+ except SaverAPIError as exc: # anything else; exc.status_code, exc.message, exc.payload
270
+ ...
271
+ ```
272
+
273
+ Options: `SaverAPI(api_key=None, timeout=60, base_url=None, session=None, max_retries=2, backoff=1.0)`. Use it as a context manager (`with SaverAPI() as api:`) to close the HTTP session.
274
+
275
+ ## Tips
276
+
277
+ - Media links (`download_url`) come from the networks' CDNs and **expire** — download them right after the call.
278
+ - Only public content can be resolved; private accounts and deleted posts fail.
279
+ - Keep the API key on your server; mobile and web apps should call your backend.
280
+ - Respect each platform's terms of service and creators' rights.
281
+
282
+ ## FAQ
283
+
284
+ **How do I download a YouTube video in Python?**
285
+ Install `saverapi-client`, then call `api.youtube(url, format="720")` and save `video["url"]` with `api.save_file(...)`. No yt-dlp or ffmpeg is needed — the API does the work. See the [YouTube Downloader API](https://saverapi.net/youtube-downloader-api) page.
286
+
287
+ **Can I download YouTube in 4K or 1440p?**
288
+ Yes: `format="2160"` (4K) and `format="1440"` (2K) are supported alongside 1080, 720, 480, 360, 240 and 144, when the video has that quality.
289
+
290
+ **How do I convert YouTube to MP3?**
291
+ `api.youtube(url, format="mp3")` returns a link to the audio file.
292
+
293
+ **How do I download Instagram Reels or TikTok videos in Python?**
294
+ `api.download(link)` works for Instagram posts and Reels, TikTok, Facebook, X and the other supported networks — the platform is detected from the link. See the [Instagram](https://saverapi.net/instagram-downloader-api) and [TikTok](https://saverapi.net/tiktok-downloader-api) API pages.
295
+
296
+ **How do I send a YouTube video from a Telegram bot without uploading it?**
297
+ Call `api.youtube_telegram(url, format, bot_username="@YourBot")` and pass the returned `file_id` to `sendVideo` / `sendAudio`. Works with aiogram, python-telegram-bot, pyTelegramBotAPI and any other library.
298
+
299
+ **Is there a free plan?**
300
+ Yes — register at [saverapi.net](https://saverapi.net/auth/register) for a free key; paid plans and pay-as-you-go credits are on the [pricing](https://saverapi.net/pricing) page.
301
+
302
+ **Does it work with asyncio?**
303
+ Yes: `pip install "saverapi-client[async]"` and use `AsyncSaverAPI` — same methods, awaited.
304
+
305
+ ## Links
306
+
307
+ - Website and free API key: https://saverapi.net
308
+ - API documentation: https://saverapi.net/docs
309
+ - YouTube Downloader API: https://saverapi.net/youtube-downloader-api
310
+ - Instagram Downloader API: https://saverapi.net/instagram-downloader-api
311
+ - TikTok Downloader API: https://saverapi.net/tiktok-downloader-api
312
+ - Facebook Video API: https://saverapi.net/facebook-video-api
313
+ - Twitter / X Video API: https://saverapi.net/twitter-video-api
314
+ - Shazam Song Recognition API: https://saverapi.net/shazam-api
315
+ - Social Media Downloader API: https://saverapi.net/social-media-downloader-api
316
+ - All-in-One Downloader API: https://saverapi.net/all-in-one-downloader-api
317
+ - Tutorials: https://saverapi.net/blog
318
+ - [YouTube downloader API in Python](https://saverapi.net/blog/youtube-downloader-api-python)
319
+ - [Build a Telegram YouTube downloader bot](https://saverapi.net/blog/build-telegram-youtube-downloader-bot)
320
+ - [Download Instagram Reels with Python](https://saverapi.net/blog/download-instagram-reels-python)
321
+ - [A yt-dlp API alternative](https://saverapi.net/blog/yt-dlp-api-alternative)
322
+ - Pricing: https://saverapi.net/pricing
323
+ - Telegram: https://t.me/SaverAPI
324
+
325
+ ## Changelog
326
+
327
+ **2.0.0**
328
+ - YouTube: `api.youtube()` now documents the new `2160` (4K) and `1440` (2K) formats; the full list is exported as `YOUTUBE_FORMATS`.
329
+ - YouTube for Telegram: `api.youtube_telegram(url, format, bot_username="@MyBot")` returns a ready `file_id` for your bot. New CLI command `saverapi youtube-telegram URL --bot @MyBot`.
330
+ - **Removed** `youtube_subtitles()` and `photolab()` (and the `saverapi subtitles` command): the `/youtube-subtitles` and `/photolab-api` endpoints were retired from the API and already answered 404. This is the only breaking change — if you do not call these two methods, upgrading from 1.x needs no code changes.
331
+ - `format` accepts an `int` as well as a `str` in type hints (`format=720`).
332
+
333
+ **1.1.0**
334
+ - New methods covering the whole catalog: `youtube_telegram`, `youtube_info_basic`, `youtube_subtitles`, `instagram_profile`, `photolab`, and `request()` for any endpoint.
335
+ - `AsyncSaverAPI` for asyncio (`pip install "saverapi-client[async]"`).
336
+ - `saverapi` command line tool.
337
+ - Automatic retries with backoff for 429 and 5xx; specific exception classes.
338
+ - API key from the `SAVERAPI_KEY` environment variable; context-manager support; type hints (`py.typed`).
339
+ - Fully backwards compatible with 1.0.x.
340
+
341
+ ## License
342
+
343
+ MIT © SaverAPI.NET
@@ -0,0 +1,298 @@
1
+ <div align="center">
2
+
3
+ # SaverAPI Python SDK
4
+
5
+ ### Social media video downloader API for Python — YouTube (up to 4K), Instagram, TikTok, Facebook, X and more
6
+
7
+ Official client for **[SaverAPI.NET](https://saverapi.net)**: download videos, Reels and audio, get YouTube in up to 4K or as a ready Telegram `file_id`, read YouTube metadata, look up Instagram profiles, recognise songs with Shazam and scan media for NSFW content — with one API key, from sync code, `asyncio` or the command line.
8
+
9
+ [![PyPI](https://img.shields.io/pypi/v/saverapi-client.svg?color=6f42c1&label=pypi&logo=pypi&logoColor=white)](https://pypi.org/project/saverapi-client/)
10
+ [![Python](https://img.shields.io/pypi/pyversions/saverapi-client.svg?color=3776ab&logo=python&logoColor=white)](https://pypi.org/project/saverapi-client/)
11
+ [![License](https://img.shields.io/badge/license-MIT-success.svg)](#license)
12
+ [![Downloads](https://img.shields.io/pypi/dm/saverapi-client.svg?color=0ea5e9&label=downloads)](https://pypi.org/project/saverapi-client/)
13
+ [![Docs](https://img.shields.io/badge/docs-saverapi.net-4f46e5)](https://saverapi.net/docs)
14
+ [![Telegram](https://img.shields.io/badge/telegram-@SaverAPI-26a5e4?logo=telegram&logoColor=white)](https://t.me/SaverAPI)
15
+
16
+ </div>
17
+
18
+ ```bash
19
+ pip install -U saverapi-client # sync client + CLI
20
+ pip install -U "saverapi-client[async]" # + AsyncSaverAPI (httpx)
21
+ ```
22
+
23
+ Get a free API key at **[saverapi.net](https://saverapi.net/auth/register)** — no card needed.
24
+
25
+ **Why SaverAPI**
26
+
27
+ - **One API for every major platform** — Instagram Reels and posts, TikTok, YouTube video and MP3, Facebook, X (Twitter), Pinterest, Threads, Snapchat, Vimeo, SoundCloud and more behind a single key.
28
+ - **YouTube from 144p to 4K** — `2160`, `1440`, `1080`, `720`… or `mp3` audio, with no yt-dlp, ffmpeg, proxies or cookies to maintain.
29
+ - **Built for Telegram bots** — get a ready `file_id` for your own bot and send a YouTube video instantly, without downloading or re-uploading it.
30
+ - **Sync, async and CLI** — `SaverAPI` (requests), `AsyncSaverAPI` (httpx, for aiogram / FastAPI) and a `saverapi` terminal command.
31
+ - **Production ready** — automatic retries, typed exceptions, type hints, Python 3.8–3.13.
32
+
33
+ **Contents:** [Quick start](#quick-start) · [Supported platforms](#supported-platforms) · [Examples](#examples) · [Async](#async-aiogram-fastapi-asyncio) · [Command line](#command-line) · [Errors and retries](#errors-and-retries) · [FAQ](#faq) · [Changelog](#changelog)
34
+
35
+ ---
36
+
37
+ ## Quick start
38
+
39
+ ```python
40
+ from saverapi import SaverAPI
41
+
42
+ api = SaverAPI(api_key="YOUR_API_KEY") # or export SAVERAPI_KEY=...
43
+
44
+ media = api.download("https://www.instagram.com/reel/DPOi9V-CAqH/")
45
+ print(media["hosting"], media["type"], media["download_url"])
46
+
47
+ api.save_file(media["download_url"], "downloads/reel.mp4")
48
+ ```
49
+
50
+ One call, one parameter: the **All-in-One downloader** recognises the platform from the link. The response's `hosting` field tells you which network it was, `type` is `video` or `image`, and `download_url` points at the file.
51
+
52
+ ## Supported platforms
53
+
54
+ | Platform | Method | REST endpoint |
55
+ |---|---|---|
56
+ | Instagram (posts, Reels) | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/instagram-downloader-api) |
57
+ | TikTok | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/tiktok-downloader-api) |
58
+ | Facebook | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/facebook-video-api) |
59
+ | Twitter / X | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/twitter-video-api) |
60
+ | Snapchat, Pinterest, Likee, Threads, Twitch, Weibo, Vimeo, SoundCloud, Spotify | `api.download(url)` | [`/all-in-one-downloader-api`](https://saverapi.net/all-in-one-downloader-api) |
61
+ | YouTube video (144p–4K) / MP3 | `api.youtube(url, format)` | [`/youtube-api`](https://saverapi.net/youtube-downloader-api) |
62
+ | YouTube as a Telegram `file_id` | `api.youtube_telegram(url, format, bot_username)` | `/youtube-telegram-base` |
63
+ | YouTube metadata | `api.youtube_info(url)` · `api.youtube_info_basic(url)` | `/youtube-info-v2` · `/youtube-info` |
64
+ | Instagram profile | `api.instagram_profile(username)` | `/instagram-profile` |
65
+ | Shazam song recognition | `api.shazam_recognize(url)` | [`/shazam-recognize`](https://saverapi.net/shazam-api) |
66
+ | Shazam top charts | `api.shazam_top(country)` | `/shazam-music-top` |
67
+ | Music search | `api.music_search(query, limit)` | `/music-search` |
68
+ | NSFW scanner | `api.nsfw_scan(url)` | `/nsfw-scanner-api` |
69
+ | Account balance (free) | `api.info_balance()` | `/infobalans` |
70
+ | Key statistics (free) | `api.api_keys_statistics()` | `/api-keys/all-statistics` |
71
+
72
+ Full parameter reference and response samples: **[saverapi.net/docs](https://saverapi.net/docs)**. Endpoints added to the catalog later can be called with `api.request("/endpoint-path", {"param": "value"})`.
73
+
74
+ ## Examples
75
+
76
+ ### Download a YouTube video (up to 4K) or MP3 in Python
77
+
78
+ ```python
79
+ video = api.youtube("https://youtu.be/OORSiK8ScTI", format="720")
80
+ api.save_file(video["url"], "video.mp4")
81
+
82
+ audio = api.youtube("https://youtu.be/OORSiK8ScTI", format="mp3")
83
+ uhd = api.youtube("https://youtu.be/OORSiK8ScTI", format="2160") # 4K, when the video has it
84
+
85
+ info = api.youtube_info("https://youtu.be/OORSiK8ScTI")
86
+ print(info["title"], info["duration"])
87
+ ```
88
+
89
+ `format` is one of `2160`, `1440`, `1080`, `720`, `480`, `360`, `240`, `144` or `mp3` (also available as `saverapi.YOUTUBE_FORMATS`).
90
+
91
+ ### YouTube straight into a Telegram bot (`file_id`)
92
+
93
+ Pass your bot's username and the response carries a `file_id` that is valid for that bot — send it without downloading or re-uploading anything, and store it to reuse later.
94
+
95
+ ```python
96
+ import time
97
+
98
+ res = api.youtube_telegram("https://youtu.be/OORSiK8ScTI", format="720", bot_username="@MyBot")
99
+ while res.get("status") == "processing": # a new video is still being prepared
100
+ time.sleep(res.get("retry_after", 5))
101
+ res = api.youtube_telegram("https://youtu.be/OORSiK8ScTI", format="720", bot_username="@MyBot")
102
+
103
+ if res["media_type"] == "video":
104
+ bot.send_video(chat_id, res["file_id"]) # your Telegram library's sendVideo
105
+ else:
106
+ bot.send_audio(chat_id, res["file_id"]) # format="mp3" → sendAudio
107
+ ```
108
+
109
+ Formats here: `1080`, `720`, `480`, `360`, `240`, `144` or `mp3`. The response also has `title`, `author`, `duration`, `size`, `width`, `height` and `thumbnail_url`. Your bot may receive service messages while the file is delivered — do not reply to them.
110
+
111
+ ### Download TikTok, Instagram, Facebook or X videos
112
+
113
+ ```python
114
+ for link in [
115
+ "https://www.tiktok.com/@user/video/7300000000000000000",
116
+ "https://www.facebook.com/watch/?v=1234567890",
117
+ "https://x.com/user/status/1234567890",
118
+ ]:
119
+ media = api.download(link)
120
+ print(media["hosting"], media["download_url"])
121
+ ```
122
+
123
+ ### Instagram profile data
124
+
125
+ ```python
126
+ profile = api.instagram_profile("cristiano")
127
+ print(profile["user"]["full_name"], profile["user"]["is_verified"])
128
+ ```
129
+
130
+ ### Recognise a song, search music, read charts
131
+
132
+ ```python
133
+ song = api.shazam_recognize("https://example.com/clip.mp3")
134
+ print(song["track"]["title"], "—", song["track"]["subtitle"])
135
+
136
+ results = api.music_search("Hello Adele", limit=5)
137
+ top = api.shazam_top("united-states")
138
+ ```
139
+
140
+ ### Check your plan and credits (free)
141
+
142
+ ```python
143
+ print(api.info_balance())
144
+ ```
145
+
146
+ ## Async (aiogram, FastAPI, asyncio)
147
+
148
+ ```python
149
+ import asyncio
150
+ from saverapi import AsyncSaverAPI
151
+
152
+ async def main():
153
+ async with AsyncSaverAPI() as api: # reads SAVERAPI_KEY
154
+ results = await asyncio.gather(
155
+ api.download("https://www.instagram.com/reel/DPOi9V-CAqH/"),
156
+ api.youtube_info("https://youtu.be/OORSiK8ScTI"),
157
+ )
158
+ print(results)
159
+
160
+ asyncio.run(main())
161
+ ```
162
+
163
+ ### Telegram downloader bot (aiogram 3)
164
+
165
+ ```python
166
+ from aiogram import Bot, Dispatcher, F
167
+ from aiogram.types import Message
168
+ from saverapi import AsyncSaverAPI, SaverAPIError
169
+
170
+ bot = Bot("TELEGRAM_BOT_TOKEN")
171
+ dp = Dispatcher()
172
+ api = AsyncSaverAPI() # SAVERAPI_KEY from the environment
173
+
174
+ @dp.message(F.text.startswith("http"))
175
+ async def on_link(message: Message):
176
+ try:
177
+ media = await api.download(message.text.strip())
178
+ except SaverAPIError as exc:
179
+ await message.answer(f"Could not download: {exc.message}")
180
+ return
181
+ if media.get("type") == "image":
182
+ await message.answer_photo(media["download_url"])
183
+ else:
184
+ await message.answer_video(media["download_url"])
185
+
186
+ dp.run_polling(bot)
187
+ ```
188
+
189
+ Step-by-step guide: **[Build a Telegram video downloader bot](https://saverapi.net/blog/build-telegram-video-downloader-bot)**.
190
+
191
+ ## Command line
192
+
193
+ ```bash
194
+ export SAVERAPI_KEY=your_key
195
+ saverapi download https://www.instagram.com/reel/DPOi9V-CAqH/
196
+ saverapi youtube https://youtu.be/OORSiK8ScTI --format mp3
197
+ saverapi youtube-telegram https://youtu.be/OORSiK8ScTI --bot @MyBot
198
+ saverapi youtube-info https://youtu.be/OORSiK8ScTI
199
+ saverapi instagram cristiano
200
+ saverapi shazam https://example.com/clip.mp3
201
+ saverapi balance
202
+ ```
203
+
204
+ Prints the JSON response; exits with status 1 on an API error.
205
+
206
+ ## Errors and retries
207
+
208
+ Rate limits (`429`) and temporary server errors (`5xx`) are retried automatically with exponential backoff (`max_retries=2` by default). Failed 5xx calls are not charged. Everything else raises a specific exception:
209
+
210
+ ```python
211
+ from saverapi import (
212
+ SaverAPIError, AuthenticationError, InsufficientCreditsError,
213
+ RateLimitError, NotFoundError, ServerError, NetworkError,
214
+ )
215
+
216
+ try:
217
+ api.download(link)
218
+ except AuthenticationError: # 401/403 — wrong or disabled key
219
+ ...
220
+ except InsufficientCreditsError: # 402 — top up or upgrade at saverapi.net/pricing
221
+ ...
222
+ except RateLimitError as exc: # 429 after retries
223
+ ...
224
+ except SaverAPIError as exc: # anything else; exc.status_code, exc.message, exc.payload
225
+ ...
226
+ ```
227
+
228
+ Options: `SaverAPI(api_key=None, timeout=60, base_url=None, session=None, max_retries=2, backoff=1.0)`. Use it as a context manager (`with SaverAPI() as api:`) to close the HTTP session.
229
+
230
+ ## Tips
231
+
232
+ - Media links (`download_url`) come from the networks' CDNs and **expire** — download them right after the call.
233
+ - Only public content can be resolved; private accounts and deleted posts fail.
234
+ - Keep the API key on your server; mobile and web apps should call your backend.
235
+ - Respect each platform's terms of service and creators' rights.
236
+
237
+ ## FAQ
238
+
239
+ **How do I download a YouTube video in Python?**
240
+ Install `saverapi-client`, then call `api.youtube(url, format="720")` and save `video["url"]` with `api.save_file(...)`. No yt-dlp or ffmpeg is needed — the API does the work. See the [YouTube Downloader API](https://saverapi.net/youtube-downloader-api) page.
241
+
242
+ **Can I download YouTube in 4K or 1440p?**
243
+ Yes: `format="2160"` (4K) and `format="1440"` (2K) are supported alongside 1080, 720, 480, 360, 240 and 144, when the video has that quality.
244
+
245
+ **How do I convert YouTube to MP3?**
246
+ `api.youtube(url, format="mp3")` returns a link to the audio file.
247
+
248
+ **How do I download Instagram Reels or TikTok videos in Python?**
249
+ `api.download(link)` works for Instagram posts and Reels, TikTok, Facebook, X and the other supported networks — the platform is detected from the link. See the [Instagram](https://saverapi.net/instagram-downloader-api) and [TikTok](https://saverapi.net/tiktok-downloader-api) API pages.
250
+
251
+ **How do I send a YouTube video from a Telegram bot without uploading it?**
252
+ Call `api.youtube_telegram(url, format, bot_username="@YourBot")` and pass the returned `file_id` to `sendVideo` / `sendAudio`. Works with aiogram, python-telegram-bot, pyTelegramBotAPI and any other library.
253
+
254
+ **Is there a free plan?**
255
+ Yes — register at [saverapi.net](https://saverapi.net/auth/register) for a free key; paid plans and pay-as-you-go credits are on the [pricing](https://saverapi.net/pricing) page.
256
+
257
+ **Does it work with asyncio?**
258
+ Yes: `pip install "saverapi-client[async]"` and use `AsyncSaverAPI` — same methods, awaited.
259
+
260
+ ## Links
261
+
262
+ - Website and free API key: https://saverapi.net
263
+ - API documentation: https://saverapi.net/docs
264
+ - YouTube Downloader API: https://saverapi.net/youtube-downloader-api
265
+ - Instagram Downloader API: https://saverapi.net/instagram-downloader-api
266
+ - TikTok Downloader API: https://saverapi.net/tiktok-downloader-api
267
+ - Facebook Video API: https://saverapi.net/facebook-video-api
268
+ - Twitter / X Video API: https://saverapi.net/twitter-video-api
269
+ - Shazam Song Recognition API: https://saverapi.net/shazam-api
270
+ - Social Media Downloader API: https://saverapi.net/social-media-downloader-api
271
+ - All-in-One Downloader API: https://saverapi.net/all-in-one-downloader-api
272
+ - Tutorials: https://saverapi.net/blog
273
+ - [YouTube downloader API in Python](https://saverapi.net/blog/youtube-downloader-api-python)
274
+ - [Build a Telegram YouTube downloader bot](https://saverapi.net/blog/build-telegram-youtube-downloader-bot)
275
+ - [Download Instagram Reels with Python](https://saverapi.net/blog/download-instagram-reels-python)
276
+ - [A yt-dlp API alternative](https://saverapi.net/blog/yt-dlp-api-alternative)
277
+ - Pricing: https://saverapi.net/pricing
278
+ - Telegram: https://t.me/SaverAPI
279
+
280
+ ## Changelog
281
+
282
+ **2.0.0**
283
+ - YouTube: `api.youtube()` now documents the new `2160` (4K) and `1440` (2K) formats; the full list is exported as `YOUTUBE_FORMATS`.
284
+ - YouTube for Telegram: `api.youtube_telegram(url, format, bot_username="@MyBot")` returns a ready `file_id` for your bot. New CLI command `saverapi youtube-telegram URL --bot @MyBot`.
285
+ - **Removed** `youtube_subtitles()` and `photolab()` (and the `saverapi subtitles` command): the `/youtube-subtitles` and `/photolab-api` endpoints were retired from the API and already answered 404. This is the only breaking change — if you do not call these two methods, upgrading from 1.x needs no code changes.
286
+ - `format` accepts an `int` as well as a `str` in type hints (`format=720`).
287
+
288
+ **1.1.0**
289
+ - New methods covering the whole catalog: `youtube_telegram`, `youtube_info_basic`, `youtube_subtitles`, `instagram_profile`, `photolab`, and `request()` for any endpoint.
290
+ - `AsyncSaverAPI` for asyncio (`pip install "saverapi-client[async]"`).
291
+ - `saverapi` command line tool.
292
+ - Automatic retries with backoff for 429 and 5xx; specific exception classes.
293
+ - API key from the `SAVERAPI_KEY` environment variable; context-manager support; type hints (`py.typed`).
294
+ - Fully backwards compatible with 1.0.x.
295
+
296
+ ## License
297
+
298
+ MIT © SaverAPI.NET