Globally searching code by filename via APIv3


I’m currently trying to create an application that automatically searches github repositories for a specific filename and grab data from repos that have that file.

I’m currently using APIv3 because GraphQL does not properly support searching for filenames in code, only repositories.

According to this doc, it states that searching by filename is exempt from the user/org/repository requirement, but when I send the following GET request, it returns a 422 Unprocessable Entity validation error:

curl -i ''

I would greatly appreicate help on this issue, or a workaround solution.

Are you replacing xxxx and yyyy with your server application’s client ID and client secret that you got when you followed the instructions for building an OAuth app? When I don’t include a client ID and client secret, I get the 422 status like you describe.

Yes, the client ID and client secret are substituted with the proper values. It still requires me to specify a user, repo, or org for the search to be successful.

I just tried it using a Personal Access Token:

curl -i ''

and got the following response:

HTTP/1.1 200 OK
Date: Mon, 11 Jun 2018 22:01:04 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 5556
Status: 200 OK
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: 1528754524
Cache-Control: no-cache
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
X-Runtime-rack: 1.139346
Vary: Accept-Encoding
X-GitHub-Request-Id: AC94:6E19:8FAB2:BBE15:5B1EF11F

  "total_count": 1,
  "incomplete_results": false,
  "items": [
      "name": "mmur.yaml",
      "path": "mmur.yaml",
      "sha": "13ffa930d4d917ae076906a14390637f71587de9",
      "url": "",
      "git_url": "",
      "html_url": "",
      "repository": {
        "id": 94132730,
        "node_id": "MDEwOlJlcG9zaXRvcnk5NDEzMjczMA==",
        "name": "MMM-MBTA",
        "full_name": "edward-shen/MMM-MBTA",
        "owner": {
          "login": "edward-shen",
          "id": 6173958,
          "node_id": "MDQ6VXNlcjYxNzM5NTg=",
          "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
        "private": false,
        "html_url": "",
        "description": "MagicMirror² module for the Massachusetts Bay Transportation Authority",
        "fork": false,
        "url": "",
        "forks_url": "",
        "keys_url": "{/key_id}",
        "collaborators_url": "{/collaborator}",
        "teams_url": "",
        "hooks_url": "",
        "issue_events_url": "{/number}",
        "events_url": "",
        "assignees_url": "{/user}",
        "branches_url": "{/branch}",
        "tags_url": "",
        "blobs_url": "{/sha}",
        "git_tags_url": "{/sha}",
        "git_refs_url": "{/sha}",
        "trees_url": "{/sha}",
        "statuses_url": "{sha}",
        "languages_url": "",
        "stargazers_url": "",
        "contributors_url": "",
        "subscribers_url": "",
        "subscription_url": "",
        "commits_url": "{/sha}",
        "git_commits_url": "{/sha}",
        "comments_url": "{/number}",
        "issue_comment_url": "{/number}",
        "contents_url": "{+path}",
        "compare_url": "{base}...{head}",
        "merges_url": "",
        "archive_url": "{archive_format}{/ref}",
        "downloads_url": "",
        "issues_url": "{/number}",
        "pulls_url": "{/number}",
        "milestones_url": "{/number}",
        "notifications_url": "{?since,all,participating}",
        "labels_url": "{/name}",
        "releases_url": "{/id}",
        "deployments_url": ""
      "score": 17.562763

so the API is working as documented. I’m not sure what is going wrong. You may want to reach out to private support at so they can take a closer look at your private configuration.

Thank you for helping with my issue. I’ll use a PAT for now, but I’ll follow up with Github support to see what’s going on.

1 Like