I want to fetch the contents of a random file written in a given programming language to use for a typing game. Using JavaScript as an example, I’ve used the search API to find repositories containing JavaScript:
But I’m having trouble figuring out how to list a repo’s JavaScript files and fetch their contents. Is there a way to do this? Is there a better way to get the contents of a random JavaScript file (preferrably from a highly-starred repo)?
I’m still not sure how to find a file of a particular language in a repo. My search query above lists repos that have a file using the language somewhere, but I can’t figure out a way to list those files and their paths.
I think there may be a miscommunication, I am not looking for a list of supported languages. What I want to do is:
Get a list of repos containing an language (e.g. JavaScript)
For one of the listed repos, get a list of files written in that language
Get the content of one of the listed files
I already know how to do step 1 using the search query in my original post. Your first comment showed me how to do step 3 (thanks again!). What I still don’t know is how to do step 2.