Skip to content
Manuel Strehl edited this page Dec 15, 2015 · 11 revisions

The Codepoints API

A RESTful Interface to Unicode Data

The API of Codepoints.net can be reached at

http://codepoints.net/api/v1/

It is a REST API giving access to Unicode data. Mostly, JSON will be returned. In the case of an error the API adheres to the Problem Details for HTTP APIs draft specification. What this means concretely is detailed on the errors description page.

The API sends a CORS header to allow true cross-domain requests in newer browsers. If the client cannot understand CORS headers, it can alternatively perform a JSON-P request by adding ?callback=function_name to any JSON-responding API URL.

The API Endpoints

Example Request

A typical request has the following form:

GET /api/v1/codepoint/1234?property=cp,na,age HTTP/1.1
Host: codepoints.net
Accept: application/json
Accept-Language: en

And the API response is shaped like this:

HTTP/1.1 200 OK
Date: Sun, 14 Jul 2013 20:19:19 GMT
Access-Control-Allow-Origin: *
Content-Language: en
Content-Type: application/json; charset=UTF-8
Last-Modified: Mon, 08 Jul 2013 23:21:20 +0200
Link: <http://codepoints.net/U+1234>; rel=alternate
Link: <http://codepoints.net/api/v1/block/ethiopic>; rel=up
Link: <http://codepoints.net/api/v1/codepoint/1235>; rel=next
Link: <http://codepoints.net/api/v1/codepoint/1233>; rel=prev
Unicode-Version: 6.1.0

{"cp":"4660","age":"3.0","na":"ETHIOPIC SYLLABLE SEE"}

There are three note-worthy headers here:

  1. The Link headers allow access to the previous and next codepoint as well as to the containing Unicode block.
  2. The custom header Unicode-Version gives the precise Unicode version this answer is valid for.
  3. The Last-Modified header is appropriately set to allow client-side caching of the API response.
Clone this wiki locally