Loop on api call using Invoke-RestMethod

Greetings…

I am working on processing json data from a rest api call using Invoke-RestMethod. This api call is trying to bring back multiple gigs of data and run into timeout or system out of memory exception. I am now trying to loop on smaller set of data based on year parameter. For instance, For the year 2015, I pass the value 2015 to the date parameter write data to a file. Then, increment year to 2016 pass the value 2016 to the date parameter and append data to the same file. Repeat the process until the current year in this instance it would be until the year 2022 and appending 2022 data to the same file. Please point me in the right direction.

try {
         $clientSecret = ''
         $clientId = ''
         $tenantId = ''
         # Construct URI
         $uri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
         # Construct Body
         $body = @{
             client_id = $clientId
             client_secret = $clientSecret
             scope = 'https://graph.microsoft.com/.default'
             grant_type = 'client_credentials'
         }
         $Uri = 'https://apiserver.com/v1/data/year/'
         # Get OAuth 2.0 Token
         $tokenRequest = Invoke-WebRequest -Method Post -Uri $uri -ContentType 'application/x-www-form-urlencoded' -Body $body -UseBasicParsing
         # Access Token
         $token = ($tokenRequest.Content | ConvertFrom-Json).access_token
         $api = Invoke-RestMethod -Method Get -Uri $Uri -ContentType 'application/json' -Headers @{Authorization = "Bearer $token"} -ErrorAction Stop
     }
 catch {
         "Error" 
         Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
         Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
         Write-Host "ErrorMessage:" $_.ErrorDetails.Message
     }

I am doing this by passing the date parameter but not sure how to append data.

$setYear = 2015
$getYear = [Int]((Get-Date).year)

for($i=$setYear; $i -le $getYear; $i=$setYear+1){Invoke-RestMethod -Method Get -Uri $Uri+ [string]$i -ContentType 'application/json' -Headers @{Authorization = "Bearer $token"} -ErrorAction Stop | ConvertTo-Json}

Thanks for your guidance.