誕生石API
月ごとの誕生石。全国宝石卸商協同組合が2021年に改訂した日本の誕生石リストに基づく。
| エンドポイント | https://apis-cloud.net/birthstones |
| 件数 | 12 件 |
| 形式 | JSON(UTF-8) |
| 認証 | 不要(CORS 全オリジン許可) |
| ID フィールド | month |
| 検索対象 | stones stonesEn meaning |
リクエスト
curl -s "https://apis-cloud.net/birthstones/1"const res = await fetch("https://apis-cloud.net/birthstones/1");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/birthstones/1") as r:
data = json.load(r)
レスポンス
200 OK
{
"month": 1,
"stones": [
"ガーネット"
],
"stonesEn": [
"Garnet"
],
"meaning": "真実・友愛・忠実"
}エンドポイント
誕生石APIは、他のリソースと同じ共通の形をしている。 パラメータの詳しい説明は 共通エンドポイントの節 にある。
GET/birthstones |
メタ情報(件数・フィールド・エンドポイント) | |
GET/birthstones/all |
全12件 | |
GET/birthstones/random |
ランダムに1件 | |
GET/birthstones/search?q=ガー |
部分一致検索 | |
GET/birthstones/fields |
フィールド名の一覧 | |
GET/birthstones/getMonth |
month の列だけ取り出す | |
GET/birthstones/1 |
ID 指定で1件 | |
GET/birthstones/1/stones |
1件の特定フィールド | |
全件取得
curl -s "https://apis-cloud.net/birthstones/all?limit=3"const res = await fetch("https://apis-cloud.net/birthstones/all?limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/birthstones/all?limit=3") as r:
data = json.load(r)フィールド
1レコードは次の 4 個のフィールドを持つ。値の例は実際の1件目から取っている。
monthnumber | 1 |
stonesarray | ガーネット |
stonesEnarray | Garnet |
meaningstring | 真実・友愛・忠実 |
必要な列だけ取得
curl -s "https://apis-cloud.net/birthstones/all?fields=month,stones&limit=3"const res = await fetch("https://apis-cloud.net/birthstones/all?fields=month,stones&limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/birthstones/all?fields=month,stones&limit=3") as r:
data = json.load(r)使用例
GET/birthstones/4 |
||
GET/birthstones/random |
||
GET/birthstones/all |
||
GET/birthstones/getStones |
||
ランダムに3件(seed 固定)
curl -s "https://apis-cloud.net/birthstones/random?count=3&seed=demo"const res = await fetch("https://apis-cloud.net/birthstones/random?count=3&seed=demo");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/birthstones/random?count=3&seed=demo") as r:
data = json.load(r)誕生石APIのよくある質問
- 誕生石の一覧はどう取得しますか?
- GET https://apis-cloud.net/birthstones/all で全12件がJSONで返ります。1件だけ欲しいときは /birthstones/random、ID を指定するときは /birthstones/{month} を使います。
- 誕生石APIに認証は必要ですか?
- 不要です。API キーもトークンもなく、GET するだけで使えます。CORS も全オリジンに開けているのでブラウザから直接呼べます。
- 誕生石APIにはどんなフィールドがありますか?
- month、stones、stonesEn、meaning の 4 個です。?fields= で必要な列だけに絞れます。検索は stones、stonesEn、meaning が対象です。