Synchronous Client
A synchronous client to interact with the 1337x API for searching and retrieving torrent information.
Example
from py1337x import Py1337x
torrents = Py1337x()
vlc_media = torrents.search('vlc media player')
print(vlc_media)
Source code in py1337x/py1337x.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
__init__(base_url=config.default_base_url, cloudscraper_kwargs={}, requests_kwargs={})
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
Optional[str]
|
The base URL for the API. |
default_base_url
|
cloudscraper_kwargs
|
Optional[dict]
|
Kwargs to pass in cloudscraper. |
{}
|
requests_kwargs
|
Optional[dict]
|
Kwargs to pass in requests. |
{}
|
Source code in py1337x/py1337x.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
search(query, page=1, category=None, sort_by=None, order='desc')
Search for torrents based on a query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
The search query. |
required |
page
|
int
|
The page number. |
1
|
category
|
Optional[str]
|
Category of the torrent. |
None
|
sort_by
|
Optional[str]
|
Sort by "time", "size", "seeders" or "leechers". |
None
|
order
|
str
|
The order string ('asc' or 'desc'). |
'desc'
|
Returns:
| Type | Description |
|---|---|
TorrentResult
|
Result from the query |
Example
Basic search
from py1337x import Py1337x
from py1337x.types import category
torrents = Py1337x()
results = torrents.search('ubuntu', category=category.APPS)
print(results)
Search with sorting by seeders
from py1337x.types import category, sort, order
results = torrents.search('ubuntu', category=category.APPS, sort_by=sort.SEEDERS)
print(results)
Search within a category
results = torrents.search('ubuntu', category=category.APPS)
print(results)
Paginated search results, fetching page 2
results = torrents.search('ubuntu', category=category.APPS, page=2, order=order.ASC)
print(results)
Source code in py1337x/py1337x.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
trending(category=None, weekly=False)
Retrieve trending torrents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
Optional[str]
|
Category of the torrent. |
None
|
weekly
|
bool
|
Whether to get weekly trending torrents. |
False
|
Returns:
| Type | Description |
|---|---|
TorrentResult
|
Trending torrents |
Example
Get today's trending torrents
trending_today = torrents.trending()
print(trending_today)
Weekly trending torrents in the applications category
trending_weekly = torrents.trending(category=category.APPS, weekly=True)
print(trending_weekly)
Source code in py1337x/py1337x.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
top(category=None)
Retrieve top 100 torrents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
Optional[str]
|
Category of the torrent. |
None
|
Returns:
| Type | Description |
|---|---|
TorrentResult
|
Top 100 torrents |
Example
Get top 100 torrents
top_torrents = torrents.top()
print(top_torrents)
Top torrents in specific category
top_movies = torrents.top(category=category.MOVIES)
print(top_movies)
Source code in py1337x/py1337x.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
popular(category, weekly=False)
Retrieve popular torrents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Category of the torrent. |
required |
weekly
|
bool
|
Whether to get weekly popular torrents. |
False
|
Returns:
| Type | Description |
|---|---|
TorrentResult
|
Popular torrents |
Example
Get popular torrents
popular = torrents.popular(category=category.GAMES)
print(popular)
Weekly popular torrents
popular_weekly = torrents.popular(category=category.APPS, weekly=True)
print(popular_weekly)
Source code in py1337x/py1337x.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
browse(category, page=1)
Browse torrents by category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Category of the torrent. |
required |
page
|
int
|
The page number. |
1
|
Returns:
| Type | Description |
|---|---|
TorrentResult
|
Parsed browse results. |
Example
Browse torrents under the applications category
apps = torrents.browse(category=category.APPS, page=2)
print(apps)
Source code in py1337x/py1337x.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
info(link=None, torrent_id=None)
Retrieve information of a torrent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
link
|
Optional[str]
|
The URL to the torrent. |
None
|
torrent_id
|
Optional[str]
|
The torrent ID. |
None
|
Returns:
| Type | Description |
|---|---|
TorrentInfo
|
Parsed torrent information. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If neither link nor torrent_id is provided, or if both are provided. |
Source code in py1337x/py1337x.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |