Functions¶
Main functions used for obtaining data from JustWatch GraphQL API.
Each function sends one GraphQL query to JustWatch API and returns API response
parsed into a NamedTuple from tuples module. Everything is handled on the API side through
prepared GraphQL query.
Most functions have a number of common arguments (in addition to function-specific
ones, like title to search for):
| Name | Description |
|---|---|
country |
2-letter country code for which offers are selected, (e.g., US, GB, DE). |
language |
Code for language in responses. It consists of 2 lowercase letters with optional uppercase alphanumeric suffix (e.g., en, en-US, de, de-CH1901). |
best_only |
Whether to return only "best" offers for each provider instead of, e.g., separate offer for SD, HD, and 4K. |
Functions returning data for multiple titles
(search,
popular)
also allow for specifying number of elements, basic pagination, and filtering for
specific providers:
| Name | Description |
|---|---|
count |
How many entries should be returned. |
offset |
Basic "pagination". Offset for the first returned result, i.e. how many first entries should be skipped. Everything is handled on API side, this library isn't doing any filtering. |
providers |
Providers (like Netflix, Amazon Prime Video) for which offers should returned. Requires 3-letter "short name". Check providers for an example of how you can get that value. |
Each function can raise two exceptions:
| Exception | Cause |
|---|---|
JustWatchHttpError |
HTTP error occurred, e.g., JustWatch API responded with non-2xx status code. |
JustWatchApiError |
JSON response from JustWatch API contains errors, e.g., due to invalid language or country code. |
| FUNCTION | DESCRIPTION |
|---|---|
details |
Get details of entry for a given ID. |
episodes |
Get details of all episodes available for a given season ID. |
offers_for_countries |
Get offers for entry of given node ID for all given countries. |
popular |
Look up all currently popular titles on JustWatch. |
providers |
Look up all providers for the given country. |
search |
Search JustWatch for the given title. |
seasons |
Get details of all seasons available for a given show ID. |
details
¶
details(node_id: str, country: str = 'US', language: str = 'en', best_only: bool = True) -> MediaEntry
Get details of entry for a given ID.
country is a 2-letter country code for which offers are selected. It should be
uppercase, however it will be normalized to uppercase automatically. It must be
2-letters long. It looks like ISO 3166-1 alpha-2 standard, however API doesn't
specify exact standard. If unexpected code is used, then JustWatchApiError exception is raised, as the API
will respond with internal error.
language is a language code for language in response (e.g., description, title).
In most basic form it's 2 lowercase letters (e.g., en, de).
It can also contain alphanumeric (in uppercase) suffix after - symbol, most
likely used for regional variants (e.g., en-US, de-CH).
It looks like a subset of IETF BCP 47, however the suffix can contain only uppercase
letters and numbers. It's value isn't normalized and must be provided in
expected format, including letter case.
best_only allows filtering out redundant offers, e.g. when if provide offers
service in 4K, HD and SD, using best_only = True returns only 4K option,
best_only = False returns all three.
| PARAMETER | DESCRIPTION |
|---|---|
node_id
|
ID of an entry to look up.
TYPE:
|
country
|
2-letter country code for which offers are selected. It seems to be ISO 3166-1 alpha-2 standard (e.g.,
TYPE:
|
language
|
Code for language in responses (e.g., description, title). It consists of 2 lowercase letters with optional uppercase alphanumeric
suffix after Its value isn't normalized and must be provided in expected format, including letter case.
TYPE:
|
best_only
|
Return only best offers if If service offers the same title in 4K, HD, and SD, then
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MediaEntry
|
Tuple with data about requested entry. |
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |
Source code in src/simplejustwatchapi/justwatch.py
episodes
¶
episodes(season_id: str, country: str = 'US', language: str = 'en', best_only: bool = True) -> list[Episode]
Get details of all episodes available for a given season ID.
Episode tuple is a subset ofMediaEntry, but with only episode-specific fields,
e.g., episode_number.
| PARAMETER | DESCRIPTION |
|---|---|
season_id
|
ID of season to look up episodes for.
TYPE:
|
country
|
2-letter country code for which offers are selected. It seems to be ISO 3166-1 alpha-2 standard (e.g.,
TYPE:
|
language
|
Code for language in responses (e.g., description, title). It consists of 2 lowercase letters with optional uppercase alphanumeric
suffix after Its value isn't normalized and must be provided in expected format, including letter case.
TYPE:
|
best_only
|
Return only best offers if If service offers the same title in 4K, HD, and SD, then
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Episode]
|
List of tuples with episode data about requested season. |
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |
Source code in src/simplejustwatchapi/justwatch.py
offers_for_countries
¶
offers_for_countries(node_id: str, countries: set[str], language: str = 'en', best_only: bool = True) -> dict[str, list[Offer]]
Get offers for entry of given node ID for all given countries.
Returned dict has keys matching countries argument and values are list of found
offers. If no countries are passed (an empty set given as argument) empty dict is
returned.
Country codes passed as argument are case-insensitive, however keys in returned dict will match them exactly. For example, for countries specified as:
Returned dict will have the following structure:{
"uK": [ ... offers ... ],
"Us": [ ... offers ... ],
"AU": [ ... offers ... ],
"ca": [ ... offers ... ],
}
| PARAMETER | DESCRIPTION |
|---|---|
node_id
|
ID of entry to look up offers for.
TYPE:
|
countries
|
2-letter country codes for which offers are selected. They seem to match ISO 3166-1 alpha-2 standard (e.g., |
language
|
Code for language in responses (e.g., description, title). It consists of 2 lowercase letters with optional uppercase alphanumeric
suffix after Its value isn't normalized and must be provided in expected format, including letter case.
TYPE:
|
best_only
|
Return only best offers if If service offers the same title in 4K, HD, and SD, then
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, list[Offer]]
|
Keys match values in |
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |
Source code in src/simplejustwatchapi/justwatch.py
popular
¶
popular(country: str = 'US', language: str = 'en', count: int = 4, best_only: bool = True, offset: int = 0, providers: list[str] | str | None = None) -> list[MediaEntry]
Look up all currently popular titles on JustWatch.
This function returns similar values as search with no title provided.
JustWatch API won't allow for getting more than 1999 responses, either through
count, or when count + offset is equal or greater than 2000 - it will return an
empty list instead (always an empty list, it won't include entries up to 1999).
| PARAMETER | DESCRIPTION |
|---|---|
country
|
2-letter country code for which offers are selected. It seems to be ISO 3166-1 alpha-2 standard (e.g.,
TYPE:
|
language
|
Code for language in responses (e.g., description, title). It consists of 2 lowercase letters with optional uppercase alphanumeric
suffix after Its value isn't normalized and must be provided in expected format, including letter case.
TYPE:
|
count
|
Return up to this many results. Too high values can cause API errors due to too high operation complexity,
if you need more results, use with
TYPE:
|
best_only
|
Return only best offers if If service offers the same title in 4K, HD, and SD, then
TYPE:
|
offset
|
Offset for the first returned result, i.e. how many first entries should be skipped. This is done on API side, not the library side; the returned list is still directly parsed from API response. I'm not sure if it guarantees stability of results - if repeated calls to this function with increasing offset will guarantee that you won't get repeats.
TYPE:
|
providers
|
Selection of 3-letter service identifiers
(e.g, For single provider you can either pass a single string, or a list of one
string. For Invalid codes will be ignored, however if all are invalid, then no filtering is done. You can look up values through |
| RETURNS | DESCRIPTION |
|---|---|
list[MediaEntry]
|
List of tuples with details of popular titles. |
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |
Source code in src/simplejustwatchapi/justwatch.py
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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
providers
¶
providers(country: str = 'US') -> list[OfferPackage]
Look up all providers for the given country.
| PARAMETER | DESCRIPTION |
|---|---|
country
|
2-letter country code for which offers are selected. It seems to be ISO 3166-1 alpha-2 standard (e.g.,
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[OfferPackage]
|
List of all found providers.
|
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |
Source code in src/simplejustwatchapi/justwatch.py
search
¶
search(title: str = '', country: str = 'US', language: str = 'en', count: int = 4, best_only: bool = True, offset: int = 0, providers: list[str] | str | None = None) -> list[MediaEntry]
Search JustWatch for the given title.
If no title is provided (or an empty string, as per default value) you'll get a
selection of "popular" titles. Without title the output is very similar to
popular function.
Title isn't stripped, so passing string with only spaces will look for those spaces.
JustWatch API won't allow for getting more than 1999 responses, either through
count, or when count + offset is equal or greater than 2000 - it will return an
empty list instead (always an empty list, it won't include entries up to
1999th).
| PARAMETER | DESCRIPTION |
|---|---|
title
|
Title to search. Not stripped, passed to the API as-is.
TYPE:
|
country
|
2-letter country code for which offers are selected. It seems to be ISO 3166-1 alpha-2 standard (e.g.,
TYPE:
|
language
|
Code for language in responses (e.g., description, title). It consists of 2 lowercase letters with optional uppercase alphanumeric
suffix after Its value isn't normalized and must be provided in expected format, including letter case.
TYPE:
|
count
|
Return up to this many results. Too high values can cause API errors due to too high operation complexity,
if you need more results, use with
TYPE:
|
best_only
|
Return only best offers if If service offers the same title in 4K, HD, and SD, then
TYPE:
|
offset
|
Offset for the first returned result, i.e. how many first entries should be skipped. This is done on API side, not the library side; the returned list is still directly parsed from API response. I'm not sure if it guarantees stability of results - if repeated calls to this function with increasing offset will guarantee that you won't get repeats.
TYPE:
|
providers
|
Selection of 3-letter service identifiers
(e.g, For single provider you can either pass a single string, or a list of one
string. For Invalid codes will be ignored, however if all are invalid, then no filtering is done. You can look up values through |
| RETURNS | DESCRIPTION |
|---|---|
list[MediaEntry]
|
List of tuples with details of search results. |
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |
Source code in src/simplejustwatchapi/justwatch.py
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 | |
seasons
¶
seasons(show_id: str, country: str = 'US', language: str = 'en', best_only: bool = True) -> list[MediaEntry]
Get details of all seasons available for a given show ID.
You can use episodes function to get
details for each episode of a single season.
| PARAMETER | DESCRIPTION |
|---|---|
show_id
|
ID of a show to look up seasons for.
TYPE:
|
country
|
2-letter country code for which offers are selected. It seems to be ISO 3166-1 alpha-2 standard (e.g.,
TYPE:
|
language
|
Code for language in responses (e.g., description, title). It consists of 2 lowercase letters with optional uppercase alphanumeric
suffix after Its value isn't normalized and must be provided in expected format, including letter case.
TYPE:
|
best_only
|
Return only best offers if If service offers the same title in 4K, HD, and SD, then
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[MediaEntry]
|
List of tuples with seasons data about requested show. |
| RAISES | DESCRIPTION |
|---|---|
JustWatchApiError
|
JSON response from API has internal errors, e.g., due to invalid language or country code. |
JustWatchHttpError
|
HTTP error occurred, e.g., JustWatch API
responded with non- |