MyAPIs v0.1.0
https://apis-cloud.net

名言API

古今東西の名言。出典が明確でないものは source に「帰属には諸説あり」と記している。D1 に格納。

エンドポイントhttps://apis-cloud.net/quotes
件数60 件
形式JSON(UTF-8)
認証不要(CORS 全オリジン許可)
ID フィールドid
検索対象text author authorKana category source
リクエスト
curl -s "https://apis-cloud.net/quotes/1"
const res = await fetch("https://apis-cloud.net/quotes/1");
const data = await res.json();
import urllib.request, json

with urllib.request.urlopen("https://apis-cloud.net/quotes/1") as r:
    data = json.load(r)
レスポンス 200 OK
{
  "id": 1,
  "text": "為せば成る 為さねば成らぬ 何事も 成らぬは人の 為さぬなりけり",
  "author": "上杉鷹山",
  "authorKana": "うえすぎようざん",
  "lang": "ja",
  "category": "行動",
  "source": "上杉鷹山の歌として伝わる"
}

エンドポイント

名言APIは、他のリソースと同じ共通の形をしている。 パラメータの詳しい説明は 共通エンドポイントの節 にある。

GET/quotes メタ情報(件数・フィールド・エンドポイント)
GET/quotes/all 全60件
GET/quotes/random ランダムに1件
GET/quotes/search?q=為せ 部分一致検索
GET/quotes/fields フィールド名の一覧
GET/quotes/getId id の列だけ取り出す
GET/quotes/1 ID 指定で1件
GET/quotes/1/text 1件の特定フィールド
全件取得
curl -s "https://apis-cloud.net/quotes/all?limit=3"
const res = await fetch("https://apis-cloud.net/quotes/all?limit=3");
const data = await res.json();
import urllib.request, json

with urllib.request.urlopen("https://apis-cloud.net/quotes/all?limit=3") as r:
    data = json.load(r)

フィールド

1レコードは次の 7 個のフィールドを持つ。値の例は実際の1件目から取っている。

idnumber1
textstring為せば成る 為さねば成らぬ 何事も 成らぬは人の 為さぬなりけり
authorstring上杉鷹山
authorKanastringうえすぎようざん
langstringja
categorystring行動
sourcestring上杉鷹山の歌として伝わる
必要な列だけ取得
curl -s "https://apis-cloud.net/quotes/all?fields=id,text&limit=3"
const res = await fetch("https://apis-cloud.net/quotes/all?fields=id,text&limit=3");
const data = await res.json();
import urllib.request, json

with urllib.request.urlopen("https://apis-cloud.net/quotes/all?fields=id,text&limit=3") as r:
    data = json.load(r)

使用例

GET/quotes/1
GET/quotes/random
GET/quotes/all?limit=5
GET/quotes/search?q=Dijkstra
GET/quotes/getAuthor?unique=1
ランダムに3件(seed 固定)
curl -s "https://apis-cloud.net/quotes/random?count=3&seed=demo"
const res = await fetch("https://apis-cloud.net/quotes/random?count=3&seed=demo");
const data = await res.json();
import urllib.request, json

with urllib.request.urlopen("https://apis-cloud.net/quotes/random?count=3&seed=demo") as r:
    data = json.load(r)

名言APIのよくある質問

名言の一覧はどう取得しますか?
GET https://apis-cloud.net/quotes/all で全60件がJSONで返ります。1件だけ欲しいときは /quotes/random、ID を指定するときは /quotes/{id} を使います。
名言APIに認証は必要ですか?
不要です。API キーもトークンもなく、GET するだけで使えます。CORS も全オリジンに開けているのでブラウザから直接呼べます。
名言APIにはどんなフィールドがありますか?
id、text、author、authorKana、lang、category、source の 7 個です。?fields= で必要な列だけに絞れます。検索は text、author、authorKana、category、source が対象です。

他のAPI