To list all files on a page with title Foo:
/api.php?action=query&format=json&prop=images&titles=Foo&imlimit=500
To list all files on a wiki:
/api.php?action=query&format=json&list=allimages&ailimit=500
If the response includes a `continue` object, you can fetch the next page by passing along the returned `imcontinue` or `aicontinue` value in your next request. See https://www.mediawiki.org/w/api.php?action=help&modules=query%2Bimages and https://www.mediawiki.org/w/api.php?action=help&modules=query%2Ballimages for details.