Buisness Problem

ํŠน์ • ๋„์‹œ์˜ ๋‚ ์”จ ์ •๋ณด๋ฅผ ์ œ๊ณตํ•˜๋Š” App ์„ ์ œ์ž‘ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ด๋ณด์ž. ๊ทธ๋ ‡๋‹ค๋ฉด external service ๋ฅผ ํ†ตํ•˜์—ฌ ๋‚ ์”จ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์™€์•ผํ•  ๊ฒƒ์ด๋‹ค.

๊ทธ๋ ‡๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ Third-Party ์ธ Weather Service ์™€ ์—ฐ๊ฒฐ์„ ํ•  ์ˆ˜ ์žˆ์„๊นŒ?

์šฐ๋ฆฌ๋Š” HTTP Protocol ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•˜๋Š” REST API ๋ฅผ ๋งŒ๋“ค์–ด์„œ Third-Party Service ์™€ Application ์„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.

REST(REpresentational State Transfer) ๋Š” HTTP Protocol ์„ ๊ธฐ๋ฐ˜์œผ๋กœ resource ์˜ ์ƒํƒœ๋ฅผ ์ฃผ๊ณ ๋ฐ›๋Š” Architecture style ์ด๋‹ค. REST ๋Š” ์ฃผ๋กœ Web API ์„ค๊ณ„์—์„œ ํ™œ์šฉ๋˜๋ฉฐ, ์ด๋ฅผ ๋”ฐ๋ฅด๋Š” API ๋ฅผ REST API ๋ผ๊ณ  ํ•œ๋‹ค. ๋˜ํ•œ client ๋‚˜ server ์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ programming laguage ์— ์ œ์•ฝ์ด ์—†์œผ๋ฉฐ, data format ์œผ๋กœ๋Š” JSON(JavaScript Object Notation) ์„ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉํ•˜์ง€๋งŒ, ์ด ์—ญ์‹œ๋„ ์ œ์•ฝ์ด ์—†๋‹ค.

Problem Solution

๋งŒ์•ฝ openweathermap.org ์—์„œ ์ œ๊ณตํ•˜๋Š” Weather Service API ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๊ณ  ํ•˜์ž. ๊ทธ๋ ‡๋‹ค๋ฉด ํ•ด๋‹น API ์‚ฌ์šฉ์„ ์œ„ํ•˜์—ฌ๋Š” API documentation ์„ ๋ฐ˜๋“œ์‹œ ํ™•์ธํ•˜๊ณ  ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.

https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API key}

์˜ˆ๋ฅผ ๋“ค์–ด ์œ„์™€ ๊ฐ™์€ API call ์—์„œ๋Š” lat ๊ฐ’๊ณผ lon ๊ฐ’, ์ฆ‰ ์œ„๋„์™€ ๊ฒฝ๋„๋ฅผ Weather Service ์— ์ „๋‹ฌํ•จ์œผ๋กœ์จ ํ•ด๋‹น ์œ„์น˜์˜ ๋„์‹œ์˜ ๋‚ ์”จ ์ •๋ณด๋ฅผ response ํ•˜๋„๋ก request ํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค.

์ฐธ๊ณ ๋กœ REST/RESTful API, Web Services, Services ๋ชจ๋‘ ๋‹ค ๊ฐ™์€ ์˜๋ฏธ๋ฅผ ๊ฐ€์ง„๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.