Searching for repositories that use a specific file extension

Couldn’t see this in the dropdown. I’m trying to phrase a query with the Search API that’ll return a list of all public repositories that have a specific file extension. 

For example if I wanted to get all that contain a .json file. 

Right now I’ve tried: 

https://api.github.com/search/extension:.[extensionname]&type=Code
But I’m struggling to find good examples I can use.

Hey @ljsikuade,

Thanks for being here! You can search by file extension, per the docs:

Suppose you want to search for popular Tetris repositories written in Assembly. Your query might look like this.

curl https://api.github.com/search/repositories?q=tetris+language:assembly&sort=stars&order=desc

You can search for multiple topics by adding more topic: instances, and including the mercy-preview header. For example:

curl -H "Accept: application/vnd.github.mercy-preview+json" \
https://api.github.com/search/repositories?q=topic:ruby+topic:rails

In this request, we’re searching for repositories with the word tetris in the name, the description, or the README. We’re limiting the results to only find repositories where the primary language is Assembly. 

Check out the docs for more info.

I hope this helps!

Andrea

2 Likes

https://api.github.com/search/extension:.[extensionname]&type=Code