[project] 미니프로젝트 03/05 API란? CSV파일?

kafa·2023년 3월 7일
0

프로젝트

목록 보기
4/6

나중에 api를 써야하는데 난 api가 뭔지 모른다.


API란?

API는 정의 및 프로토콜 집합을 사용하여 두 소프트웨어 구성 요소가 서로 통신할 수 있게 하는 메커니즘이다.
예를 들어, 기상청의 소프트웨어 시스템에는 일일 기상 데이터가 들어 있는데 휴대폰의 날씨 앱은 API를 통해 이 시스템과 ‘대화’하여 휴대폰에 매일 최신 날씨 정보를 표시할 수 있다.

API 아키텍처는 일반적으로 클라이언트와 서버 측면에서 설명 할 수 있다. 요청을 보내는 애플리케이션을 클라이언트라고 하고, 응답을 보내는 애플리케이션을 서버라고 한다.
따라서 날씨 예에서 기상청의 날씨 데이터베이스는 서버이고 모바일 앱은 클라이언트이다.

웹 API란?

웹 API 또는 웹 서비스 API는 웹 서버와 웹 브라우저 간의 애플리케이션 처리 인터페이스를 말한다. 모든 웹 서비스는 API이지만 모든 API가 웹 서비스는 아니다.

역사적으로 API가 월드 와이드 웹 전에 만들어졌기 때문에 Java API, 서비스 API 등 API에 대한 다양한 용어가 존재한다. 최신 웹 API는 REST API이며 용어는 서로 바꿔 사용할 수 있다.

API 자료 출처 : 아마존aws


우리 프로젝트의 최종적인 목표는 자바를 이용해 웹페이지를 만드는 것이다. 따라서 웹에 적용 가능한 자료가 아니면 사용할 수 없다.

data.go.kr

CSV 기상청_단기예보 에서 자료를 찾을 수 있었다.

{"name":"기상청_단기예보","description":"예보기간과 구역을 시공간적으로 세분화하여 발표하는 자료로 3시간 간격으로 발표합니다. 단기예보는 예보시점부터 3일 이내 기간에 대하여 행하는 예보로, 전국의 읍,면,동 단위로 상세한 날씨를 예보하기 위하여 2시부터 3시간 간격으로 일 8회 발표하며, 예보시간은 +4시간부터 +58~67시간까지 생산됩니다.","url":"https://www.data.go.kr/data/15043494/fileData.do","keywords":["동네예보,날씨,중기예보"],"license":"https://data.go.kr/ugs/selectPortalPolicyView.do","dateCreated":"2020-06-29","dateModified":"2021-07-26","datePublished":"2020-06-29","creator":{"name":"기상청","contactPoint":{"contactType":"국가기후데이터센터","telephone":"+82-0424817480","@type":"ContactPoint"},"@type":"Organization"},"distribution":[{"encodingFormat":"CSV","contentUrl":"https://data.kma.go.kr/data/rmt/rmtList.do?code=420&pgmNo=572","@type":"DataDownload"}],"@context":"https://schema.org","@type":"Dataset"}

예 ?

한편 위의 페이지를 뒤져보니
기상청 기상자료개방포털 단기예보 - 파일셋에 지역별 예보유형별 자료를 받을 수 있었다.

근데 여긴 문제가 있었다.

기상청 단기예보 파일셋에서 자료를 조회했는데 다음과 같이 떴다. 예보는 조회할 수 없는걸까.

CSV

CSV(comma-separated values)는 몇 가지 필드를 쉼표(,)로 구분한 텍스트 데이터 및 텍스트 파일이다. 확장자는 .csv이며 MIME 형식은 text/csv이다.

csv파일을 파싱해서 db에 저장하는 법

Importing CSV Data to JFrame

스키마

스키마란?

DCAT

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<rdf:RDF xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcat="http://www.w3.org/ns/dcat#" xmlns:vcard="http://www.w3.org/2006/vcard/ns#">
<dcat:Catalog>
<dcat:dataset>
<dcat:Dataset>
<dcat:contactPoint>
<vcard:Individual>
<vcard:hasTelephone rdf:resource="tel:0424817480"/>
</vcard:Individual>
</dcat:contactPoint>
<dct:description xml:lang="kr">예보기간과 구역을 시공간적으로 세분화하여 발표하는 자료로 3시간 간격으로 발표합니다. 단기예보는 예보시점부터 3일 이내 기간에 대하여 행하는 예보로, 전국의 읍,면,동 단위로 상세한 날씨를 예보하기 위하여 2시부터 3시간 간격으로 일 8회 발표하며, 예보시간은 +4시간부터 +58~67시간까지 생산됩니다.</dct:description>
<dct:description xml:lang="en">The forecast period and area are subdivided into time and space, and are announced every three hours. The short-term forecast is a forecast for a period within 3 days from the time of the forecast, and is announced 8 times a day every 3 hours from 2 o&#39;clock in order to forecast detailed weather for each town, village, and dong nationwide, and the forecast time is +4 hours. From +58 to 67 hours.</dct:description>
<dct:title xml:lang="kr">기상청_단기예보</dct:title>
<dct:title xml:lang="en">Meteorological Administration_Short-term forecast</dct:title>
<dct:issued rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2020-06-29 14:55:16.000</dct:issued>
<dct:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2021-07-26 14:32:39.000</dct:modified>
<dct:publisher>
<foaf:Organization>
<foaf:name>기상청</foaf:name>
</foaf:Organization>
</dct:publisher>
<dcat:theme>과학기술</dcat:theme>
<dcat:keyword xml:lang="kr">동네예보,날씨,중기예보</dcat:keyword>
<dcat:keyword xml:lang="en">Neighborhood forecast, weather, medium-term forecast</dcat:keyword>
<dct:rights>저작자표시</dct:rights>
<dct:accrualPeriodicity>수시</dct:accrualPeriodicity>
</dcat:Dataset>
</dcat:dataset>
</dcat:Catalog>
</rdf:RDF>

DCAT-RDF 파일 생성
RDF Eclipse Apache Jena 다운로드 및 사용법


날씨api비교
기상청과 sk에서 제공하는 날씨api, 국제날씨를 제공하는 api 3가지를 비교했다.


아 걍 저때 프레임이나 할껄 :)
해당일로부터 이틀 후인 현재, 후회 중:)

profile
kafa is kafa. not be something other.

0개의 댓글