Skip to main content

Search commits

Find commits via various criteria on the default branch (usually `master`). This method returns up to 100 results [per page](https://docs.github.com/[email protected]/rest/overview/resources-in-the-rest-api#pagination). When searching for commits, you can get text match metadata for the **message** field when you provide the `text-match` media type. For more details about how to receive highlighted search results, see [Text match metadata](https://docs.github.com/[email protected]/rest/reference/search#text-match-metadata). For example, if you want to find commits related to CSS in the [octocat/Spoon-Knife](https://github.com/octocat/Spoon-Knife) repository. Your query would look something like this: `q=repo:octocat/Spoon-Knife+css`

GET/search/commits
Source
github-v3-rest.json
Revision
f5f067c1e6f6
Active snapshot
85e53e3d0d65

Request

Query Parameters
q string
required

The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as GitHub.com. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/[email protected]/rest/reference/search#constructing-a-search-query). See "[Searching commits](https://docs.github.com/articles/searching-commits/)" for a detailed list of qualifiers.

sort string
optional

Sorts the results of your query by `author-date` or `committer-date`. Default: [best match](https://docs.github.com/[email protected]/rest/reference/search#ranking-search-results)

order string
optional

Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`.

per_page integer
optional

Results per page (max 100)

page integer
optional

Page number of the results to fetch.

Responses

application/json object

Response

incomplete_results boolean
required
items array[Commit Search Result Item object]
required
items Commit Search Result Item object

Commit Search Result Item

author Simple User object
requirednullable

Simple User

avatar_url string<uri>
required

Example: https://github.com/images/error/octocat_happy.gif

email string
optionalnullable
events_url string
required

Example: https://api.github.com/users/octocat/events{/privacy}

followers_url string<uri>
required

Example: https://api.github.com/users/octocat/followers

following_url string
required

Example: https://api.github.com/users/octocat/following{/other_user}

gists_url string
required

Example: https://api.github.com/users/octocat/gists{/gist_id}

gravatar_id string
requirednullable

Example: 41d064eb2195891e12d0413f63227ea7

html_url string<uri>
required

Example: https://github.com/octocat

id integer
required

Example: 1

login string
required

Example: octocat

name string
optionalnullable
node_id string
required

Example: MDQ6VXNlcjE=

organizations_url string<uri>
required

Example: https://api.github.com/users/octocat/orgs

received_events_url string<uri>
required

Example: https://api.github.com/users/octocat/received_events

repos_url string<uri>
required

Example: https://api.github.com/users/octocat/repos

site_admin boolean
required
starred_at string
optional

Example: "2020-07-09T00:17:55Z"

starred_url string
required

Example: https://api.github.com/users/octocat/starred{/owner}{/repo}

subscriptions_url string<uri>
required

Example: https://api.github.com/users/octocat/subscriptions

type string
required

Example: User

url string<uri>
required

Example: https://api.github.com/users/octocat

comments_url string<uri>
required
commit object
required
author object
required
comment_count integer
required
committer Git User object
requirednullable

Metaproperties for Git author/committer information.

message string
required
tree object
required
url string<uri>
required
verification Verification object
optional
committer Git User object
requirednullable

Metaproperties for Git author/committer information.

date string
optional

Example: "2007-10-29T02:42:39.000-07:00"

email string
optional

Example: "[email protected]"

name string
optional

Example: "Chris Wanstrath"

html_url string<uri>
required
node_id string
required
parents array[object]
required
repository Minimal Repository object
required

Minimal Repository

allow_forking boolean
optional
archive_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}

archived boolean
optional
assignees_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/assignees{/user}

blobs_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}

branches_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/branches{/branch}

clone_url string
optional
code_of_conduct Code Of Conduct object
optional

Code Of Conduct

collaborators_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}

comments_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/comments{/number}

commits_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/commits{/sha}

compare_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}

contents_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/contents/{+path}

contributors_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/contributors

created_at string<date-time>
optionalnullable

Example: 2011-01-26T19:01:12Z

default_branch string
optional
delete_branch_on_merge boolean
optional
deployments_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/deployments

description string
requirednullable

Example: This your first repo!

disabled boolean
optional
downloads_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/downloads

events_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/events

fork boolean
required
forks integer
optional

Example: 0

forks_count integer
optional
forks_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/forks

full_name string
required

Example: octocat/Hello-World

git_commits_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/git/commits{/sha}

git_refs_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/git/refs{/sha}

git_tags_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/git/tags{/sha}

git_url string
optional
has_downloads boolean
optional
has_issues boolean
optional
has_pages boolean
optional
has_projects boolean
optional
has_wiki boolean
optional
homepage string
optionalnullable
hooks_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/hooks

html_url string<uri>
required

Example: https://github.com/octocat/Hello-World

id integer
required

Example: 1296269

is_template boolean
optional
issue_comment_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/issues/comments{/number}

issue_events_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/issues/events{/number}

issues_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/issues{/number}

keys_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/keys{/key_id}

labels_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/labels{/name}

language string
optionalnullable
languages_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/languages

license object
optionalnullable
merges_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/merges

milestones_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/milestones{/number}

mirror_url string
optionalnullable
name string
required

Example: Hello-World

network_count integer
optional
node_id string
required

Example: MDEwOlJlcG9zaXRvcnkxMjk2MjY5

notifications_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}

open_issues integer
optional

Example: 0

open_issues_count integer
optional
owner Simple User object
required

Simple User

permissions object
optional
private boolean
required
pulls_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/pulls{/number}

pushed_at string<date-time>
optionalnullable

Example: 2011-01-26T19:06:43Z

releases_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/releases{/id}

size integer
optional
ssh_url string
optional
stargazers_count integer
optional
stargazers_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/stargazers

statuses_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/statuses/{sha}

subscribers_count integer
optional
subscribers_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/subscribers

subscription_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/subscription

svn_url string
optional
tags_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/tags

teams_url string<uri>
required

Example: http://api.github.com/repos/octocat/Hello-World/teams

temp_clone_token string
optional
template_repository Repository object
optionalnullable

A git repository

topics array
optional
trees_url string
required

Example: http://api.github.com/repos/octocat/Hello-World/git/trees{/sha}

updated_at string<date-time>
optionalnullable

Example: 2011-01-26T19:14:43Z

url string<uri>
required

Example: https://api.github.com/repos/octocat/Hello-World

visibility string
optional
watchers integer
optional

Example: 0

watchers_count integer
optional
score number
required
sha string
required
text_matches Search Result Text Matches array[object]
optional
url string<uri>
required
total_count integer
required

Not modified