将棋の駒API
将棋の駒8種と成駒6種。id は USI 表記(成駒は先頭に +)、count は片方の陣営の初期枚数。
| エンドポイント | https://apis-cloud.net/shogi-pieces |
| 件数 | 14 件 |
| 形式 | JSON(UTF-8) |
| 認証 | 不要(CORS 全オリジン許可) |
| ID フィールド | id(name kana romaji abbr english でも引ける) |
| 検索対象 | name kana romaji english moves note |
リクエスト
curl -s "https://apis-cloud.net/shogi-pieces/K"const res = await fetch("https://apis-cloud.net/shogi-pieces/K");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/shogi-pieces/K") as r:
data = json.load(r)
レスポンス
200 OK
{
"id": "K",
"name": "玉将",
"kana": "ぎょくしょう",
"romaji": "Gyokusho",
"abbr": "玉",
"english": "King",
"count": 1,
"isPromoted": false,
"promotesTo": null,
"moves": "縦横斜めの隣接する8マスに1マス動ける。取られると負け。",
"note": "上位者が王将(おうしょう)、下位者が玉将を使う慣習がある。"
}エンドポイント
将棋の駒APIは、他のリソースと同じ共通の形をしている。 パラメータの詳しい説明は 共通エンドポイントの節 にある。
GET/shogi-pieces |
メタ情報(件数・フィールド・エンドポイント) | |
GET/shogi-pieces/all |
全14件 | |
GET/shogi-pieces/random |
ランダムに1件 | |
GET/shogi-pieces/search?q=玉将 |
部分一致検索 | |
GET/shogi-pieces/fields |
フィールド名の一覧 | |
GET/shogi-pieces/getId |
id の列だけ取り出す | |
GET/shogi-pieces/K |
ID 指定で1件 | |
GET/shogi-pieces/K/name |
1件の特定フィールド | |
全件取得
curl -s "https://apis-cloud.net/shogi-pieces/all?limit=3"const res = await fetch("https://apis-cloud.net/shogi-pieces/all?limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/shogi-pieces/all?limit=3") as r:
data = json.load(r)フィールド
1レコードは次の 11 個のフィールドを持つ。値の例は実際の1件目から取っている。
idstring | K |
namestring | 玉将 |
kanastring | ぎょくしょう |
romajistring | Gyokusho |
abbrstring | 玉 |
englishstring | King |
countnumber | 1 |
isPromotedboolean | false |
promotesTonullable | — |
movesstring | 縦横斜めの隣接する8マスに1マス動ける。取られると負け。 |
notestring | 上位者が王将(おうしょう)、下位者が玉将を使う慣習がある。 |
必要な列だけ取得
curl -s "https://apis-cloud.net/shogi-pieces/all?fields=id,name&limit=3"const res = await fetch("https://apis-cloud.net/shogi-pieces/all?fields=id,name&limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/shogi-pieces/all?fields=id,name&limit=3") as r:
data = json.load(r)使用例
GET/shogi-pieces/R |
||
GET/shogi-pieces/飛車 |
||
GET/shogi-pieces/%2BP |
||
GET/shogi-pieces/random |
||
GET/shogi-pieces/all?fields=name,moves |
||
GET/shogi-pieces/search?q=金将 |
||
ランダムに3件(seed 固定)
curl -s "https://apis-cloud.net/shogi-pieces/random?count=3&seed=demo"const res = await fetch("https://apis-cloud.net/shogi-pieces/random?count=3&seed=demo");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/shogi-pieces/random?count=3&seed=demo") as r:
data = json.load(r)将棋の駒APIのよくある質問
- 将棋の駒の一覧はどう取得しますか?
- GET https://apis-cloud.net/shogi-pieces/all で全14件がJSONで返ります。1件だけ欲しいときは /shogi-pieces/random、ID を指定するときは /shogi-pieces/{id} を使います。
- 将棋の駒APIに認証は必要ですか?
- 不要です。API キーもトークンもなく、GET するだけで使えます。CORS も全オリジンに開けているのでブラウザから直接呼べます。
- 将棋の駒APIにはどんなフィールドがありますか?
- id、name、kana、romaji、abbr、english、count、isPromoted、promotesTo、moves、note の 11 個です。?fields= で必要な列だけに絞れます。検索は name、kana、romaji、english、moves、note が対象です。