[210805 TIL] RESTful API

Choi Rimยท2021๋…„ 8์›” 5์ผ
0

Way to developer

๋ชฉ๋ก ๋ณด๊ธฐ
21/21
post-thumbnail
post-custom-banner

API

  • Applicaion Programming Interface
    • Interface : ๊ธฐ๊ณ„์™€ ์ธ๊ฐ„๊ฐ„์˜ ์†Œํ†ต ์ฐฝ๊ตฌ
    • ์†Œํ”„ํŠธ์›จ์–ด์™€ ์†Œํ”„ํŠธ์›จ์–ด ๊ฐ„ ์ง€์ •๋œ ํ˜•์‹์œผ๋กœ ์š”์ฒญ, ๋ช…๋ น์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์ˆ˜๋‹จ
  • ์ •๋ณด๋“ค์ด ์ฃผ๊ณ ๋ฐ›์•„์ง€๋Š” ๋ฐ ์žˆ์–ด์„œ ๊ฐœ๋ฐœ์ž๋“ค ์‚ฌ์ด์—์„œ ๋„๋ฆฌ ์“ฐ์ด๋Š” ์ผ์ข…์˜ ํ˜•์‹

RESTful API

  • API ์‹œ์Šคํ…œ์„ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•œ ์•„ํ‚คํ…์ฒ˜ ์ค‘์— ๊ฐ€์žฅ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” ํ˜•์‹
  • Graphql, GRPC, REST ... etc

Representational State Transfer

  • ์›น ์ƒ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ์—ฌ๋Ÿฌ ๋ฆฌ์†Œ์Šค๋ฅผ HTTP URI๋กœ ํ‘œํ˜„ํ•˜๊ณ  ๊ทธ ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ํ–‰์œ„๋ฅผ HTTP Method๋กœ ์ •์˜ํ•˜๋Š” ๋ฐฉ์‹.

RESTful API์˜ ์žฅ๋‹จ์ 

์žฅ์ 

  • API ์ž์ฒด๋งŒ์œผ๋กœ๋„ API ์˜ ๋ชฉ์ ์ด ์‰ฝ๊ฒŒ ์ดํ•ด ๋œ๋‹ค.
    • GET/users/1
    • 1๋ฒˆ ์œ ์ € ํ˜ธ์ถœ

๋‹จ์ 

  • ํ‘œ์ค€๊ทœ์•ฝ์ด ์—†์–ด ๋น„ํšจ์œจ์ ์ด๊ฑฐ๋‚˜ ๋น„์ƒ์‚ฐ์ ์ธ ํŒจํ„ด์œผ๋กœ ์ž‘์„ฑ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ๋งŽ๋‹ค.

๊ธฐ๋ณธ ๋ฐฐ๊ฒฝ ์ง€์‹

  • URI (Uniform Resource Identifier)
    • ํ•ด๋‹น ์‚ฌ์ดํŠธ์˜ ํŠน์ • ์ž์›์˜ ์œ„์น˜๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์œ ์ผํ•œ ์ฃผ์†Œ
    • http://finance.naver.com/login
    • /login ๋ถ€๋ถ„์ด URI
  • HTTP Method
    • HTTP request๊ฐ€ ์˜๋„ํ•˜๋Š” action์„ ์ •์˜ํ•œ ๊ฒƒ
  • Payload
    • HTTP request์—์„œ server๋กœ ๋ณด๋‚ด๋Š” ๋ฐ์ดํ„ฐ (body)

์„ค๊ณ„ ๊ทœ์น™

  • URI์˜ / ๊ตฌ๋ถ„์ž๋ฅผ ์‚ฌ์šฉํ•ด ์ž์›์˜ ๊ณ„์ธต ๊ด€๊ณ„๋ฅผ ๋‚˜ํƒ€๋‚ธ๋‹ค.
  • URI๊ฐ€ ๊ธธ์–ด์ง€๋Š” ๊ฒฝ์šฐ -๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ€๋…์„ฑ์„ ๋†’์ธ๋‹ค.
  • _๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค. ( ๊ฐ€๋…์„ฑ์„ ์œ„ํ•˜์—ฌ)
  • URI ๊ฒฝ๋กœ์—๋Š” ๋Œ€๋ฌธ์ž ์‚ฌ์šฉ์„ ํ”ผํ•˜๋„๋ก ๊ทœ์ •
  • ๋™์‚ฌ ๊ธˆ์ง€, ๋ช…์‚ฌ ์‚ฌ์šฉ
profile
https://rimi0108.github.io/
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€