nextToken in AWS boto3 Request

In one of my projects, I was trying to obtain a list of all available files in an AWS s3 bucket, which is done through an API call through boto3.

However, I noticed that the returned list isn't complete, and that there is an additional field nextToken.

A quick search returns this StackOverflow page that solves my problem. Basically, the API may not return the complete result when it is too long. Instead, it returns a partial result + nextToken. You can use nextToken in the next API call to continue retrieving the remainder of the result.

Obviously, a while loop would suffice for retrieving the full list of files that I wanted.


You'll only receive email when they publish something new.

More from Spark Tseung
All posts