十二支API
十二支と、それぞれが表す動物・方角・時刻。yearMod12 は「西暦をこの数で割った余りがその年の干支」を表す(例: 2020 % 12 = 4 で子年)。
| エンドポイント | https://apis-cloud.net/eto |
| 件数 | 12 件 |
| 形式 | JSON(UTF-8) |
| 認証 | 不要(CORS 全オリジン許可) |
| ID フィールド | name(order kana romaji english animal でも引ける) |
| 検索対象 | name kana romaji english animal animalKana |
リクエスト
curl -s "https://apis-cloud.net/eto/1"const res = await fetch("https://apis-cloud.net/eto/1");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/eto/1") as r:
data = json.load(r)
レスポンス
200 OK
{
"order": 1,
"name": "子",
"kana": "ね",
"animal": "鼠",
"animalKana": "ねずみ",
"romaji": "Ne",
"english": "Rat",
"direction": "北",
"hour": "23時〜1時",
"yearMod12": 4,
"recentYear": 2020
}エンドポイント
十二支APIは、他のリソースと同じ共通の形をしている。 パラメータの詳しい説明は 共通エンドポイントの節 にある。
GET/eto |
メタ情報(件数・フィールド・エンドポイント) | |
GET/eto/all |
全12件 | |
GET/eto/random |
ランダムに1件 | |
GET/eto/search?q=子 |
部分一致検索 | |
GET/eto/fields |
フィールド名の一覧 | |
GET/eto/getName |
name の列だけ取り出す | |
GET/eto/1 |
ID 指定で1件 | |
GET/eto/1/name |
1件の特定フィールド | |
全件取得
curl -s "https://apis-cloud.net/eto/all?limit=3"const res = await fetch("https://apis-cloud.net/eto/all?limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/eto/all?limit=3") as r:
data = json.load(r)フィールド
1レコードは次の 11 個のフィールドを持つ。値の例は実際の1件目から取っている。
ordernumber | 1 |
namestring | 子 |
kanastring | ね |
animalstring | 鼠 |
animalKanastring | ねずみ |
romajistring | Ne |
englishstring | Rat |
directionstring | 北 |
hourstring | 23時〜1時 |
yearMod12number | 4 |
recentYearnumber | 2020 |
必要な列だけ取得
curl -s "https://apis-cloud.net/eto/all?fields=order,name&limit=3"const res = await fetch("https://apis-cloud.net/eto/all?fields=order,name&limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/eto/all?fields=order,name&limit=3") as r:
data = json.load(r)使用例
GET/eto/午 |
||
GET/eto/7 |
||
GET/eto/Horse |
||
GET/eto/random |
||
GET/eto/getAnimal |
||
ランダムに3件(seed 固定)
curl -s "https://apis-cloud.net/eto/random?count=3&seed=demo"const res = await fetch("https://apis-cloud.net/eto/random?count=3&seed=demo");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/eto/random?count=3&seed=demo") as r:
data = json.load(r)十二支APIのよくある質問
- 十二支の一覧はどう取得しますか?
- GET https://apis-cloud.net/eto/all で全12件がJSONで返ります。1件だけ欲しいときは /eto/random、ID を指定するときは /eto/{name} を使います。
- 十二支APIに認証は必要ですか?
- 不要です。API キーもトークンもなく、GET するだけで使えます。CORS も全オリジンに開けているのでブラウザから直接呼べます。
- 十二支APIにはどんなフィールドがありますか?
- order、name、kana、animal、animalKana、romaji、english、direction、hour、yearMod12、recentYear の 11 個です。?fields= で必要な列だけに絞れます。検索は name、kana、romaji、english、animal、animalKana が対象です。