One of the most frequent activities in social applications is link sharing. Wouldn't it be nice if your application could display an image thumbnail or some info from the linked resource? Normally developers would use clunky proprietary APIs, if those are available at all, or resort to screen scraping the pages to extract bits and pieces of information. Plus they'd have to do it differently for each service. Needless to say it's a hassle.
oEmbed solves this common problem nicely.
oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly.
Many large services such as YouTube, Flickr, Hulu, Vimeo, Viddler, Qik, MyOpera, and now DeviantArt support this API. Our implementation of the oEmbed API makes it simple for application developers to embed media from DeviantArt just by having a link to a deviation page.
For example, a request like this:
https://backend.deviantart.com/oembed?url=https%3A%2F%2Fwww.deviantart.com%2Fteam%2Fart%2FFella-Celebrates-100k-971957229
Will return the JSON response.
All that an application developer needs to do is to parse the desired values from this response, be it thumbnail or preview url or author name, and output a custom <img> tag or text on their webpage.
By far the simplest way to use our oEmbed API is from client-side javascript using jQuery.
Your application should recognize that a given url leads to a deviation page at DeviantArt and then use this JSONP (JSON with padding) formatted oEmbed API call:
<script>
var oembed_url = 'https://backend.deviantart.com/oembed?url=https%3A%2F%2Fwww.deviantart.com%2Fteam%2Fart%2FFella-Celebrates-100k-971957229&format=jsonp&callback=?';
$.getJSON(oembed_url, function(data) {
console.log('Deviation by: ' + data.author_name);
});
</script>
Of course, you can also choose to use this API from the server side, parsing links and doing API calls when status updates are posted or possibly formatted for display. In that case, you would probably choose to use JSON or XML format.
The oEmbed API specification page lists a variety of libraries for most popular languages and frameworks that simplify an implementation. Needless to say, if you choose to embed media from DeviantArt by using this API, it's a very small step to provide the same integration with many other services that support it. Only the link format detection and url endpoints are specific to each service.
We comply to the official oEmbed specifications. Our endpoints are:
JSON: https://backend.deviantart.com/oembed
XML: https://backend.deviantart.com/oembed?format=xml
JSONP: https://backend.deviantart.com/oembed?format=jsonp&callback=yourCallback
The URL scheme for the url parameter is:
https://www.deviantart.com/username/art/*
https://sta.sh/*