'What would be a more efficient method to paginate through this API?

I created a few lines of code to paginate through an API, but with a time complexity of O(n^2), I'm curious if there is a more efficient way to implement this code.

#Example JSON Response
[
  {
    "internalName": "DEUSEXHUMANREVOLUTIONDIRECTORSCUT",
    "title": "Deus Ex: Human Revolution - Director's Cut",
    "metacriticLink": "/game/pc/deus-ex-human-revolution---directors-cut",
    "dealID": "HhzMJAgQYGZ%2B%2BFPpBG%2BRFcuUQZJO3KXvlnyYYGwGUfU%3D",
    "storeID": "1",
    "gameID": "102249",
    "salePrice": "2.99",
    "normalPrice": "19.99",
    "isOnSale": "1",
    "savings": "85.042521",
    "metacriticScore": "91",
    "steamRatingText": "Very Positive",
    "steamRatingPercent": "92",
    "steamRatingCount": "17993",
    "steamAppID": "238010",
    "releaseDate": 1382400000,
    "lastChange": 1621536418,
    "dealRating": "9.6",
    "thumb": "https://cdn.cloudflare.steamstatic.com/steam/apps/238010/capsule_sm_120.jpg?t=1619788192"
  },
response = requests.get("https://www.cheapshark.com/api/1.0/deals")
numPages = response.headers['X-Total-Page-Count']

entries = []

for page in range(0, int(numPages):
    url = f"https://www.cheapshark.com/api/1.0/deals&pageNumber={page}"
    data = requests.get(url).json()
    for i in range(60):
        allData = {
            'title' : data[i]['title'],
            'salePrice' : data[i]['salePrice']
        }
        entries.append(allData)
    page += 1


Solution 1:[1]

If that's the API provided by the service, then nope -- you're as efficient as you'll get.

As an aside: I see you're doing for i in range(60) and guessing that there are 60 items per page? It might be better to simply iterate through all the entries in data instead in case the number of items per page changes over time (e.g., imagine the last page -- you might not have a full 60 items...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JJ Geewax