Make paginated HTTP requests in python using the requests module,

import requests
 
BASE_URL = 'https://jsonmock.hackerrank.com/api/football_matches'
 
def getMatches():
    page_number = 1
    all_matches = []
 
    try:
        while True:
            print(f'Fetching page {page_number}')
            page = requests.get(f'{BASE_URL}?year=2011&page={page_number}')
 
            data = page.json()
            all_matches += data['data']
 
            if page_number == data['total_pages']:
               break
 
            page_number += 1
 
        return all_matches
    except:
        print('Error fetching data')
        return []
    
 
if __name__ == '__main__':
 
    matches = getMatches()
    print(matches)