Skip to content

Instantly share code, notes, and snippets.

Last active April 30, 2024 19:21
Show Gist options
  • Save jasonrudolph/6065289 to your computer and use it in GitHub Desktop.
Save jasonrudolph/6065289 to your computer and use it in GitHub Desktop.
5 entertaining things you can find with the GitHub Search API

Find the oldest user accounts with zero followers

Go follow these poor souls.

$ curl -G   \
    --data-urlencode 'q=followers:0'            \
    --data-urlencode 'sort=joined'              \
    --data-urlencode 'order=asc'                \
    -H 'Accept: application/vnd.github.preview' \
    | jq '.items[0,1,2] | {html_url, login, id}'
  "id": 30,
  "login": "fanvsfan",
  "html_url": ""
  "id": 32,
  "login": "railsjitsu",
  "html_url": ""
  "id": 44,
  "login": "errfree",
  "html_url": ""

Check out the User Search API docs for more details.

Find recently-indexed Clojure projects using an MIT license

Rebels! I bet these dudes don't like hammocks either.

$ curl -G          \
    --data-urlencode 'q=MIT License path:project.clj' \
    --data-urlencode 'sort=indexed'                   \
    --data-urlencode 'order=desc'                     \
    -H 'Accept: application/vnd.github.preview'       \
    | jq '.items[0,1,2] | {description: (.repository.description), name: (.repository.full_name), html_url}'
  "html_url": "",
  "name": "royvandewater/optparse",
  "description": "Option parser for clojure"
  "html_url": "",
  "name": "SnootyMonkey/coming-soon",
  "description": "coming-soon is a simple Clojure/ClojureScript/Redis 'landing page' application that takes just a few minute to setup"
  "html_url": "",
  "name": "rreas/ring-test",
  "description": "An integration test framework for ring web applications."

Check out the Code Search API docs for more details.

What does John Resig work on other than JavaScript?

$ curl -G   \
    --data-urlencode 'q=@jeresig -language:javascript' \
    -H 'Accept: application/vnd.github.preview'        \
    | jq '.items[] | {html_url, watchers_count, language, name}'
  "name": "processing-js",
  "language": "Java",
  "watchers_count": 1455,
  "html_url": ""
  "name": "selectortest",
  "language": null,
  "watchers_count": 12,
  "html_url": ""
  "name": "wtpa-bot",
  "language": "Perl",
  "watchers_count": 9,
  "html_url": ""
  "name": "",
  "language": null,
  "watchers_count": 6,
  "html_url": ""
  "name": "apples2artworks",
  "language": "Python",
  "watchers_count": 1,
  "html_url": ""
  "name": "datacook",
  "language": "Perl",
  "watchers_count": 0,
  "html_url": ""

@jeresig has a repo with zero people watching it? This changes my whole worldview.

Check out the Repository Search API docs for more details.

Find the most commented issues in the past month

OK. OK. You were only expecting 5 examples. But since you read this far, here's a bonus one.

# We'll use the `date` command to get the date for "1 month ago"
$ date -v-1m '+%Y-%m-%d'
# => 2013-06-23

$ curl -G             \
    --data-urlencode "q=created:>`date -v-7d '+%Y-%m-%d'`" \
    --data-urlencode 'sort=comments'                       \
    --data-urlencode 'order=desc'                          \
    -H 'Accept: application/vnd.github.preview'            \
    | jq '.items[0,1,2] | {html_url, title, comments}'

I ran this a couple months ago, when we were first sketching out the search API. What did I find? A Pull Request to remove all press representatives from Followed by another Pull Request to counteract the first one.

Interesting times.

  "comments": 158,
  "title": "Remove press representatives",
  "html_url": ""
  "comments": 151,
  "title": "Add several independent voices to the Press Center page",
  "html_url": ""
  "comments": 150,
  "title": "Select and implement a template engine (or The issue to discuss everything Framework refactoring)",
  "html_url": ""

Check out the Issue Search API docs for more details.

Copy link

RickyS commented Jan 19, 2014

The date command on Ubuntu Linux does not have the '-v' flag.

Copy link

Try @rochefort's git-trend. It's a command line utility that shows you trending github repos. Another is my github-trending gem that fetches daily, weekly and monthly trending repositories on github.

Copy link

Does any of the current github python api does advanced search like this?

Copy link

Its probably only entertaining on MacOS date: invalid option -- 'v'

created_on=`date --date="${i} days ago" '+%Y-%m-%d'

and add --silent to curl argument

Copy link

How about Find the hottest repositories created in the last week, just like

Copy link

nealmcb commented Sep 26, 2017

Your query doesn't work. I wonder if they added this requirement after you posted this.

  "message": "Validation Failed",
  "errors": [
      "message": "Must include at least one user, organization, or repository",
      "resource": "Search",
      "field": "q",
      "code": "invalid"
  "documentation_url": ""

Copy link

Potherca commented Oct 3, 2017

@nealmcb This has to do with authentication. Quoting from the "Considerations for code search" section of the article on searching code:

Logged in users can search all public repositories while anonymous searches must include a limit on org:, user:, or repo:.

If you add authentication to your calls, things should work as described...

Copy link

akashynwa commented Oct 30, 2017

Jason, basically I want to find the pull requests of a repository which are older than 7 days of the present date so my query for getting the pull requests is as follows:::

the response is as follows
"url": "",
"id": 147991930,
"html_url": "",
"diff_url": "",
"patch_url": "",
"issue_url": "",
"number": 951,
"state": "open",
"locked": false,
"title": "CI against Ruby 2.2.8, 2.3.5, 2.4.2",
"user": {
"login": "yatmsu",
"id": 436515,
"avatar_url": "",
"gravatar_id": "",
"url": "",
"html_url": "",
"followers_url": "",
"following_url": "{/other_user}",
"gists_url": "{/gist_id}",
"starred_url": "{/owner}{/repo}",
"subscriptions_url": "",
"organizations_url": "",
"repos_url": "",
"events_url": "{/privacy}",
"received_events_url": "",
"type": "User",
"site_admin": false
"body": "\r\n\r\n",
"created_at": "2017-10-22T12:51:14Z",
"updated_at": "2017-10-22T13:36:43Z",
"closed_at": null,
"merged_at": null,
"merge_commit_sha": "d0ea0ed9a32999b62c154515c4ebb351486243ef",
"assignee": null,
"assignees": [],
"requested_reviewers": [],
"milestone": null,
"commits_url": "",
"review_comments_url": "",
"review_comment_url": "{/number}",
"comments_url": "",
"statuses_url": "",
"head": {

so what parameters should I add after pulls to get the pull requests based on date (older than 7 days),
can you give me the exact query, (I can see the created at parameter in the response but I don't know how to use it)

I want to use this get get call in my python script, so I think we can't use --data--urlencode.
can you give me the exact query so that it works in postman and my python script.


Copy link

Find all repositories that are actually online?

Copy link

bharathi-tenneti commented Oct 16, 2019

Is Code search API useful for searching, filename:x across all repositories with "xyz in the file content? As of now, it throws me error saying that it, need User/repo/Organization

Copy link

fniessen commented Dec 3, 2019

The above requests seem not to be working anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment