Custom media types are used in the API to let consumers choose the format
of the data they wish to receive. This is done by adding one or more of
the following types to the
Accept header when you make a request. Media types
are specific to resources, allowing them to change independently and support
formats that other resources don't.
All GitHub media types look like this:
The most basic media types the API supports are:
Note: In the past, we recommended including
v3 in your
Accept header. This is no longer required and will have no impact on your API requests.
If you're specifying a property (such as full/raw/etc defined below),
put it after
Comment body properties
The body of a comment can be written in GitHub Flavored Markdown. The APIs to manage issues, issue comments, pull request comments, and gist comments all accept these same media types:
Raw media type for comment body properties
Return the raw markdown body. Response will include
body. This is the
default if you do not pass any specific media type.
Text media type for comment body properties
Return a text only representation of the markdown body. Response will
HTML media type for comment body properties
Return HTML rendered from the body's markdown. Response will include
Full media type for comment body properties
Return raw, text and HTML representations. Response will include
Git blob properties
The following media types are allowed when getting a blob:
JSON media type for Git blob properties
Return JSON representation of the blob with
content as a base64
encoded string. This is the default if nothing is passed.
Raw media type for Git blob properties
Return the raw blob data.
Commits, commit comparison, and pull requests
The REST API to manage commits and pull requests support diff and patch formats:
diff media type for commits, commit comparison, and pull requests
patch media type for commits, commit comparison, and pull requests
sha media type for commits, commit comparison, and pull requests
Raw media type for repository contents
Return the raw contents of a file. This is the default if you do not pass any specific media type.
HTML media type for repository contents
For markup files such as Markdown or AsciiDoc, you can retrieve the rendered HTML using the
.html media type. Markup languages are rendered to HTML using our open-source Markup library.
Raw media type for gists
Return the raw contents of a gist. This is the default if you do not pass any specific media type.
base64 media type for gists
The gist contents are base64-encoded before being sent out. This can be useful if your gist contains any invalid UTF-8 sequences.