Code to get a list of all images in media folder

Is it possible to programatically get a list of all files in a media folder? If so how? I’m looking to provide a custom API endpoint to images in a folder directly, without having to create a collection and post for each image.