728x90
반응형
미니 프로젝트로 만드는 웹 페이지에 이것저것 추가하다가 날씨 정보를 불러오고 싶었다. 다양한 방법을 찾아보다 날씨 정보를 무료 API로 받아 올 수 있는 Open Weather 사이트를 이용해 보았다.
날씨 API를 받아오는 방법
1.Key 발급
해당 사이트 로그인 후 나의 계정 My API Keys에 들어가면 발급 된 Key가 보일 것이다. (Key는 따로 메모해둔다)
2. Current Weather Data
상단 카테고리 중 API 로 들어간다. 아래로 내려가면 Current Weather Data가 보일 것이다. 아래 API doc을 클릭한다.
3. Json 호출
API doc에 들어가서 아래로 내려가다 보면 아래와 같은 링크가 있다.
https://api.openweathermap.org/data/2.5/weather?q={city name}&appid={API key}
{city name}에 날씨를 알고 싶은 도시(ex. seoul, london 등) 를 넣고 {API key]에는 자신의 key(1번 내용)를 넣어서 주소를 입력하면 Json형식으로 현재의 날씨정보을 알려준다.
날씨 API 활용
받아온 날씨 API를 이용해 날씨를 검색해 볼 수 있는 웹을 구현해 보았다. 도시명을 입력하면 기본값인 Gwangju 옆으로 검색한 도시의 날씨가 보여진다.
728x90
반응형
'Digital Boot' 카테고리의 다른 글
[Python] 고객 정보 관리 프로그램 만들기 실습 2 (1) | 2023.11.07 |
---|---|
[Python] 고객 정보 관리 프로그램 만들기 실습 1 (0) | 2023.11.06 |
[Spring Boot] Project - 미니 게임 만들기 (0) | 2023.11.01 |
Project Report (1) | 2023.10.30 |
[React] 가위바위보 게임 만들기 (0) | 2023.09.07 |