In order to make API calls, you must first register your application (after logging in with your deviantART account)
After you've registered, you'll gain access to a pair of client_id and client_secret codes on the My Applications page.
These codes will enable you to authenticate users through your app and make API calls on their behalf.
Since available libraries support different drafts of the OAuth 2.0 specification, we've decided to support both draft 10 and draft 15 which are the most commonly used versions in current open-source OAuth 2.0 libraries.
The URL for each API call differs depending on which version of OAuth 2.0 you've authenticated the user with. Since the drafts are not interchangeable, a user authenticated through draft 10 can only call draft 10 endpoints, and likewise with draft 15.
For example, the /placebo API call uses these two endpoints:
https://www.deviantart.com/api/draft10/placebo
https://www.deviantart.com/api/draft15/placebo
You should call the first endpoint if you're using a draft 10 library, and the second endpoint if you're using a draft 15 library.
Beware of libraries that are only compatible with OAuth (not 2.0).
The OAuth 2.0 standard is not backwards compatible and we don't support the old version of the standard.
Before making API calls for a user, you must ask that user to authorize your application. First you should redirect the user to one of deviantART's authorization URLs along with the required query-string parameters below.
The correct URL to use depends on which Oauth 2.0 draft you've chosen:
https://www.deviantart.com/oauth2/draft10/authorize
https://www.deviantart.com/oauth2/draft15/authorize
Required Parameters
These parameters must be sent as query-string GET fields.
A successful response means that the user will be redirected to your whitelisted URI along with the following GET parameter:
An unsuccessful response means that the user chose not to authorize your application.
Note that the redirect_uri you provide must match one of the URIs in your registered application's whitelist. If you'd like to update this whitelist, click the corresponding [Edit] link for your application on the My Applications page. You'll find the whitelist options in the Publishing Options dropdown.
Once the user has authorized your application, they will be redirected to the redirect_uri you've provided along with an extra code parameter. Use this code to make your first API call - a token request:
https://www.deviantart.com/oauth2/draft10/token
https://www.deviantart.com/oauth2/draft15/token
Required Parameters
These parameters may be sent via GET or POST
A successful token call will return a JSON-encoded token that you can then use to make API calls.
{
"expires_in": 3600,
"status": "success",
"access_token": "Alph4num3r1ct0k3nv4lu3",
"refresh_token": "0123456789"
}
An unsuccessful response will return an HTTP 400 - Bad Request or an HTTP 401 - Unauthorized, optionally with one of the following JSON responses:
{
"status": "error",
"error": "access_denied",
"error_description": "Access to this oAuth2 resource is denied, invalid client_secret."
}
{
"status": "error",
"error": "unsupported_grant_type",
"error_description": "Only authorization_code and refresh_token are supported for access grant."
}
{
"status": "error",
"error": "invalid_code",
"error_description": "Access code must be numeric"
}
{
"status": "error",
"error": "invalid_grant",
"error_description": "Invalid access code."
}
{
"status": "error",
"error": "invalid_request",
"error_description": "refresh_token must be specified"
}
{
"status": "error",
"error": "invalid_grant",
"error_description": "Invalid refresh token."
}
The first and most basic authenticated API call. It checks that a given access_token is still valid. The endpoints are:
https://www.deviantart.com/api/draft10/placebo
https://www.deviantart.com/api/draft15/placebo
Required Parameters
Successful Response
If the token is valid, it will return the following JSON:
{
status: "success"
}
If the token has expired, it will return the following JSON:
{
"status": "error",
"error": "expired_token"
}
This call is most useful for checking that an access_token is still valid before making another API call that might take a long time (like a file upload). This way, if a token has expired, your users won't have to wait until the upload (or any other long-running API call) returns an error before your app notices and makes a /token call to refresh the expired token.
Add Media
Style