Hi guys I am a python beginner I am trying to fetch all the information from an API whose responses are paginated.I am trying to get the "pagination data" so that I can use that to create my loop using request library.How can write the following shell command in python for me to get the desired results
curl -IXGET https://api.myapplication.com/products?page=1 -H "Content-type: application/json" -H "Authorization: Bearer <PRIVILEGED_ACCESS_TOKEN>" | grep X-Pagination
X-Pagination: {"total_records":3103,"total_pages":32,"first_page":true,"last_page":false,"out_of_bounds":false,"offset":0}
I tried doing this but am getting an error: AttributeError: 'Response' object has no attribute 'type'
import requests
import json
from urllib.request import urlopen,Request
my_headers = {'Authorization': 'Bearer 9YU5OXYdQlBXfROYAXrthdgqli8rkXMAnB5jEmkPZzE'}
pag_results = requests.get('https://api.myapplication.com/products?page=1,headers={"Content-type: application/json"}',headers=my_headers)
pagination_res1 = urlopen(pag_results)
pagination_res2 = pagination_res1.read()
print(pagination_res2)