Skip to content

API JSON P

Manuel Strehl edited this page Aug 2, 2013 · 2 revisions

JSON-P Requests to the API

Every time the API can return JSON, the result can be requested as JSON-P, too. JSON-P is basically JSON embedded in a little JavaScript snippet, so that the response can be handled in an HTML <script> element. See JSON-P.org on details.

You can enable a JSON-P response simply by providing a GET parameter named callback, giving it a JavaScript function name. A simple example: This request

http://codepoints.net/api/v1/codepoint/0078?property=na

results in the JSON response:

{"na":"LATIN SMALL LETTER V"}

If you append the parameter callback, the response will be valid JavaScript:

http://codepoints.net/api/v1/codepoint/0078?property=na&callback=foo

returns

foo({"na":"LATIN SMALL LETTER V"});

Clone this wiki locally