๐ŸŒฑlimitless API ๊ฐ€์ด๋“œ

(1) cardset ๋ณด๊ธฐ ํŽ˜์ด์ง€

  • Page URL : /cardsets/:id

โ‘  ํ˜„์žฌ cardset ์ •๋ณด(id, ์ œ๋ชฉ, ์ž์‹ ๋…ธ๋“œ ์ •๋ณด) ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

๐Ÿ“ค Request

URL

GET /api/cardsets/{cardset์˜ id}/info

๐Ÿ“ข Response

NameTypeDescription
idintcardset์˜ id
namestringcardset์˜ title
cardSetCountint์ž์‹ ๋…ธ๋“œ๋“ค ์ค‘ cardset์˜ ๊ฐœ์ˆ˜
cardCountint์ž์‹ ๋…ธ๋“œ๋“ค ์ค‘ card์˜ ๊ฐœ์ˆ˜

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
GET /api/1/info
  • ๐Ÿ“ข Response
{
	id: 1,
    name: '์šด์˜์ฒด์ œ',
    cardSetCount: 2,
    cardCount: 2,
}

โ‘ก cardset์˜ ์ž์‹ ๋…ธ๋“œ(card, cardset) ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

  • ๋ฐ”๋กœ ์•„๋ž˜ ์—ฐ๊ฒฐ๋œ ์ž์‹ ๋…ธ๋“œ๊นŒ์ง€๋งŒ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ โ†’ depth = 1

๐Ÿ“ค Request

URL

GET /api/cardsets/{cardset์˜ id}/children

๐Ÿ“ข Response

  • Response ํ˜•ํƒœ๋Š” [card ๋˜๋Š” cardset์ด ์ €์žฅ๋œ JSON Array]

โ“ if โ†’ card

NameTypeDescription
idintcard์˜ id
typestringtype: 'CARD'
titlestringcard์˜ question

โ“‘ if โ†’ cardset

NameTypeDescription
idintcardset์˜ id
typestringtype: 'CARDSET'
titlestringcardset์˜ title

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
GET /api/cardsets/1/children
  • ๐Ÿ“ข Response
[
	{
    	id: 2,
        type: 'CARD',
        title: '์šด์˜์ฒด์ œ๋ž€?',
    },
    {
    	id: 3,
        type: 'CARDSET',
        title: '์šด์˜์ฒด์ œ ์ฒ˜๋ฆฌ ๋ฐฉ์‹'
    },
    {
    	id: 4,
        type: 'CARD',
        title: '์šด์˜์ฒด์ œ์˜ ์‚ฌ์šฉ ๋ชฉ์ ์€?',
    },
]

โ‘ข sidebar์— ๋ณด์ด๋Š” root cardset ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

  • ๊ฐ€์žฅ ์ƒ์œ„ root cardset๋“ค์˜ info ๋ณด์—ฌ์ฃผ๊ธฐ
  • root cardset๋“ค์˜ ์ƒ์œ„ cardset์„ ์ž„์˜๋กœ ๋งŒ๋“ค๊ณ  ๊ทธ๊ฒƒ์˜ id=1์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜์ž.

๐Ÿ“ค Request

URL

GET /api/cardsets/1/children

๐Ÿ“ข Response

  • Response ํ˜•ํƒœ๋Š” [๊ฐ๊ฐ์˜ root ์ •๋ณด๊ฐ€ ๋‹ด๊ธด JSON Array]
NameTypeDescription
idintroot cardset์˜ id
typestringtype: 'CARDSET'
titleintcardset์˜ title

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
GET /api/cardsets/1/children
  • ๐Ÿ“ข Response
[
	{
    	id: 3,
        type: 'CARDSET',
        title: '์šด์˜์ฒด์ œ',
    },
    {
    	id: 6,
        type: 'CARDSET',
        title: '์•Œ๊ณ ๋ฆฌ์ฆ˜',
    },
]

(2) cardset ์ˆ˜์ • ํŽ˜์ด์ง€

  • Page URL : /studio/:id

โœจ์ฐธ๊ณ 

  1. ์นด๋“œ๋ฅผ ์ƒ์„ฑํ•˜๊ณ  save ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ
    • frontend์—์„œ [์ƒˆ๋กญ๊ฒŒ ์ƒ์„ฑํ•œ ์นด๋“œ list]์™€ [์ˆ˜์ •ํ•œ ์นด๋“œ list]์™€ [์ˆ˜์ •๋œ cardset ์ œ๋ชฉ]์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค๊ฐ€
    • save ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ๊ฐ๊ฐ์„ for๋ฌธ์œผ๋กœ ๋Œ์•„์„œ ๊ฐ๊ฐ์˜ card๋ฅผ POST๋กœ ๋ณด๋‚ธ๋‹ค.
  1. add cardset ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅผ ๋•Œ
    • ํ˜„์žฌ๊นŒ์ง€์˜ ์ˆ˜์ • ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ 1๋ฒˆ ๊ณผ์ •(์นด๋“œ ์ €์žฅ ์š”์ฒญ)์„ ์ง„ํ–‰ํ•œ๋‹ค.
    • new cardset ์ƒ์„ฑ ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค. body์— { name : 'Untitled' }๋ฅผ ๋‹ด์•„์„œ ๋ณด๋‚ด๊ณ  ์‘๋‹ต์œผ๋กœ new cardset์˜ cardset id๋ฅผ ๋ฐ›๋Š”๋‹ค.
    • cardset id๋ฅผ ๊ฐ€์ง€๊ณ  URL์ด /studio/:id์ธ ํŽ˜์ด์ง€๋ฅผ ํ˜ธ์ถœํ•ด ์ƒˆ๋กœ์šด studio page๋กœ ์ด๋™ํ•œ๋‹ค.

โ‘  ์ƒˆ๋กญ๊ฒŒ ๋งŒ๋“  ์นด๋“œ ์ €์žฅํ•˜๊ธฐ

๐Ÿ“ค Request

URL

POST /api/cardsets/{cardset์˜ id}/card

๐Ÿงพ Parameter

NameTypeDescription
questionstringcard์˜ ์งˆ๋ฌธ
answerstringcard์˜ ์ •๋‹ต

๐Ÿ“ข Response

NameTypeDescription
idint๋งŒ๋“ค์–ด์ง„ card์˜ id
questionstringcard์˜ ์งˆ๋ฌธ
answerstringcard์˜ ์ •๋‹ต

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
POST /api/cardsets/1/card
{
	question: '์‚ฌ๊ณผ๋ฅผ ์˜์–ด๋กœ?',
    description: 'apple',
}
  • ๐Ÿ“ข Response
{
	id: 2,
	question: '์‚ฌ๊ณผ๋ฅผ ์˜์–ด๋กœ?',
    description: 'apple',
}

โ‘ก ๊ธฐ์กด ์นด๋“œ ์ˆ˜์ •ํ•˜๊ธฐ

๐Ÿ“ค Request

URL

PATCH /api/cardsets/{cardset์˜ id}/card/{์ˆ˜์ •ํ•œ card์˜ id}

๐Ÿงพ Parameter

NameTypeDescription
questionstringcard์˜ ์งˆ๋ฌธ
answerstringcard์˜ ์ •๋‹ต

๐Ÿ“ข Response

NameTypeDescription
idint๋งŒ๋“ค์–ด์ง„ card์˜ id
questionstringcard์˜ ์งˆ๋ฌธ
answerstringcard์˜ ์ •๋‹ต

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
PATCH /api/1/card/2
{
	question: '์‚ฌ๊ณผ๋ฅผ ์˜์–ด๋กœ?',
    description: 'apple',
}
  • ๐Ÿ“ข Response
{
	id: 2,
	question: '์‚ฌ๊ณผ๋ฅผ ์˜์–ด๋กœ?',
    description: 'apple',
}

โ‘ข ์ƒˆ๋กœ์šด cardset ์ƒ์„ฑ ์š”์ฒญ ๋ณด๋‚ด๊ธฐ

  • add cardset ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์‹คํ–‰

๐Ÿ“ค Request

URL

POST /api/cardsets/{cardset์˜ id}/cardset

๐Ÿงพ Parameter

NameTypeDescription
namestring'Untitled'๋ฅผ ๋ณด๋‚ธ๋‹ค

๐Ÿ“ข Response

NameTypeDescription
idint๋งŒ๋“ค์–ด์ง„ new cardset์˜ id

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
POST /api/cardsets/1{cardset์˜ id}/cardset
{
	name: '์ž๋ฃŒ๊ตฌ์กฐ',
}
  • ๐Ÿ“ข Response
{
	id: 15,
}

โ‘ฃ ํ˜„์žฌ cardset์˜ title ์ˆ˜์ •

๐Ÿ“ค Request

URL

PATCH api/cardsets/{์ˆ˜์ •๋œ ํ˜„์žฌ cardset์˜ id}

๐Ÿงพ Parameter

NameTypeDescription
idint์ˆ˜์ •๋œ cardset์˜ id
namestring์ˆ˜์ •ํ•  cardset์˜ ์ œ๋ชฉ

๐Ÿ“ข Response

๐ŸŒŸ๋ณด๋ฅ˜! ์–ด๋–ค๊ฑธ ์‘๋‹ต์œผ๋กœ ์ค„์ง€ ๋ฏธ์ •...

NameTypeDescription
namestring์ˆ˜์ •๋œ cardset์˜ ์ œ๋ชฉ

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
PATCH api/cardsets/1
{
	id: 1,
	name: '์•Œ๊ณ ๋ฆฌ์ฆ˜',
}
  • ๐Ÿ“ข Response
{
	name: '์•Œ๊ณ ๋ฆฌ์ฆ˜',
}

โ‘ค ํ˜„์žฌ cardset์˜ cards ๊ฐ€์ ธ์˜ค๊ธฐ

๐Ÿ“ค Request

URL

GET /api/cardsets/{cardset์˜ id}/cards

๐Ÿ“ข Response

  • cards๋ฅผ JSON Array๋กœ ์ค€๋‹ค.
NameTypeDescription
idintcard id
questionstringcard ์งˆ๋ฌธ
answerstringcard ์ •๋‹ต
titlestringcard๊ฐ€ ์†ํ•œ cardset์˜ title

์˜ˆ์‹œ

  • ๐Ÿ“ค Request
GET /api/cardsets/1/cards
  • ๐Ÿ“ข Response
[
	{
    	id: 1,
        question: '1+1?',
        answer: '2',
    },
    {
    	id: 14,
        question: '2+2?',
        answer: '4',
    },
]

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ