eu90h
While this document contains usage examples, the functional tests found in the functional_tests directory of the github repository provide a good source of usage examples and patterns.
Before you begin making requests to the GitHub api, you must create an identity.
type must be one of the following symbols: 'password'personal-token'oauth
'password authentication simply uses your GitHub username and password.
'personal-token authentication allows you to send your GitHub username and a personal access token (created on your GitHub settings page.)
'oauth uses an OAuth token for authorization.
For more information, see the github api documentation
The data field is a list whose contents are determined by user authentication method.
For 'password or 'personal-token types, your data will be of the form (list usernamepassword-or-token), where both username & password-or-token are strings.
procedure
[ #:endpointendpoint
The optional #:endpoint keyword sets the root endpoint for making api requests. If you have a GitHub enterprise account, you may wish to change the endpoint. See this for more information on root-endpoints.
If you change the user-agent string, be aware that GitHub has certain rules explicated here
struct
#:extra-constructor-namemake-github-response)code:number?data:jsexpr?
syntax
[#:methodstring?#:datastring?#:media-typestring?]github-response?))
Typically, one would not use this procedure directly but rather pass it along to another function.
The #:method keyword specifies what HTTP verb to use (I.e. "GET", "POST", "PATCH", etc.)
The #:data keyword specifies any information to send along with the request. This is almost always a JSON string.
Finally, #:media-type specifies the format in which you wish to receive data. Practically every github-* procedure has an optional keyword #:media-type that allows you to specify a media-type for a request.
For more information on media types see the GitHub api documentation.
According to the GitHub documentation, personal access tokens are equivalent to your password. Never give it out (and don’t accidently commit your identity!)
Read more about your options for authentication here
(github"/users/plt/repos")
When making requests to the GitHub API, it is common to receive data encoded in the JSON format. This quick section introduces Racket’s JSON handling facilities.
Racket provides a library for working with JSON data, aptly called json.
This is used by the Racket github-api library to encode data before returning it.
{"name":"billy bob"}
(hash-ref jsexpr'name)
To learn more about working with hashes see the Racket guide and the Racket reference on hash-tables.
The Gist API will return up to 1 megabyte of content from a requested gist.
To see if a file was truncated, check whether or not the key truncated is "true".
To get the full contents of the file, make a request to the url referenced by the key raw_url.
For more information on truncation see the GitHub documentation
procedure
files[ #:descriptiondescription#:publicpublic#:media-typemedia-type]) → api-resonse/capi-req:github-api-req/c
The optional keyword description provides a description of the gist. By default it is empty.
procedure
gist-idfiles[ #:descriptiondescription#:media-typemedia-type]) → api-resonse/capi-req:github-api-req/cgist-id:string?
procedure
gist-idapi-req:github-api-req/cgist-id:string?
procedure
gist-id[ #:media-typemedia-type])api-req:github-api-req/cgist-id:string?
procedure
gist-idapi-req:github-api-req/cgist-id:string?
procedure
gist-idapi-req:github-api-req/cgist-id:string?
procedure
gist-idapi-req:github-api-req/cgist-id:string?
procedure
gist-idapi-req:github-api-req/cgist-id:string?
procedure
gist-id[ #:media-typemedia-type])api-req:github-api-req/cgist-id:string?
procedure
gist-idapi-req:github-api-req/cgist-id:string?
procedure
gist-idsha[ #:media-typemedia-type])api-req:github-api-req/cgist-id:string?sha:string?
procedure
user[ #:media-typemedia-type])api-req:github-api-req/cuser:string?
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
For more information on the Events API, see the GitHub documentation
procedure
repo-ownerrepoapi-req:github-api-req/crepo-owner:string?repo:string?
procedure
repo-ownerrepo[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo:string?
procedure
org[ #:media-typemedia-type])api-req:github-api-req/corg:string?
procedure
user[ #:media-typemedia-type])api-req:github-api-req/cuser:string?
api-req:github-api-req/cuser:string?
procedure
user[ #:media-typemedia-type])api-req:github-api-req/cuser:string?
procedure
user[ #:media-typemedia-type])api-req:github-api-req/cuser:string?
For more information about feeds, go here
procedure
api-req:github-api-req/c
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
For more information about the Issues API, click here
Furthermore, the Issues API uses custom media types. See this section
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
procedure
organization[ #:media-typemedia-type])api-req:github-api-req/corganization:string?
procedure
repo-ownerrepo-nameapi-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-nametitle[ #:bodybody#:assigneeassignee#:milestonemilestone#:labelslabel#:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?title:string?
procedure
repo-ownerrepo-name[ #:titletitle#:bodybody#:assigneeassignee#:milestonemilestone#:labelslabelapi-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-nameissue-numberapi-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-nameissue-number[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-name[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-namecomment-idapi-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-nameissue-numbercomment-body[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?comment-body:string?
procedure
repo-ownerrepo-namecomment-idcomment-body[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?comment-body:string?
procedure
repo-ownerrepo-namecomment-id[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?
"eu90h""racket-github-api""testing-issues-api"#:body"this is a test of the issues api"#:assignee"eu90h"
procedure
repo-ownerrepo-name[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?
procedure
repo-ownerrepo-nameuser[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?user:string?
Click here for more information on the Git Data API.
procedure
repo-ownerrepo-nameshaapi-req:github-api-req/crepo-owner:string?repo-name:string?sha:string?
procedure
repo-ownerrepo-namecontent[ encodingapi-req:github-api-req/crepo-owner:string?repo-name:string?content:string?
procedure
repo-ownerrepo-nameshaapi-req:github-api-req/crepo-owner:string?repo-name:string?sha:string?
procedure
repo-ownerrepo-namemessagetreeparents[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo-name:string?message:string?tree:string?
For more on Organizations, go "https://developer.github.com/v3/orgs/""here"
procedure
api-req:github-api-req/c
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
procedure
user[ #:media-typemedia-type])api-req:github-api-req/cuser:string?
procedure
orgapi-req:github-api-req/corg:string?
procedure
org[ #:media-typemedia-type])api-req:github-api-req/corg:string?
procedure
repo-ownerrepo[ #:media-typemedia-type])api-req:github-api-req/crepo-owner:string?repo:string?
procedure
userapi-req:github-api-req/cuser:string?
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
procedure
[ #:media-typemedia-type])api-req:github-api-req/c
Webhooks are a sort-of user defined callback in the form of a listening webserver that github sends a message to whenever a certain type of event occurs.
A service hook is a webhook whose type is anything except "web"
To read more, see the GitHub documentation
procedure
url[ #:content-typecontent-type#:secretsecret#:insecure-sslinsecure-ssl])api-req:github-api-req/curl:string?
procedure
repo-ownerrepotypeconfig[ #:eventseventsapi-req:github-api-req/crepo-owner:string?repo:string?type:string?config:jsexpr?
Passing any other string results in an error response from the GitHub API.
procedure
repo-ownerrepoapi-req:github-api-req/crepo-owner:string?repo:string?
procedure
repo-ownerrepohook-idapi-req:github-api-req/crepo-owner:string?repo:string?
procedure
repo-ownerrepoapi-req:github-api-req/crepo-owner:string?repo:string?
procedure
repo-ownerrepoapi-req:github-api-req/crepo-owner:string?repo:string?
procedure
repo-ownerrepoapi-req:github-api-req/crepo-owner:string?repo:string?
#:insecure-ssl"0"#:content-type"json"))