Aug
SEP
Oct
10
2019
2020
2021
About this capture
T h e W a y b a c k M a c h i n e - h t t p : / / w e b . a r c h i v e . o r g / w e b / 2 0 2 0 0 9 1 0 2 3 3 0 5 0 / h t t p s : / / d e v e l o p e r . g i t h u b . c o m / v 3 /
D o c s
V e r s i o n s
T h e c o n t e n t o n t h i s s i t e m a y b e o u t o f d a t e . F o r t h e m o s t a c c u r a t e a n d u p - t o - d a t e c o n t e n t , v i s i t d o c s . g i t h u b . c o m .
W e ' v e u n i f i e d a l l o f G i t H u b ' s p r o d u c t d o c u m e n t a t i o n i n o n e p l a c e ! C h e c k o u t t h e n e w l o c a t i o n s f o r R E S T A P I , G r a p h Q L A P I , a n d D e v e l o p e r s .
L e a r n m o r e o n t h e G i t H u b b l o g .
● R e f e r e n c e
● G u i d e s
● L i b r a r i e s
Navigate the docs…
API Overview
Media Types
OAuth Authorizations API
Other Authentication Methods
Troubleshooting
API Previews
Versions
Activity overview
Events
Event Types and Payloads
Feeds
Notifications
Starring
Watching
Checks
Check Runs
Check Suites
Code Scanning
Gists overview
Comments
Git Data overview
Blobs
Commits
References
Tags
Trees
GitHub Actions Overview
Artifacts
Secrets
Self-hosted runners
Workflows
Workflow jobs
Workflow runs
GitHub Apps overview
OAuth Applications API
Installations
Permissions
Available Endpoints
GitHub Marketplace
Interactions
Organization
Repository
Issues overview
Assignees
Comments
Events
Labels
Milestones
Timeline
Issue Event Types
Migrations overview
Organization
Source Imports
User
Miscellaneous overview
Codes of Conduct
Emojis
Gitignore
Licenses
Markdown
Meta
Rate Limit
Organizations overview
Blocking Users (Organizations)
Members
Outside Collaborators
Webhooks
Projects overview
Cards
Collaborators
Columns
Pull Requests overview
Reviews
Review Comments
Review Requests
Reactions overview
Commit Comment
Issue
Issue Comment
Pull Request Review Comment
Team Discussion
Team Discussion Comment
Repositories overview
Branches
Collaborators
Comments
Commits
Community
Contents
Deploy Keys
Deployments
Forks
Invitations
Merging
Pages
Releases
Statistics
Statuses
Traffic
Webhooks
Search overview
Repositories
Code
Commits
Issues
Users
Topics
Text match metadata
Teams
Discussions
Discussion comments
Members
Team sunchronization
SCIM
Users overview
Blocking Users
Emails
Followers
Git SSH Keys
GPG Keys
O v e r v i e w
T h i s d e s c r i b e s t h e r e s o u r c e s t h a t m a k e u p t h e o f f i c i a l G i t H u b R E S T A P I v 3 . I f y o u h a v e a n y p r o b l e m s o r r e q u e s t s , p l e a s e c o n t a c t G i t H u b S u p p o r t or G i t H u b P r e m i u m S u p p o r t .
● C u r r e n t v e r s i o n
● S c h e m a
● A u t h e n t i c a t i o n
● P a r a m e t e r s
● R o o t e n d p o i n t
● G r a p h Q L g l o b a l n o d e I D s
● C l i e n t e r r o r s
● H T T P r e d i r e c t s
● H T T P v e r b s
● H y p e r m e d i a
●
● R a t e l i m i t i n g
● U s e r a g e n t r e q u i r e d
● C o n d i t i o n a l r e q u e s t s
● C r o s s o r i g i n r e s o u r c e s h a r i n g
● J S O N - P c a l l b a c k s
● T i m e z o n e s
C u r r e n t v e r s i o n
B y d e f a u l t , a l l r e q u e s t s t o h t t p s : / / a p i . g i t h u b . c o m r e c e i v e t h e v 3 v e r s i o n o f t h e R E S T A P I .
W e e n c o u r a g e y o u t o e x p l i c i t l y r e q u e s t t h i s v e r s i o n v i a t h e A c c e p t h e a d e r .
Accept: application/vnd.github.v3+json
F o r i n f o r m a t i o n a b o u t G i t H u b ' s G r a p h Q L A P I v 4 , s e e t h e v 4 d o c u m e n t a t i o n . F o r i n f o r m a t i o n a b o u t m i g r a t i n g t o G r a p h Q L , s e e " M i g r a t i n g f r o m R E S T . "
S c h e m a
A l l A P I a c c e s s i s o v e r H T T P S , a n d a c c e s s e d f r o m h t t p s : / / a p i . g i t h u b . c o m . A l l d a t a i s
s e n t a n d r e c e i v e d a s J S O N .
curl -i https://api.github.com/users/octocat/orgs
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 12 Oct 2012 23:33:14 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
ETag: "a00049ba79152d03380c34652f2cb612"
X-GitHub-Media-Type: github.v3
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4987
X-RateLimit-Reset: 1350085394
Content-Length: 5
Cache-Control: max-age=0, private, must-revalidate
X-Content-Type-Options: nosniff
B l a n k f i e l d s a r e i n c l u d e d a s n u l l i n s t e a d o f b e i n g o m i t t e d .
A l l t i m e s t a m p s r e t u r n i n I S O 8 6 0 1 f o r m a t :
YYYY-MM-DDTHH:MM:SSZ
F o r m o r e i n f o r m a t i o n a b o u t t i m e z o n e s i n t i m e s t a m p s , s e e t h i s s e c t i o n .
S u m m a r y r e p r e s e n t a t i o n s
W h e n y o u f e t c h a l i s t o f r e s o u r c e s , t h e r e s p o n s e i n c l u d e s a s u b s e t o f t h e
a t t r i b u t e s f o r t h a t r e s o u r c e . T h i s i s t h e " s u m m a r y " r e p r e s e n t a t i o n o f t h e
r e s o u r c e . ( S o m e a t t r i b u t e s a r e c o m p u t a t i o n a l l y e x p e n s i v e f o r t h e A P I t o p r o v i d e .
F o r p e r f o r m a n c e r e a s o n s , t h e s u m m a r y r e p r e s e n t a t i o n e x c l u d e s t h o s e a t t r i b u t e s .
T o o b t a i n t h o s e a t t r i b u t e s , f e t c h t h e " d e t a i l e d " r e p r e s e n t a t i o n . )
E x a m p l e : W h e n y o u g e t a l i s t o f r e p o s i t o r i e s , y o u g e t t h e s u m m a r y
r e p r e s e n t a t i o n o f e a c h r e p o s i t o r y . H e r e , w e f e t c h t h e l i s t o f r e p o s i t o r i e s o w n e d
b y t h e o c t o k i t o r g a n i z a t i o n :
GET /orgs/octokit/repos
D e t a i l e d r e p r e s e n t a t i o n s
W h e n y o u f e t c h a n i n d i v i d u a l r e s o u r c e , t h e r e s p o n s e t y p i c a l l y i n c l u d e s a l l
a t t r i b u t e s f o r t h a t r e s o u r c e . T h i s i s t h e " d e t a i l e d " r e p r e s e n t a t i o n o f t h e
r e s o u r c e . ( N o t e t h a t a u t h o r i z a t i o n s o m e t i m e s i n f l u e n c e s t h e a m o u n t o f d e t a i l
i n c l u d e d i n t h e r e p r e s e n t a t i o n . )
E x a m p l e : W h e n y o u g e t a n i n d i v i d u a l r e p o s i t o r y , y o u g e t t h e d e t a i l e d
r e p r e s e n t a t i o n o f t h e r e p o s i t o r y . H e r e , w e f e t c h t h e
o c t o k i t / o c t o k i t . r b r e p o s i t o r y :
GET /repos/octokit/octokit.rb
T h e d o c u m e n t a t i o n p r o v i d e s a n e x a m p l e r e s p o n s e f o r e a c h A P I m e t h o d . T h e e x a m p l e
r e s p o n s e i l l u s t r a t e s a l l a t t r i b u t e s t h a t a r e r e t u r n e d b y t h a t m e t h o d .
A u t h e n t i c a t i o n
T h e r e a r e t w o w a y s t o a u t h e n t i c a t e t h r o u g h G i t H u b A P I v 3 . R e q u e s t s t h a t
r e q u i r e a u t h e n t i c a t i o n w i l l r e t u r n 4 0 4 N o t F o u n d , i n s t e a d o f
4 0 3 F o r b i d d e n , i n s o m e p l a c e s . T h i s i s t o p r e v e n t t h e a c c i d e n t a l l e a k a g e
o f p r i v a t e r e p o s i t o r i e s t o u n a u t h o r i z e d u s e r s .
B a s i c a u t h e n t i c a t i o n
curl -u "username" https://api.github.com
O A u t h 2 t o k e n ( s e n t i n a h e a d e r )
curl -H "Authorization: token OAUTH-TOKEN " https://api.github.com
N o t e : G i t H u b r e c o m m e n d s s e n d i n g O A u t h t o k e n s u s i n g t h e A u t h o r i z a t i o n h e a d e r .
R e a d m o r e a b o u t O A u t h 2 . N o t e t h a t O A u t h 2 t o k e n s c a n b e a c q u i r e d u s i n g t h e w e b a p p l i c a t i o n f l o w f o r p r o d u c t i o n a p p l i c a t i o n s .
O A u t h 2 k e y / s e c r e t
D e p r e c a t i o n N o t i c e : G i t H u b w i l l d i s c o n t i n u e a u t h e n t i c a t i o n t o t h e A P I u s i n g q u e r y p a r a m e t e r s . A u t h e n t i c a t i n g t o t h e A P I s h o u l d b e d o n e w i t h H T T P b a s i c a u t h e n t i c a t i o n . U s i n g q u e r y p a r a m e t e r s t o a u t h e n t i c a t e t o t h e A P I w i l l n o l o n g e r w o r k o n M a y 5 , 2 0 2 1 . F o r m o r e i n f o r m a t i o n , i n c l u d i n g s c h e d u l e d b r o w n o u t s , s e e t h e b l o g p o s t .
curl -u my_client_id:my_client_secret 'https://api.github.com/user/repos'
U s i n g y o u r c l i e n t _ i d a n d c l i e n t _ s e c r e t d o e s n o t a u t h e n t i c a t e a s a u s e r , i t w i l l o n l y i d e n t i f y y o u r O A u t h a p p l i c a t i o n t o i n c r e a s e y o u r r a t e l i m i t . P e r m i s s i o n s a r e o n l y g r a n t e d t o u s e r s , n o t a p p l i c a t i o n s , a n d y o u w i l l o n l y g e t b a c k d a t a t h a t a n u n a u t h e n t i c a t e d u s e r w o u l d s e e . F o r t h i s r e a s o n , y o u s h o u l d o n l y u s e t h e O A u t h 2 k e y / s e c r e t i n s e r v e r - t o - s e r v e r s c e n a r i o s . D o n ' t l e a k y o u r O A u t h a p p l i c a t i o n ' s c l i e n t s e c r e t t o y o u r u s e r s .
R e a d m o r e a b o u t u n a u t h e n t i c a t e d r a t e l i m i t i n g .
F a i l e d l o g i n l i m i t
A u t h e n t i c a t i n g w i t h i n v a l i d c r e d e n t i a l s w i l l r e t u r n 4 0 1 U n a u t h o r i z e d :
curl -i https://api.github.com -u foo:bar
HTTP/1.1 401 Unauthorized
{
"message": "Bad credentials",
"documentation_url": "https://developer.github.com/v3"
}
A f t e r d e t e c t i n g s e v e r a l r e q u e s t s w i t h i n v a l i d c r e d e n t i a l s w i t h i n a s h o r t p e r i o d ,
t h e A P I w i l l t e m p o r a r i l y r e j e c t a l l a u t h e n t i c a t i o n a t t e m p t s f o r t h a t u s e r
( i n c l u d i n g o n e s w i t h v a l i d c r e d e n t i a l s ) w i t h 4 0 3 F o r b i d d e n :
curl -i https://api.github.com -u valid_username:valid_password
HTTP/1.1 403 Forbidden
{
"message": "Maximum number of login attempts exceeded. Please try again later.",
"documentation_url": "https://developer.github.com/v3"
}
P a r a m e t e r s
M a n y A P I m e t h o d s t a k e o p t i o n a l p a r a m e t e r s . F o r G E T r e q u e s t s , a n y p a r a m e t e r s n o t
s p e c i f i e d a s a s e g m e n t i n t h e p a t h c a n b e p a s s e d a s a n H T T P q u e r y s t r i n g
p a r a m e t e r :
curl -i "https://api.github.com/repos/vmg/redcarpet/issues?state=closed"
I n t h i s e x a m p l e , t h e ' v m g ' a n d ' r e d c a r p e t ' v a l u e s a r e p r o v i d e d f o r t h e : o w n e r
a n d : r e p o p a r a m e t e r s i n t h e p a t h w h i l e : s t a t e i s p a s s e d i n t h e q u e r y
s t r i n g .
F o r P O S T , P A T C H , P U T , a n d D E L E T E r e q u e s t s , p a r a m e t e r s n o t i n c l u d e d i n t h e U R L s h o u l d b e e n c o d e d a s J S O N
w i t h a C o n t e n t - T y p e o f ' a p p l i c a t i o n / j s o n ' :
curl -i -u username -d '{"scopes":["public_repo"]}' https://api.github.com/authorizations
R o o t e n d p o i n t
Y o u c a n i s s u e a G E T r e q u e s t t o t h e r o o t e n d p o i n t t o g e t a l l t h e e n d p o i n t c a t e g o r i e s t h a t t h e R E S T A P I v 3 s u p p o r t s :
curl https://api.github.com
G r a p h Q L g l o b a l n o d e I D s
S e e t h e g u i d e o n " U s i n g G l o b a l N o d e I D s " f o r d e t a i l e d i n f o r m a t i o n a b o u t h o w t o f i n d n o d e _ i d s v i a t h e R E S T A P I v 3 a n d u s e t h e m i n G r a p h Q L o p e r a t i o n s .
C l i e n t e r r o r s
T h e r e a r e t h r e e p o s s i b l e t y p e s o f c l i e n t e r r o r s o n A P I c a l l s t h a t
r e c e i v e r e q u e s t b o d i e s :
S e n d i n g i n v a l i d J S O N w i l l r e s u l t i n a 4 0 0 B a d R e q u e s t r e s p o n s e .
HTTP/1.1 400 Bad Request
Content-Length: 35
{"message":"Problems parsing JSON"}
S e n d i n g t h e w r o n g t y p e o f J S O N v a l u e s w i l l r e s u l t i n a 4 0 0 B a d
R e q u e s t r e s p o n s e .
HTTP/1.1 400 Bad Request
Content-Length: 40
{"message":"Body should be a JSON object"}
S e n d i n g i n v a l i d f i e l d s w i l l r e s u l t i n a 4 2 2 U n p r o c e s s a b l e E n t i t y
r e s p o n s e .
HTTP/1.1 422 Unprocessable Entity
Content-Length: 149
{
"message": "Validation Failed",
"errors": [
{
"resource": "Issue",
"field": "title",
"code": "missing_field"
}
]
}
A l l e r r o r o b j e c t s h a v e r e s o u r c e a n d f i e l d p r o p e r t i e s s o t h a t y o u r c l i e n t
c a n t e l l w h a t t h e p r o b l e m i s . T h e r e ' s a l s o a n e r r o r c o d e t o l e t y o u
k n o w w h a t i s w r o n g w i t h t h e f i e l d . T h e s e a r e t h e p o s s i b l e v a l i d a t i o n e r r o r
c o d e s :
Error code name
Description
missing
A resource does not exist.
missing_field
A required field on a resource has not been set.
invalid
The formatting of a field is invalid. Review the documentation for the for more specific information.
already_exists
Another resource has the same value as this field. This can happen in resources that must have some unique key (such as label names).
unprocessable
The inputs provided were invalid.
R e s o u r c e s m a y a l s o s e n d c u s t o m v a l i d a t i o n e r r o r s ( w h e r e c o d e is c u s t o m ) . C u s t o m e r r o r s w i l l a l w a y s h a v e a m e s s a g e f i e l d d e s c r i b i n g t h e e r r o r , a n d m o s t e r r o r s w i l l a l s o i n c l u d e a d o c u m e n t a t i o n _ u r l f i e l d p o i n t i n g t o s o m e c o n t e n t t h a t m i g h t h e l p y o u r e s o l v e t h e e r r o r .
H T T P r e d i r e c t s
A P I v 3 u s e s H T T P r e d i r e c t i o n w h e r e a p p r o p r i a t e . C l i e n t s s h o u l d a s s u m e t h a t a n y
r e q u e s t m a y r e s u l t i n a r e d i r e c t i o n . R e c e i v i n g a n H T T P r e d i r e c t i o n i s n o t a n
e r r o r a n d c l i e n t s s h o u l d f o l l o w t h a t r e d i r e c t . R e d i r e c t r e s p o n s e s w i l l h a v e a
L o c a t i o n h e a d e r f i e l d w h i c h c o n t a i n s t h e U R I o f t h e r e s o u r c e t o w h i c h t h e
c l i e n t s h o u l d r e p e a t t h e r e q u e s t s .
Status Code
Description
301
Permanent redirection. The URI you used to make the request has been superseded by the one specified in the Location header field. This and all future requests to this resource should be directed to the new URI.
302, 307
Temporary redirection. The request should be repeated verbatim to the URI specified in the Location header field but clients should continue to use the original URI for future requests.
O t h e r r e d i r e c t i o n s t a t u s c o d e s m a y b e u s e d i n a c c o r d a n c e w i t h t h e H T T P 1 . 1 s p e c .
H T T P v e r b s
W h e r e p o s s i b l e , A P I v 3 s t r i v e s t o u s e a p p r o p r i a t e H T T P v e r b s f o r e a c h
a c t i o n .
Verb
Description
HEAD
Can be issued against any resource to get just the HTTP header info.
GET
Used for retrieving resources.
POST
Used for creating resources.
PATCH
Used for updating resources with partial JSON data. For instance, an Issue resource has title and body attributes. A PATCH request may accept one or more of the attributes to update the resource. PATCH is a relatively new and uncommon HTTP verb, so resource endpoints also accept POST requests.
PUT
Used for replacing resources or collections. For PUT requests with no body attribute, be sure to set the Content-Length header to zero.
DELETE
Used for deleting resources.
H y p e r m e d i a
A l l r e s o u r c e s m a y h a v e o n e o r m o r e * _ u r l p r o p e r t i e s l i n k i n g t o o t h e r
r e s o u r c e s . T h e s e a r e m e a n t t o p r o v i d e e x p l i c i t U R L s s o t h a t p r o p e r A P I c l i e n t s
d o n ' t n e e d t o c o n s t r u c t U R L s o n t h e i r o w n . I t i s h i g h l y r e c o m m e n d e d t h a t A P I
c l i e n t s u s e t h e s e . D o i n g s o w i l l m a k e f u t u r e u p g r a d e s o f t h e A P I e a s i e r f o r
d e v e l o p e r s . A l l U R L s a r e e x p e c t e d t o b e p r o p e r R F C 6 5 7 0 U R I t e m p l a t e s .
Y o u c a n t h e n e x p a n d t h e s e t e m p l a t e s u s i n g s o m e t h i n g l i k e t h e u r i _ t e m p l a t e
g e m :
>> tmpl = URITemplate.new('/notifications{?since,all,participating}')
>> tmpl.expand
=> "/notifications"
>> tmpl.expand :all => 1
=> "/notifications?all=1"
>> tmpl.expand :all => 1, :participating => 1
=> "/notifications?all=1&participating=1"
P a g i n a t i o n
R e q u e s t s t h a t r e t u r n m u l t i p l e i t e m s w i l l b e p a g i n a t e d t o 3 0 i t e m s b y
d e f a u l t . Y o u c a n s p e c i f y f u r t h e r p a g e s w i t h t h e ? p a g e p a r a m e t e r . F o r s o m e
r e s o u r c e s , y o u c a n a l s o s e t a c u s t o m p a g e s i z e u p t o 1 0 0 w i t h t h e ? p e r _ p a g e p a r a m e t e r .
N o t e t h a t f o r t e c h n i c a l r e a s o n s n o t a l l e n d p o i n t s r e s p e c t t h e ? p e r _ p a g e p a r a m e t e r ,
s e e e v e n t s f o r e x a m p l e .
curl 'https://api.github.com/user/repos?page=2&per_page=100'
N o t e t h a t p a g e n u m b e r i n g i s 1 - b a s e d a n d t h a t o m i t t i n g t h e ? p a g e
p a r a m e t e r w i l l r e t u r n t h e f i r s t p a g e .
F o r m o r e i n f o r m a t i o n o n p a g i n a t i o n , c h e c k o u t o u r g u i d e o n T r a v e r s i n g w i t h P a g i n a t i o n .
L i n k h e a d e r
N o t e : I t ' s i m p o r t a n t t o f o r m c a l l s w i t h L i n k h e a d e r v a l u e s i n s t e a d o f c o n s t r u c t i n g y o u r o w n U R L s .
T h e L i n k h e a d e r i n c l u d e s p a g i n a t i o n i n f o r m a t i o n :
Link: <https://api.github.com/user/repos?page=3&per_page=100>; rel="next",
<https://api.github.com/user/repos?page=50&per_page=100>; rel="last"
T h e e x a m p l e i n c l u d e s a l i n e b r e a k f o r r e a d a b i l i t y .
T h i s L i n k r e s p o n s e h e a d e r c o n t a i n s o n e o r m o r e H y p e r m e d i a l i n k r e l a t i o n s , s o m e o f w h i c h m a y r e q u i r e e x p a n s i o n a s U R I t e m p l a t e s .
T h e p o s s i b l e r e l v a l u e s a r e :
Name
Description
next
The link relation for the immediate next page of results.
last
The link relation for the last page of results.
first
The link relation for the first page of results.
prev
The link relation for the immediate previous page of results.
R a t e l i m i t i n g
F o r A P I r e q u e s t s u s i n g B a s i c A u t h e n t i c a t i o n o r O A u t h , y o u c a n m a k e u p t o 5 0 0 0 r e q u e s t s
p e r h o u r . A u t h e n t i c a t e d r e q u e s t s a r e a s s o c i a t e d w i t h t h e a u t h e n t i c a t e d u s e r , r e g a r d l e s s o f
w h e t h e r B a s i c A u t h e n t i c a t i o n or a n O A u t h t o k e n
w a s u s e d . T h i s m e a n s t h a t a l l O A u t h a p p l i c a t i o n s a u t h o r i z e d b y a u s e r s h a r e t h e s a m e q u o t a
o f 5 0 0 0 r e q u e s t s p e r h o u r w h e n t h e y a u t h e n t i c a t e w i t h d i f f e r e n t t o k e n s o w n e d b y t h e s a m e u s e r .
F o r u n a u t h e n t i c a t e d r e q u e s t s , t h e r a t e l i m i t a l l o w s f o r u p t o 6 0 r e q u e s t s p e r h o u r .
U n a u t h e n t i c a t e d r e q u e s t s a r e a s s o c i a t e d w i t h t h e o r i g i n a t i n g I P a d d r e s s , a n d n o t t h e u s e r m a k i n g r e q u e s t s .
N o t e t h a t t h e S e a r c h A P I h a s c u s t o m r a t e l i m i t r u l e s .
T h e r e t u r n e d H T T P h e a d e r s o f a n y A P I r e q u e s t s h o w y o u r c u r r e n t r a t e l i m i t s t a t u s :
curl -i https://api.github.com/users/octocat
HTTP/1.1 200 OK
Date: Mon, 01 Jul 2013 17:27:06 GMT
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 56
X-RateLimit-Reset: 1372700873
Header Name
Description
X-RateLimit-Limit
The maximum number of requests you're permitted to make per hour.
X-RateLimit-Remaining
The number of requests remaining in the current rate limit window.
X-RateLimit-Reset
The time at which the current rate limit window resets in UTC epoch seconds .
I f y o u n e e d t h e t i m e i n a d i f f e r e n t f o r m a t , a n y m o d e r n p r o g r a m m i n g l a n g u a g e c a n g e t t h e j o b d o n e . F o r e x a m p l e , i f y o u o p e n u p t h e c o n s o l e o n y o u r w e b b r o w s e r , y o u c a n e a s i l y g e t t h e r e s e t t i m e a s a J a v a S c r i p t D a t e o b j e c t .
new Date ( 1372700873 * 1000 )
// => Mon Jul 01 2013 13:47:53 GMT-0400 (EDT)
I f y o u e x c e e d t h e r a t e l i m i t , a n e r r o r r e s p o n s e r e t u r n s :
HTTP/1.1 403 Forbidden
Date: Tue, 20 Aug 2013 14:50:41 GMT
Status: 403 Forbidden
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1377013266
{
"message": "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
"documentation_url": "https://developer.github.com/v3/#rate-limiting"
}
Y o u c a n c h e c k y o u r r a t e l i m i t s t a t u s w i t h o u t i n c u r r i n g a n A P I h i t .
I n c r e a s i n g t h e u n a u t h e n t i c a t e d r a t e l i m i t f o r O A u t h a p p l i c a t i o n s
I f y o u r O A u t h a p p l i c a t i o n n e e d s t o m a k e u n a u t h e n t i c a t e d c a l l s w i t h a h i g h e r r a t e l i m i t , y o u c a n p a s s y o u r a p p ' s c l i e n t I D a n d s e c r e t b e f o r e t h e e n d p o i n t r o u t e .
curl -u my_client_id:my_client_secret https://api.github.com/user/repos
HTTP/1.1 200 OK
Date: Mon, 01 Jul 2013 17:27:06 GMT
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4966
X-RateLimit-Reset: 1372700873
N o t e : N e v e r s h a r e y o u r c l i e n t s e c r e t w i t h a n y o n e o r i n c l u d e i t i n c l i e n t - s i d e b r o w s e r c o d e . U s e t h e m e t h o d s h o w n h e r e o n l y f o r s e r v e r - t o - s e r v e r c a l l s .
S t a y i n g w i t h i n t h e r a t e l i m i t
I f y o u e x c e e d y o u r r a t e l i m i t u s i n g B a s i c A u t h e n t i c a t i o n o r O A u t h , y o u c a n l i k e l y f i x t h e i s s u e b y c a c h i n g A P I r e s p o n s e s a n d u s i n g c o n d i t i o n a l r e q u e s t s .
A b u s e r a t e l i m i t s
I n o r d e r t o p r o v i d e q u a l i t y s e r v i c e o n G i t H u b , a d d i t i o n a l r a t e l i m i t s m a y a p p l y t o s o m e a c t i o n s w h e n u s i n g t h e A P I . F o r e x a m p l e , u s i n g t h e A P I t o r a p i d l y c r e a t e c o n t e n t , p o l l a g g r e s s i v e l y i n s t e a d o f u s i n g w e b h o o k s , m a k e m u l t i p l e c o n c u r r e n t r e q u e s t s , o r r e p e a t e d l y r e q u e s t d a t a t h a t i s c o m p u t a t i o n a l l y e x p e n s i v e m a y r e s u l t i n a b u s e r a t e l i m i t i n g .
A b u s e r a t e l i m i t s a r e n o t i n t e n d e d t o i n t e r f e r e w i t h l e g i t i m a t e u s e o f t h e A P I . Y o u r n o r m a l r a t e l i m i t s s h o u l d b e t h e o n l y l i m i t y o u t a r g e t . T o e n s u r e y o u ' r e a c t i n g a s a g o o d A P I c i t i z e n , c h e c k o u t o u r B e s t P r a c t i c e s g u i d e l i n e s .
I f y o u r a p p l i c a t i o n t r i g g e r s t h i s r a t e l i m i t , y o u ' l l r e c e i v e a n i n f o r m a t i v e r e s p o n s e :
HTTP/1.1 403 Forbidden
Content-Type: application/json; charset=utf-8
Connection: close
{
"message": "You have triggered an abuse detection mechanism and have been temporarily blocked from content creation. Please retry your request again later.",
"documentation_url": "https://developer.github.com/v3/#abuse-rate-limits"
}
U s e r a g e n t r e q u i r e d
A l l A P I r e q u e s t s M U S T i n c l u d e a v a l i d U s e r - A g e n t h e a d e r . R e q u e s t s w i t h n o U s e r - A g e n t
h e a d e r w i l l b e r e j e c t e d . W e r e q u e s t t h a t y o u u s e y o u r G i t H u b u s e r n a m e , o r t h e n a m e o f y o u r
a p p l i c a t i o n , f o r t h e U s e r - A g e n t h e a d e r v a l u e . T h i s a l l o w s u s t o c o n t a c t y o u i f t h e r e a r e p r o b l e m s .
H e r e ' s a n e x a m p l e :
User-Agent: Awesome-Octocat-App
c U R L s e n d s a v a l i d U s e r - A g e n t h e a d e r b y d e f a u l t . I f y o u p r o v i d e a n i n v a l i d U s e r - A g e n t h e a d e r v i a c U R L ( o r v i a a n a l t e r n a t i v e c l i e n t ) , y o u w i l l r e c e i v e a 4 0 3 F o r b i d d e n r e s p o n s e :
curl -iH 'User-Agent: ' https://api.github.com/meta
HTTP/1.0 403 Forbidden
Connection: close
Content-Type: text/html
Request forbidden by administrative rules.
Please make sure your request has a User-Agent header.
Check https://developer.github.com for other possible causes.
C o n d i t i o n a l r e q u e s t s
M o s t r e s p o n s e s r e t u r n a n E T a g h e a d e r . M a n y r e s p o n s e s a l s o r e t u r n a L a s t - M o d i f i e d h e a d e r . Y o u c a n u s e t h e v a l u e s
o f t h e s e h e a d e r s t o m a k e s u b s e q u e n t r e q u e s t s t o t h o s e r e s o u r c e s u s i n g t h e
I f - N o n e - M a t c h a n d I f - M o d i f i e d - S i n c e h e a d e r s , r e s p e c t i v e l y . I f t h e r e s o u r c e
h a s n o t c h a n g e d , t h e s e r v e r w i l l r e t u r n a 3 0 4 N o t M o d i f i e d .
N o t e : M a k i n g a c o n d i t i o n a l r e q u e s t a n d r e c e i v i n g a 3 0 4 r e s p o n s e d o e s n o t
c o u n t a g a i n s t y o u r R a t e L i m i t , s o w e e n c o u r a g e y o u t o u s e i t
w h e n e v e r p o s s i b l e .
curl -i https://api.github.com/user
HTTP/1.1 200 OK
Cache-Control: private, max-age=60
ETag: "644b5b0155e6404a9cc4bd9d8b1ae730"
Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
Status: 200 OK
Vary: Accept, Authorization, Cookie
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996
X-RateLimit-Reset: 1372700873
curl -i https://api.github.com/user -H 'If-None-Match: "644b5b0155e6404a9cc4bd9d8b1ae730"'
HTTP/1.1 304 Not Modified
Cache-Control: private, max-age=60
ETag: "644b5b0155e6404a9cc4bd9d8b1ae730"
Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
Status: 304 Not Modified
Vary: Accept, Authorization, Cookie
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996
X-RateLimit-Reset: 1372700873
curl -i https://api.github.com/user -H "If-Modified-Since: Thu, 05 Jul 2012 15:31:30 GMT"
HTTP/1.1 304 Not Modified
Cache-Control: private, max-age=60
Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
Status: 304 Not Modified
Vary: Accept, Authorization, Cookie
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4996
X-RateLimit-Reset: 1372700873
C r o s s o r i g i n r e s o u r c e s h a r i n g
T h e A P I s u p p o r t s C r o s s O r i g i n R e s o u r c e S h a r i n g ( C O R S ) f o r A J A X r e q u e s t s f r o m
a n y o r i g i n .
Y o u c a n r e a d t h e C O R S W 3 C R e c o m m e n d a t i o n , o r
t h i s i n t r o f r o m t h e
H T M L 5 S e c u r i t y G u i d e .
H e r e ' s a s a m p l e r e q u e s t s e n t f r o m a b r o w s e r h i t t i n g
h t t p : / / e x a m p l e . c o m :
curl -i https://api.github.com -H "Origin: http://example.com"
HTTP/1.1 302 Found
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
T h i s i s w h a t t h e C O R S p r e f l i g h t r e q u e s t l o o k s l i k e :
curl -i https://api.github.com -H "Origin: http://example.com" -X OPTIONS
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-GitHub-OTP, X-Requested-With
Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Max-Age: 86400
J S O N - P c a l l b a c k s
Y o u c a n s e n d a ? c a l l b a c k p a r a m e t e r t o a n y G E T c a l l t o h a v e t h e r e s u l t s
w r a p p e d i n a J S O N f u n c t i o n . T h i s i s t y p i c a l l y u s e d w h e n b r o w s e r s w a n t
t o e m b e d G i t H u b c o n t e n t i n w e b p a g e s b y g e t t i n g a r o u n d c r o s s d o m a i n
i s s u e s . T h e r e s p o n s e i n c l u d e s t h e s a m e d a t a o u t p u t a s t h e r e g u l a r A P I ,
p l u s t h e r e l e v a n t H T T P H e a d e r i n f o r m a t i o n .
curl https://api.github.com?callback=foo
/**/foo({
"meta": {
"status": 200,
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4966",
"X-RateLimit-Reset": "1372700873",
"Link": [ // pagination headers and other links
["https://api.github.com?page=2", {"rel": "next"}]
]
},
"data": {
// the data
}
})
Y o u c a n w r i t e a J a v a S c r i p t h a n d l e r t o p r o c e s s t h e c a l l b a c k . H e r e ' s a m i n i m a l e x a m p l e y o u c a n t r y o u t :
<html>
<head>
<script type="text/javascript">
function foo(response) {
var meta = response.meta;
var data = response.data;
console.log(meta);
console.log(data);
}
var script = document.createElement('script');
script.src = 'https://api.github.com?callback=foo';
document.getElementsByTagName('head')[0].appendChild(script);
</script>
</head>
<body>
<p>Open up your browser's console.</p>
</body>
</html>
A l l o f t h e h e a d e r s a r e t h e s a m e S t r i n g v a l u e a s t h e H T T P H e a d e r s w i t h o n e
n o t a b l e e x c e p t i o n : L i n k . L i n k h e a d e r s a r e p r e - p a r s e d f o r y o u a n d c o m e
t h r o u g h a s a n a r r a y o f [ u r l , o p t i o n s ] t u p l e s .
A l i n k t h a t l o o k s l i k e t h i s :
Link: <url1>; rel="next", <url2>; rel="foo"; bar="baz"
. . . w i l l l o o k l i k e t h i s i n t h e C a l l b a c k o u t p u t :
{
"Link" : [
[
"url1" ,
{
"rel" : "next"
}
],
[
"url2" ,
{
"rel" : "foo" ,
"bar" : "baz"
}
]
]
}
T i m e z o n e s
S o m e r e q u e s t s t h a t c r e a t e n e w d a t a , s u c h a s c r e a t i n g a n e w c o m m i t , a l l o w y o u t o p r o v i d e t i m e z o n e i n f o r m a t i o n w h e n s p e c i f y i n g o r g e n e r a t i n g t i m e s t a m p s . W e a p p l y t h e f o l l o w i n g r u l e s , i n o r d e r o f p r i o r i t y , t o d e t e r m i n e t i m e z o n e i n f o r m a t i o n f o r A P I c a l l s .
● E x p l i c i t l y p r o v i d i n g a n I S O 8 6 0 1 t i m e s t a m p w i t h t i m e z o n e i n f o r m a t i o n
● U s i n g t h e T i m e - Z o n e h e a d e r
● U s i n g t h e l a s t k n o w n t i m e z o n e f o r t h e u s e r
● D e f a u l t i n g t o U T C w i t h o u t o t h e r t i m e z o n e i n f o r m a t i o n
E x p l i c i t l y p r o v i d i n g a n I S O 8 6 0 1 t i m e s t a m p w i t h t i m e z o n e i n f o r m a t i o n
F o r A P I c a l l s t h a t a l l o w f o r a t i m e s t a m p t o b e s p e c i f i e d , w e u s e t h a t e x a c t t i m e s t a m p . A n e x a m p l e o f t h i s i s t h e C o m m i t s A P I .
T h e s e t i m e s t a m p s l o o k s o m e t h i n g l i k e 2 0 1 4 - 0 2 - 2 7 T 1 5 : 0 5 : 0 6 + 0 1 : 0 0 . A l s o s e e t h i s e x a m p l e f o r h o w t h e s e t i m e s t a m p s c a n b e s p e c i f i e d .
U s i n g t h e T i m e - Z o n e h e a d e r
I t i s p o s s i b l e t o s u p p l y a T i m e - Z o n e h e a d e r w h i c h d e f i n e s a t i m e z o n e a c c o r d i n g t o t h e l i s t o f n a m e s f r o m t h e O l s o n d a t a b a s e .
curl -H "Time-Zone: Europe/Amsterdam" -X POST https://api.github.com/repos/github/linguist/contents/new_file.md
T h i s m e a n s t h a t w e g e n e r a t e a t i m e s t a m p f o r t h e m o m e n t y o u r A P I c a l l i s m a d e i n t h e t i m e z o n e t h i s h e a d e r d e f i n e s . F o r e x a m p l e , t h e C o n t e n t s A P I g e n e r a t e s a g i t c o m m i t f o r e a c h a d d i t i o n o r c h a n g e a n d u s e s t h e c u r r e n t t i m e a s t h e t i m e s t a m p . T h i s h e a d e r w i l l d e t e r m i n e t h e t i m e z o n e u s e d f o r g e n e r a t i n g t h a t c u r r e n t t i m e s t a m p .
U s i n g t h e l a s t k n o w n t i m e z o n e f o r t h e u s e r
I f n o T i m e - Z o n e h e a d e r i s s p e c i f i e d a n d y o u m a k e a n a u t h e n t i c a t e d c a l l t o t h e A P I , w e u s e t h e l a s t k n o w n t i m e z o n e f o r t h e a u t h e n t i c a t e d u s e r . T h e l a s t k n o w n t i m e z o n e i s u p d a t e d w h e n e v e r y o u b r o w s e t h e G i t H u b w e b s i t e .
D e f a u l t i n g t o U T C w i t h o u t o t h e r t i m e z o n e i n f o r m a t i o n
I f t h e s t e p s a b o v e d o n ' t r e s u l t i n a n y i n f o r m a t i o n , w e u s e U T C a s t h e t i m e z o n e t o c r e a t e t h e g i t c o m m i t .
Navigate the docs…
API Overview
Media Types
OAuth Authorizations API
Other Authentication Methods
Troubleshooting
API Previews
Versions
Activity overview
Events
Event Types and Payloads
Feeds
Notifications
Starring
Watching
Checks
Check Runs
Check Suites
Code Scanning
Gists overview
Comments
Git Data overview
Blobs
Commits
References
Tags
Trees
GitHub Actions Overview
Artifacts
Secrets
Self-hosted runners
Workflows
Workflow jobs
Workflow runs
GitHub Apps overview
OAuth Applications API
Installations
Permissions
Available Endpoints
GitHub Marketplace
Interactions
Organization
Repository
Issues overview
Assignees
Comments
Events
Labels
Milestones
Timeline
Issue Event Types
Migrations overview
Organization
Source Imports
User
Miscellaneous overview
Codes of Conduct
Emojis
Gitignore
Licenses
Markdown
Meta
Rate Limit
Organizations overview
Blocking Users (Organizations)
Members
Outside Collaborators
Webhooks
Projects overview
Cards
Collaborators
Columns
Pull Requests overview
Reviews
Review Comments
Review Requests
Reactions overview
Commit Comment
Issue
Issue Comment
Pull Request Review Comment
Team Discussion
Team Discussion Comment
Repositories overview
Branches
Collaborators
Comments
Commits
Community
Contents
Deploy Keys
Deployments
Forks
Invitations
Merging
Pages
Releases
Statistics
Statuses
Traffic
Webhooks
Search overview
Repositories
Code
Commits
Issues
Users
Topics
Text match metadata
Teams
Discussions
Discussion comments
Members
Team sunchronization
SCIM
Users overview
Blocking Users
Emails
Followers
Git SSH Keys
GPG Keys
● M e d i a T y p e s
● O A u t h A u t h o r i z a t i o n s A P I
● O t h e r A u t h e n t i c a t i o n M e t h o d s
● T r o u b l e s h o o t i n g
● A P I P r e v i e w s
● V e r s i o n s
● E v e n t s
● E v e n t T y p e s a n d P a y l o a d s
● F e e d s
● N o t i f i c a t i o n s
● S t a r r i n g
● W a t c h i n g
● C h e c k R u n s
● C h e c k S u i t e s
● C o m m e n t s
● B l o b s
● C o m m i t s
● R e f e r e n c e s
● T a g s
● T r e e s
● A r t i f a c t s
● S e c r e t s
● S e l f - h o s t e d r u n n e r s
● W o r k f l o w s
● W o r k f l o w j o b s
● W o r k f l o w r u n s
● O A u t h A p p l i c a t i o n s A P I
● I n s t a l l a t i o n s
● P e r m i s s i o n s
● A v a i l a b l e E n d p o i n t s
● O r g a n i z a t i o n
● R e p o s i t o r y
● A s s i g n e e s
● C o m m e n t s
● E v e n t s
● L a b e l s
● M i l e s t o n e s
● T i m e l i n e
● I s s u e E v e n t T y p e s
● O r g a n i z a t i o n
● S o u r c e I m p o r t s
● U s e r
● C o d e s o f C o n d u c t
● E m o j i s
● G i t i g n o r e
● L i c e n s e s
● M a r k d o w n
● M e t a
● R a t e L i m i t
● B l o c k i n g U s e r s
● M e m b e r s
● O u t s i d e C o l l a b o r a t o r s
● W e b h o o k s
● C a r d s
● C o l l a b o r a t o r s
● C o l u m n s
● R e v i e w s
● R e v i e w C o m m e n t s
● R e v i e w R e q u e s t s
● C o m m i t C o m m e n t
● I s s u e
● I s s u e C o m m e n t
● P u l l R e q u e s t R e v i e w C o m m e n t
● T e a m D i s c u s s i o n
● T e a m D i s c u s s i o n C o m m e n t
● B r a n c h e s
● C o l l a b o r a t o r s
● C o m m e n t s
● C o m m i t s
● C o m m u n i t y
● C o n t e n t s
● D e p l o y K e y s
● D e p l o y m e n t s
● F o r k s
● I n v i t a t i o n s
● M e r g i n g
● P a g e s
● R e l e a s e s
● S t a t i s t i c s
● S t a t u s e s
● T r a f f i c
● W e b h o o k s
● R e p o s i t o r i e s
● C o d e
● C o m m i t s
● I s s u e s
● U s e r s
● T o p i c s
● T e x t m a t c h m e t a d a t a
● D i s c u s s i o n s
● D i s c u s s i o n c o m m e n t s
● M e m b e r s
● T e a m s y n c h r o n i z a t i o n
● B l o c k i n g U s e r s
● E m a i l s
● F o l l o w e r s
● G i t S S H K e y s
● G P G K e y s
A P I S t a t u s