Skip to content

API search

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

Search for Codepoints

Template for this request:

http://codepoints.net/api/v1/search{?properties}{&page}{&per_page}{&callback}

with {?properties} one or several key/value pairs of Unicode properties or int for decimal codepoint values or q for free text search. This API exposes the functionality of the main site’s search. {?callback} is an optional callback function name to perform a JSON-P request.

Response

The responding set of codepoints is paged so that a maximum of 1000 codepoints is displayed at once. You can opt for fewer codepoints with the per_page GET parameter.

A response for the request to /api/v1/search?q=heart&per_page=5 looks like this:

{
    "page": 1,
    "last_page": 22,
    "per_page": 5,
    "count": 109,
    "result": [
        8711,
        9167,
        9753,
        9824,
        9825
    ]
}

page denotes the current page in paged results. last_page is the last page number in paged results. per_page shows, how many codepoints are shown per page, count is the number of all codepoints matching the query. result finally is an array of integers, which represent the codepoints in the result set.

Additional HTTP Headers

A successful response will contain four to five Link headers:

  1. rel=alternate links to the HTML view of the search result on the main site.
  2. rel=first links to the first page of the result set. This is always present.
  3. rel=prev links to the previous page, if it exists.
  4. rel=next links to the next page, if it exists.
  5. rel=first links to the last page of the result set. This is always present.

Possible Errors

This API endpoint should not throw any errors. An empty search result looks like this:

{
    "page": 1,
    "last_page": 1,
    "per_page": 1000,
    "count": 0,
    "result": [ ]
}
Clone this wiki locally