Tiny scraper based API app for jisho.org. すげーじゃん?
jisho-api
is configured through ENV vars:
JISHO_API_HOST # (default: "") address jisho-api will listen on. an empty string means all available interfaces/addresses
JISHO_API_PORT # (default: "8080") port jisho-api will listen on
JISHO_API_LOG_JSON # (default: false) whether or not jisho-api should log using a json format
JISHO_API_LOG_CONCISE # (default: false) whether or not jisho-api should use 'concise logging' (reduces request log output)
JISHO_API_LOG_LEVEL # (default: "info") one of "trace", "debug", "info", "warn", "error", "critical"
JISHO_API_REDIS_ADDR # (default: "") address of the redis server to use. jisho-api will crash when this is configured but it cant connect.
JISHO_API_REDIS_PASS # (default: "") password to use when connecting with the redis server. leave blank if no password is required
JISHO_API_REDIS_DB # (default: 0) db to use. leave blank to use 0 / the default db
jisho-api
can make use of redis to speed up its responses and most importantly stop hammering jisho.org with request it has already made.
To enable it simply point the JISHO_API_REDIS_ADDR
env var to a valid redis server and jisho-api
will do the rest. Note that if the redis
server cannot be accessed jisho-api
will crash at launch.
Simply make a request to <host>/search/<search query>
in the same way you would search jisho.org. Additional results (if there any) can be
requested by specifying the page
query param (starts counting from 1).
$ curl -s my-jisho-api.com/search/たべる | jq
[
{
"writing": "食べる",
"reading": "食(た)べる",
"meanings": [
{
"value": "to eat",
"tags": [
"Ichidan verb",
"Transitive verb"
]
},
{
"value": "to live on (e.g. a salary); to live off; to subsist on",
"tags": [
"Ichidan verb",
"Transitive verb"
]
}
],
"tags": [
"Common word",
"JLPT N5",
"Wanikani level 6"
]
}
]
jisho-api
makes use of a compact "reading" format that combines both the written kanji and the kana reading that should be used:
<kanji>(<kana>)*|<kana>*
some examples:
writing | reading |
---|---|
食べる | 食(た)べる |
上げる | 上(あ)げる |
教科書 | 教(きょう)科(か)書(しょ) |