12星座API
西洋占星術の12星座。期間・四大元素(火地風水)・三区分・支配星つき。
| エンドポイント | https://apis-cloud.net/horoscope |
| 件数 | 12 件 |
| 形式 | JSON(UTF-8) |
| 認証 | 不要(CORS 全オリジン許可) |
| ID フィールド | name(order kana latin english でも引ける) |
| 検索対象 | name kana latin english element ruler |
リクエスト
curl -s "https://apis-cloud.net/horoscope/1"const res = await fetch("https://apis-cloud.net/horoscope/1");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/horoscope/1") as r:
data = json.load(r)
レスポンス
200 OK
{
"order": 1,
"name": "牡羊座",
"kana": "おひつじざ",
"latin": "Aries",
"english": "Ram",
"symbol": "♈",
"from": "3月21日",
"to": "4月19日",
"element": "火",
"quality": "活動宮",
"ruler": "火星"
}エンドポイント
12星座APIは、他のリソースと同じ共通の形をしている。 パラメータの詳しい説明は 共通エンドポイントの節 にある。
GET/horoscope |
メタ情報(件数・フィールド・エンドポイント) | |
GET/horoscope/all |
全12件 | |
GET/horoscope/random |
ランダムに1件 | |
GET/horoscope/search?q=牡羊 |
部分一致検索 | |
GET/horoscope/fields |
フィールド名の一覧 | |
GET/horoscope/getName |
name の列だけ取り出す | |
GET/horoscope/1 |
ID 指定で1件 | |
GET/horoscope/1/name |
1件の特定フィールド | |
全件取得
curl -s "https://apis-cloud.net/horoscope/all?limit=3"const res = await fetch("https://apis-cloud.net/horoscope/all?limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/horoscope/all?limit=3") as r:
data = json.load(r)フィールド
1レコードは次の 11 個のフィールドを持つ。値の例は実際の1件目から取っている。
ordernumber | 1 |
namestring | 牡羊座 |
kanastring | おひつじざ |
latinstring | Aries |
englishstring | Ram |
symbolstring | ♈ |
fromstring | 3月21日 |
tostring | 4月19日 |
elementstring | 火 |
qualitystring | 活動宮 |
rulerstring | 火星 |
必要な列だけ取得
curl -s "https://apis-cloud.net/horoscope/all?fields=order,name&limit=3"const res = await fetch("https://apis-cloud.net/horoscope/all?fields=order,name&limit=3");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/horoscope/all?fields=order,name&limit=3") as r:
data = json.load(r)使用例
GET/horoscope/獅子座 |
||
GET/horoscope/Leo |
||
GET/horoscope/5 |
||
GET/horoscope/random |
||
GET/horoscope/search?q=火 |
||
GET/horoscope/getLatin |
||
ランダムに3件(seed 固定)
curl -s "https://apis-cloud.net/horoscope/random?count=3&seed=demo"const res = await fetch("https://apis-cloud.net/horoscope/random?count=3&seed=demo");
const data = await res.json();import urllib.request, json
with urllib.request.urlopen("https://apis-cloud.net/horoscope/random?count=3&seed=demo") as r:
data = json.load(r)12星座APIのよくある質問
- 12星座の一覧はどう取得しますか?
- GET https://apis-cloud.net/horoscope/all で全12件がJSONで返ります。1件だけ欲しいときは /horoscope/random、ID を指定するときは /horoscope/{name} を使います。
- 12星座APIに認証は必要ですか?
- 不要です。API キーもトークンもなく、GET するだけで使えます。CORS も全オリジンに開けているのでブラウザから直接呼べます。
- 12星座APIにはどんなフィールドがありますか?
- order、name、kana、latin、english、symbol、from、to、element、quality、ruler の 11 個です。?fields= で必要な列だけに絞れます。検索は name、kana、latin、english、element、ruler が対象です。