Get content of random file for given language?

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)?

Thanks for any help anyone can give!

how about this one ?

do the search first then once you have a target file, read the content

Hi @jdevstatic that’s helpful, thank you!

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 is a similar question on how to find the list of supported language by GitHub and this is the particular repo, I think so,

you can also ask them by raising an issue

I think there may be a miscommunication, I am not looking for a list of supported languages. What I want to do is:

  1. Get a list of repos containing an language (e.g. JavaScript)
  2. For one of the listed repos, get a list of files written in that language
  3. 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.

how about this one ?

it includes the file name extension, so you would know the language