Example - Japanese dictionary API
This is a more advanced example, that aims to provide a Japanese-English dictionary API. It is based on the JMdict project.
It takes a large XML file as an input, and provides an HTTP service with a single endpoint and filtering features.
It also demonstrates the possibility of having the endpoints available via both HTTP (http://localhost:3001
) and HTTPS (https://localhost:3002
), using a self-signed certificate.
You can download and run this example locally (using Docker) with the following script.
The source code for this example is also available here.
List of words
The basic behaviour of the endpoint is to list all the words in the database:
GET http://localhost:3001/
Response body:
Search a specific Japanese word
The word
parameter allows filtering on a Japanese word. It is based on the SQLite index and only allows exact matching of the whole words.
GET http://localhost:3001/?word=読む
Response body:
Wildcard search in English
The translation
filter allows to search a word by it’s translation, using a Wildcard index.
GET http://localhost:3001/?translation=run
Response body:
Advanced full-text match query
The query
filter allows more advanced searches using an FTS5 index.
GET http://localhost:3001/?query=(translation: trip AND translation: day) OR translation:work hard
Response body:
Paging
The results are paged using the offset
and limit
parameters. The default value for limit
is 100
.
GET http://localhost:3001/?limit=2&offset=50
Response body:
GET http://localhost:3001/?limit=2&offset=52
Response body: