I've built an npm library called codeowners-api which does this . So its not python but in JS.
If you want to use REST you would need to fetch the codeowners file from the Repo in question using Github's get-file API.
After that you take the file and you iterate over the codeowners file until you find the match. You can look at my library's code as reference.
I've also created a chrome extension which gives the reviewer a filter button to see only their relevant files.