oEmbed API

lasconic edited this page Nov 8, 2011 · 3 revisions
Clone this wiki locally

oEmbed is an open standard for embedding external content into a website. In the case of MuseScore.com, it will embed the score player for a given score. You can use any URL of any score to obtain the embed code for it. To find out more about oEmbed, view the spec or check out Webmonkey’s Get Started With oEmbed tutorial.

API Endpoints

You can use the API endpoint to request the embed code for a score from its URL. The response format can be either xml, json or js (for JSONP).

http://musescore.com/oembed/endpoint

MuseScore.com currently supports embedding of scores only. The accepted URL schemes are:

http://musescore.com/*
http://mus.cr/*

Discovery

No discovery yet

Arguments

All arguments are sent as query parameters and must be urlencoded (as per RFC 1738).

url The MuseScore.com URL for a score.
format (optional) Either json, xml or jsonp. Defaults to json.
maxwidth (optional) The maximum width for the player. Defaults to 100%
maxheight (optional) The maximum height for the player. Defaults to 394.
callback (optional) In case you request a jsonp response by setting format=jsonp, this callback function will be executed

Example Call

http://musescore.com/oembed/endpoint?url=http://musescore.com/nicolas/scores/439&format=xml

A simple example, using jQuery, is available. Check and fork the code.

Example Responses

As mentioned above, the default width for the player is 100%. The current oembed specification requires the returned data to specify the width in pixels, which is not practical. Therefore if you did not specify a maxwidth the returned width parameter will be 100%. If you require the width to be correctly set to an integer, please provide a maxwidth.

XML

Call:

http://musescore.com/oembed/endpoint?url=http://musescore.com/nicolas/scores/439&format=xml

Response:

<oembed>
  <type>rich</type>
  <version>1.0</version>
  <provider_name>MuseScore.com</provider_name>
  <width>100%</width>
  <height>394</height>
  <provider_url>http://musescore.com</provider_url>
  <html>
  <iframe width="100%" height="394" src="http://musescore.com/node/439/embed" frameborder="0"></iframe><span><a    href="http://musescore.com/nicolas/scores/439">Héléna</a> by <a href="http://musescore.com/user/5">Nicolas</a></span>
  </html>
  <title>Héléna</title>
  <author_name>Nicolas</author_name>
  <author_url>http://musescore.com/nicolas</author_url>
  <original_url>http://musescore.com/nicolas/scores/439</original_url>
</oembed>

JSON

Call:

http://musescore.com/oembed/endpoint?url=http://musescore.com/nicolas/scores/439&format=json

Response:

{"type":"rich",
  "version":"1.0",
  "provider_name":"MuseScore.com",
  "width":"100%",
  "height":394,
  "provider_url":"http:\/\/musescore.com",
  "html":"<iframe width=\"100%\" height=\"394\" src=\"http:\/\/musescore.com\/node\/439\/embed\" frameborder=\"0\"><\/iframe><span><a href=\"http:\/\/musescore.com\/nicolas\/scores\/439\">H\u00e9l\u00e9na<\/a> by <a  href=\"http:\/\/musescore.com\/user\/5\">Nicolas<\/a><\/span> ",
  "title":"Héléna",
  "author_name":"Nicolas",
  "author_url":"http:\/\/musescore.com\/nicolas",
  "original_url":"http:\/\/musescore.com\/nicolas\/scores\/439"}

JSONP

Call:

http://musescore.com/oembed/endpoint?url=http://musescore.com/nicolas/scores/439&format=jsonp&callback=MyCallback

Response:

MyCallback({"type":"rich",
  "version":"1.0",
  "provider_name":"MuseScore.com",
  "width":"100%",
  "height":394,
  "provider_url":"http:\/\/musescore.com",
  "html":"<iframe width=\"100%\" height=\"394\" src=\"http:\/\/musescore.com\/node\/439\/embed\" frameborder=\"0\"><\/iframe><span><a href=\"http:\/\/musescore.com\/nicolas\/scores\/439\">H\u00e9l\u00e9na<\/a> by <a  href=\"http:\/\/musescore.com\/user\/5\">Nicolas<\/a><\/span> ",
  "title":"Héléna",
  "author_name":"Nicolas",
  "author_url":"http:\/\/musescore.com\/nicolas",
  "original_url":"http:\/\/musescore.com\/nicolas\/scores\/439"});