๐Ÿ“ŒLanguage/JavaScript

์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ํฌ๋กฌ ์•ฑ ๋งŒ๋“ค๊ธฐ - ๋…ธ๋งˆ๋“œ ์ฝ”๋” ํด๋ก ์ฝ”๋”ฉ #13 ์œ„์น˜ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ, API๋ž€ , Json viewer ํฌ๋กฌํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ ์‚ฌ์šฉ ๋ฐฉ๋ฒ•

hellohailie 2022. 4. 13. 17:47

navigator.geolocation.getCurrentPosition()
user์˜ ์œ„์น˜(geolocation)๋ฅผ ์ผœ์ค€๋‹ค. 
์„ฑ๊ณตํ–ˆ์„ ๋•Œ ์‹คํ–‰๋  ํ•จ์ˆ˜
์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ์‹คํ–‰๋  ํ•จ์ˆ˜

 

 

 

API ๋ž€?

application programming interface

 

ํ”„๋กœ๊ทธ๋žจ๋“ค์ด ์„œ๋กœ ์†Œํ†ตํ•˜๋Š” ๋ฐฉ๋ฒ• / ์ฝ”๋“œ๋“ค๋ผ๋ฆฌ ์„œ๋กœ ์†Œํ†ตํ•˜๊ธฐ ์œ„ํ•ด ๋งŒ๋“ค์–ด์ง„ ๊ฒƒ

 

๊ณต๊ณต API 

๋‚ ์”จ API 

๊ฐ ์–ดํ”Œ๋“ค์˜ API 

๊ณผ๊ฑฐ ๋‚ ์”จ API 

๊ณต๊ธฐ ์˜ค์—ผ API 

 

API ๋Š” ๋ฐ์ดํ„ฐ, ์„œ๋ฒ„๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ๋“ค์ด ์›ํ•˜๋Š”๋Œ€๋กœ ๋””์ž์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋ž˜์„œ ์–ด๋–ค API๋Š” ์ ‘๊ทผ๊ถŒํ•œ์ด ์ •ํ•ด์ ธ์žˆ๋‹ค. ๊ฐ€๋”์€ API ์‚ฌ์šฉ์— ์ œ์•ฝ์ด ์žˆ๊ฑฐ๋‚˜, ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ง€๋ถˆํ•ด์•ผํ• ๋•Œ๋„ ์žˆ๋‹ค. 

 

web API = ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์œ„ํ•ด ๋งŒ๋“  API. ex) ๊ตฌ๊ธ€ ํฌ๋กฌ, ํŒŒ์ด์–ดํญ์Šค ๋“ฑ๋“ฑ

 

 


<API ๊ณ„์ • ์—ด๊ธฐ>

 

https://openweathermap.org/

 

ะกurrent weather and forecast - OpenWeatherMap

Leaving everything behind, people are fleeing conflict in Ukraine. They need shelter, food, and water. When you subscribe to our service, you can join us to help with donation of just of 20. Openweather will add 40 to each donation and send it to Disastrou

openweathermap.org

 

  1. ํšŒ์›๊ฐ€์ž…ํ•˜๊ธฐ Create New Account
  2. ์›ํ•˜๋Š” API doc ๊ฐ€์„œ ์ฃผ์†Œ ๋ณต์‚ฌํ•˜๊ธฐ

 

 

 

3. https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}

์ด ๋ถ€๋ถ„์„ ์›ํ•˜๋Š” ๊ฐ’์œผ๋กœ ๋„ฃ๊ธฐ

 

4. My API keys ์—์„œ  API key  ๋„ฃ๊ธฐ

 

5. ์˜จ๋„๋ฅผ ํ™”์”จ์—์„œ ์„ญ์”จ๋กœ ๋ฐ”๊พธ๊ธฐ

 

์ฃผ์†Œ ๋’ค์— &units=metric ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ๋œ๋‹ค.

https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}&units=metric

 


<์ฐธ๊ณ  - API ์„ค์ •์‹œ ํŽธํ•˜๊ฒŒ ํ•ด์ฃผ๋Š” ์„œ๋น„์Šค>

 

<ํฌ๋กฌํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ Json viewer

https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh/related?utm_source=chrome-ntp-icon 

 

JSON Viewer

The most beautiful and customizable JSON/JSONP highlighter that your eyes have ever seen. Open source at https://goo.gl/fmphc7

chrome.google.com

 

 

์˜ต์…˜์—์„œ ์›ํ•˜๋Š” ๊ธ€๊ผด, ๋ชจ์–‘์œผ๋กœ ์„ค์ •๋„ ๊ฐ€๋Šฅํ•ด์š”!

 

๋‹ค์šด๋ฐ›์œผ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ๋ณด๊ธฐ ์–ด๋ ค์šด ์ฝ”๋“œ๋ฅผ ์•„๋ž˜์ฒ˜๋Ÿผ ๋ณด๊ธฐ ํŽธํ•˜๊ฒŒ ๋ฐ”๊ฟ”์ค€๋‹ต๋‹ˆ๋‹ค!

 


10๋ถ„๋„ ๋˜์ง€ ์•Š๋Š” ๊ฐ•์˜๋ฅผ 1์‹œ๊ฐ„์ด ๋„˜๋„๋ก ๋ณด๊ณ  ๋˜ ๋ณด๊ณ  ์ดํ•ดํ•˜๋ฉด์„œ ๋“ฃ๊ณ , ๋“œ๋””์–ด ์˜ค๋Š˜ ์™„๊ฐ•ํ–ˆ๋‹ค!!

 

์‚ฌ์‹ค ์™„๊ฐ•์„ ํ–ˆ์ง€๋งŒ ์•„์ง ๋งŽ์ด ๋ถ€์กฑํ•˜๋‹ค. 

ํ˜ผ์ž ๋‚˜๋งŒ์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ์™„์„ฑ์‹œํ‚ค๋ฉฐ ํ•œ์นธ์”ฉ ์ฑ„์›Œ๋‚˜๊ฐˆ ๊ฒƒ์ด๋‹ค!

 

ํ™”์ดํŒ…!