@@ -170,6 +170,50 @@ results = search("title", count=200, offset=1950)
170170
171171
172172
173+ ## Getting more results and pagination
174+
175+ This library allows for very simple pagination in
176+ [ ` search ` ] [ simplejustwatchapi.justwatch.search ] and
177+ [ ` popular ` ] [ simplejustwatchapi.justwatch.popular ] commands through ` count ` and ` offset `
178+ arguments. The first one configures how many entries are returned in one request, the
179+ second allows for offsetting which is the "first" result (thus "skipping" first
180+ entries).
181+
182+ This lets you get around issues with [ operation complexity] ( #operation-complexity )
183+ and get more data. For example, to get all available popular titles without running
184+ into the issue with complexity you can:
185+
186+ ``` python
187+ from simplejustwatchapi import popular
188+
189+ i = 0
190+ page = 99
191+ all_results = []
192+ while results := popular(count = page, offset = i):
193+ i += page
194+ all_results.extend(results)
195+ # len(all_results) == 1980
196+ ```
197+ While trying to get them all at once will result in an exception:
198+ ``` python
199+ from simplejustwatchapi import popular
200+
201+ results = popular(count = 1980 )
202+ # JustWatchApiError is raised due to too high operation complexity.
203+ ```
204+
205+ Unfortunately, I don't know of any way around the issue with
206+ [ maximum number of entries] ( #maximum-number-of-entries ) , so it's impossible to get more
207+ than 1999 elements.
208+
209+ !!! note "Stability of results with pagination"
210+ All "pagination" is done on the side of the API, by offsetting which is the first
211+ element, nothing is done on the side of this library. Since this operation isn't
212+ keeping any context between requests there's no guarantee of "stability" of results
213+ between requests - whether titles will shift order while you're getting pages.
214+
215+
216+
173217## Provider codes
174218
175219!!! tip "Different countries can have different codes"
0 commit comments