Need help to understand the documentation of Sentry API

Question:

I am making an API request to the sentry API, like this:

_URL = "https://sentry.io/api/0/projects/aaaa-7y/aaaa/issues/"
headers = {'Authorization': 'Bearer 11111111111111111111111', 'Content-Type': 'application/json'}
params = {"statsPeriod":"24h", 'cursor':'100:-1:1'}

r = requests.get(url = _URL, headers = headers, params=params, verify=False) 
data = r.json()

and I realized that I am only getting 100 results despite I have more in the endpoint UI.
According to the documentation, I should use the pagination: https://docs.sentry.io/api/pagination/ but I am having a really good time trying to understand how to implement it because the response does not provide anything that I can use for pagination. What I am missing in my API request.

See the start of the response. I was expecting to see something like rel="previous"; results="false"; according to the documentation.

[{'id': '',
  'shareId': None,
  'shortId': 'aaaa-8Y',
  'title': '<unknown>',
  'culprit': '',
  'permalink': 'https://sentry.io/organizations/7777-7y/issues/777777/',
  'logger': None,
  'level': 'error',
  'status': 'unresolved',
  'isPublic': False,
  'platform': 'javascript',
  'project': {'id': '7777',
   'name': 'aaaa',
   'slug': 'aaaa',
   'platform': 'react-native'},
  'type': 'error',
  'metadata': {'value': 'aaa: Variable "$input" got invalid value { aa: "google-aaaa|aaaaa", uri: "https://storage.googleapis.com/glue-storage-prod/aa/aa-e267-4bfe-90bd-aaa.png", imageWidth: 1169, imageHeight: 253...',
   'display_title_with_tree_label': False},
  'numComments': 0,
  'assignedTo': None,
  'isBookmarked': False,
  'isSubscribed': False,
  'subscriptionDetails': None,
  'hasSeen': False,
  'issueType': 'error',
  'issueCategory': 'error',
  'isUnhandled': False,
  'count': '2',
  'userCount': 0,
  'firstSeen': '2022-08-04T11:47:52.295000Z',
  'lastSeen': '2022-08-10T07:24:18.899000Z'},
Asked By: user13603107

||

Answers:

If in first example you switch bash to http then you see:

enter image description here

It sends this as HTTP header, not in response/JSON.

You need:

link = r.headers['Link']        # it raises error when `Link` doesn't exist

or safer

link = r.headers.get('Link')    # it gives `None` when `Link` doesn't exist
Answered By: furas

Thanks for your support.
For anyone’s reference with Sentry’s API, I ended up doing this to fetch data and paginate:

data_set=[]

    while r.links['next']['results'] == "true":
        r = requests.get(r.links['next']['url'], headers = headers, params=params, verify=False) 
        data = r.json()
        for req in data:
            data_set.append(req)
Answered By: user13603107