Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
Python - API- pagination Graphql

I would like to retrieve data from an API, the problem is that it only returns 49 data each time. I got the startCursor, hasNextPage and endCursor but I don't know how to tell the script to loop until hasNextPage=False based on the endCursor and thus have all the data for my request. Here is the code:

import requests
import json

query = """
    query {
      player(slug:"lionel-andres-messi-cuccittini"){
            cards(rarities:[limited]) {
                nodes {
                    slug
                    userOwnerWithRate {
                        from
        }
        }
      pageInfo{
        startCursor
        hasNextPage
        endCursor
    }
    }
    }
  }
"""
url = 'https://api.sorare.com/graphql/'
r = requests.post(url, json={'query': query})
json_data = json.loads(r.text)
print(json_data)

Do you have an idea to help me get all the pages of a request please?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!