API - PIETEP/mebius GitHub Wiki

API設計

Usecase

  • カード

    • カード追加
    • カード削除
  • デッキ

    • デッキ登録
    • カードをadd
    • カードを削除
    • デッキを削除
  • 検索クエリ

    • カード名を入力(1枚以上)
    • 星を入れる
    • searchボタンを押す

API一覧

  • カード
    • GET /api/v1/cards
    • POST /api/v1/cards
    • GET /api/v1/cards/{:id}
    • DELETE /api/v1/cards/{:id}
  • デッキ
    • GET /api/v1/decks
    • POST /api/v1/decks
    • GET /api/v1/decks/{:id}
    • PUT /api/v1/decks/{:id}
    • DELETE /api/v1/decks/{:id}
  • 検索クエリ
    • GET /api/v1/search
    • GET /api/v1/suggest

GET /api/v1/cards

Query Parameter

Response JSON

{
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }]
}

POST /api/v1/cards

Request JSON

{
    "name": "ドラゴンナイト",
    "point": 4,
    "species0": "dragon",
    "species1": "human",
    "job": "Knight"
}

Successful Response JSON

  • Status Code: 200
{
    "id": 0,
    "name": "ドラゴンナイト",
    "point": 4,
    "species0": "dragon",
    "species1": "human",
    "job": "Knight"
}

Failure Response JSON

  • Status Code: 400
{
    "message": "おーい"
}

GET /api/v1/cards/{:id}

Query Parameter

Response JSON

{
    "id": 0,
    "name": "ドラゴンナイト",
    "point": 4,
    "species0": "dragon",
    "species1": "human",
    "job": "Knight"
}

DELETE /api/v1/cards/{:id}

Query Parameter

Successful Response JSON

{
    "name": "ドラゴンナイト",
    "point": 4,
    "species0": "dragon",
    "species1": "human",
    "job": "Knight"
}

Failure Response JSON

  • Status Code: 400
{
    "message": "失敗したで"
}

GET /api/v1/decks

Query Parameter

Response JSON

{
    "decks": [{
        "id": 0,
        "name": "Dragon",
        "cards": [{
            "id": 0,
            "name": "ドラゴンナイト",
            "point": 4,
            "species0": "dragon",
            "species1": "human",
            "job": "Knight"
        }, {
            "id": 1,
            "name": "デストロイヤー",
            "point": 5,
            "species0": "Goblin",
            "species1": null,
            "job": "Mechanic"
        }],
        "creator": "Yuta"
    }, {
        "id": 1,
        "name": "Goblin",
        "cards": [{
            "id": 0,
            "name": "ドラゴンナイト",
            "point": 4,
            "species0": "dragon",
            "species1": "human",
            "job": "Knight"
        }, {
            "id": 1,
            "name": "デストロイヤー",
            "point": 5,
            "species0": "Goblin",
            "species1": null,
            "job": "Mechanic"
        }],
        "creator": "Yuya"
    }]
}

POST /api/v1/decks

Request JSON

{
    "name": null,
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }],
    "creator": "Yuta"
}

Successful Response JSON

  • Status Code: 200
{
    "id": 0,
    "name": "Deck0",
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }],
    "creator": "Yuta"
}

Failure Response JSON

  • Status Code: 400
{
    "message": "おーい"
}

GET /api/v1/decks/{:id}

Response JSON

{
    "id": 0,
    "name": "Deck0",
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }],
    "creator": "Yuta"
}

PUT /api/v1/decks/{:id}

Request JSON

{
    "id": 0,
    "name": "元々付いてる名前",
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }],
    "creator": "Yuta"
}

Response JSON

{
    "id": 0,
    "name": "Deck0",
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }],
    "creator": "Yuta"
}

DELETE /api/v1/decks/{:id}

Successful Response JSON

{
    "name": "Deck0",
    "cards": [{
        "id": 0,
        "name": "ドラゴンナイト",
        "point": 4,
        "species0": "dragon",
        "species1": "human",
        "job": "Knight"
    }, {
        "id": 1,
        "name": "デストロイヤー",
        "point": 5,
        "species0": "Goblin",
        "species1": null,
        "job": "Mechanic"
    }],
    "creator": "Yuta"
}

Failure Response JSON

  • Status Code: 400
{
    "message": "失敗したで"
}

GET /api/v1/search

Query Parameter

  • q: 検索ワード
  • star: 星の数

Response JSON

{
    "scores": [{
        "point": 100,
        "deck": {
            "id": 0,
            "name": "",
            "url": "http://<domain>/deck/0"
        }
    }, {
        "point": 90,
        "deck": {
            "id": 1,
            "name": "",
            "url": "http://<domain>/deck/1"
        }
    }, {
        "point": 80,
        "deck": {
            "id": 2,
            "name": "",
            "url": "http://<domain>/deck/2"
        }
    },]
}

GET /api/v1/suggest

Query Parameter

  • q: 検索ワード

Response JSON

{
    "words": [
        "ドラゴンナイト",
        "ドラゴンなんちゃら",
        "ドラゴン強い子",
    ]
}
⚠️ **GitHub.com Fallback** ⚠️