[KT AIVLE SCHOOL - 6기 기자단] CCTV API사용하기

2025. 2. 25. 13:44·KT AIVLE School/프로젝트

 

 

ITS(지능형교통체계) 국가교통정보센터에서는 CCTV 화상정보를 API로 제공한다.

이를 활용하여 실시간 교통 상황을 확인할 수 있다.

 

1. API 신청 및 발급

  • ITS 국가교통정보센터 회원가입을 진행한다.

https://www.its.go.kr/opendata/opendataList?service=cctv

 

ITS 국가교통정보센터

ITS 국가교통정보센터

its.go.kr

 

2. API 사용 신청

  • 오픈데이터 목록 확인

 

 

  • 인증키 신청 버튼

 

  • 인증키 발급 신청 진행

 

3. API키 사용

  • 마이페이지에서 승인여부를 확인할 수 있다.

  • 요청변수와 출력변수를 확인한다.

 

  • 샘플코드를 참고하여 활용할 수 있었고 예제 실행을 통해서 API가 잘 작동하는지 확인해볼 수 있었다. 

 

/* Java 샘플 코드 */


import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.io.BufferedReader;
import java.io.IOException;

public class ApiExplorer {
 public static void main(String[] args) throws IOException {
  StringBuilder urlBuilder = new StringBuilder("https://openapi.its.go.kr:9443/cctvInfo"); /*URL*/
  urlBuilder.append("?" + URLEncoder.encode("apiKey", "UTF-8") + "=" + URLEncoder.encode("test", "UTF-8")); /*공개키*/
  urlBuilder.append("&" + URLEncoder.encode("type","UTF-8") + "=" + URLEncoder.encode("all", "UTF-8")); /*도로유형*/
  urlBuilder.append("&" + URLEncoder.encode("cctvType","UTF-8") + "=" + URLEncoder.encode("1", "UTF-8")); /*CCTV유형*/
  urlBuilder.append("&" + URLEncoder.encode("minX","UTF-8") + "=" + URLEncoder.encode("126.800000", "UTF-8")); /*최소경도영역*/
  urlBuilder.append("&" + URLEncoder.encode("maxX","UTF-8") + "=" + URLEncoder.encode("127.890000", "UTF-8")); /*최대경도영역*/
  urlBuilder.append("&" + URLEncoder.encode("minY","UTF-8") + "=" + URLEncoder.encode("34.900000", "UTF-8")); /*최소위도영역*/
  urlBuilder.append("&" + URLEncoder.encode("maxY","UTF-8") + "=" + URLEncoder.encode("35.100000", "UTF-8")); /*최대위도영역*/
  urlBuilder.append("&" + URLEncoder.encode("getType","UTF-8") + "=" + URLEncoder.encode("xml", "UTF-8")); /*출력타입*/
  URL url = new URL(urlBuilder.toString());
  HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("GET");
  conn.setRequestProperty("Content-type", "text/xml;charset=UTF-8");
  System.out.println("Response code: " + conn.getResponseCode());
  BufferedReader rd;
  if(conn.getResponseCode() >= 200 && conn.getResponseCode() <= 300) {
   rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  } else {
   rd = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
  }
  StringBuilder sb = new StringBuilder();
  String line;
  while ((line = rd.readLine()) != null) {
   sb.append(line);
  }
  rd.close();
  conn.disconnect();
  System.out.println(sb.toString());
 }
}

 

'KT AIVLE School > 프로젝트' 카테고리의 다른 글

[KT AIVLE SCHOOL - 6기 기자단] OpenWeatherMap API사용하기  (0) 2025.02.25
[KT AIVLE SCHOOL - 6기 기자단] 빅프로젝트 후기  (0) 2025.02.25
응급상황 인식 및 응급실 연계 서비스 포탈  (7) 2024.12.26
Colab에서 음성파일 만들기  (0) 2024.11.19
미니 프로젝트 2차 후기  (6) 2024.10.09
'KT AIVLE School/프로젝트' 카테고리의 다른 글
  • [KT AIVLE SCHOOL - 6기 기자단] OpenWeatherMap API사용하기
  • [KT AIVLE SCHOOL - 6기 기자단] 빅프로젝트 후기
  • 응급상황 인식 및 응급실 연계 서비스 포탈
  • Colab에서 음성파일 만들기
Rabet
Rabet
  • 블로그 메뉴

    • 관리자
    • 글쓰기
  • Rabet
    卯
    Rabet
  • 전체
    오늘
    어제
    • Root (141)
      • KT AIVLE School (85)
        • Start (4)
        • Python프로그래밍 & 라이브러리 (6)
        • 데이터 처리 및 분석 (7)
        • 데이터 분석 및 의미 찾기 (7)
        • 웹크롤링 (10)
        • 머신러닝 (10)
        • 딥러닝 (6)
        • 시각지능 딥러닝 (10)
        • 언어지능 딥러닝 (6)
        • JAVA (4)
        • SQL (2)
        • 가상화 클라우드 (5)
        • 프로젝트 (8)
      • QA (3)
        • 오류사항 (1)
      • 웹공부 (14)
        • SPRING (11)
        • React (1)
      • 코딩 알고리즘 스터디 (23)
      • 코딩테스트 (9)
        • JAVA (8)
        • HTML (1)
      • CS공부 (3)
      • 자격증공부 (4)
        • 정보처리기사 (1)
        • 컴퓨터활용능력 1급 (1)
        • AICE Associate (1)
        • ISTQB (1)
  • 인기 글

  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.2
Rabet
[KT AIVLE SCHOOL - 6기 기자단] CCTV API사용하기
상단으로

티스토리툴바