신호정보 (제공)

신호정보 및 일자 별 이력을 제공합니다.

1. 신호정보 조회 API (GetSignalInfo)

요청 URL

https://service.mqnicrnd5.com/api/v1/rtsi/offer/gsi

연계 주기

요청 시

프로토콜

HTTPS

HTTP 메서드

GET

데이터 포맷

참고사항

API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.

> GET /api/v1/rtsi/offer/gsi?csrdId=1570063200 HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>

요청 예시

curl --location 'https://service.mqnicrnd5.com/api/v1/rtsi/offer/gsi?csrdId=1570063200' \
--header 'Authorization: Bearer <접근 토큰>'

응답 예시

{
    "results": [
        {
            "nodeId": "1570192600",
            "dttm": "20240617",
            "data": [
                {
                    "timestamp": "2024-06-17 10:52:33",
                    "phaseNo": 3,
                    "sigStatus": [
                        2
                    ],
                    "leftTime": [
                        4
                    ],
                    "pedestrian": []
                },
                {
                    "timestamp": "2024-06-17 10:52:37",
                    "phaseNo": 4,
                    "sigStatus": [
                        3
                    ],
                    "leftTime": [
                        25
                    ],
                    "pedestrian": []
                }
            ]
        }
    ]
}

2. 신호정보 이력 리스트 조회 API (GetSignalHistFilePath)

일자별로 압축한 압축 파일의 URI 리스트를 반환합니다.

요청 URL

https://service.mqnicrnd5.com/api/v1/rtsi/offer/gshf

연계 주기

요청 시

프로토콜

HTTPS

HTTP 메서드

GET

데이터 포맷

참고사항

API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.

> GET /api/v1/rtsi/offer/gshf?csrdId=1570063200 HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>

요청 예시

curl --location 'https://service.mqnicrnd5.com/api/v1/rtsi/offer/gshf?csrdId=1570195400' \
--header 'Authorization: Bearer <접근 토큰>'

응답 예시

{
    "results": [
        {
            "node_id": "1570195400",
            "uri": [
                {
                    "dttm": "20240613",
                    "filePath": "rtsi/1570195400/20240613/1570195400_rtsi_20240613.zip",
                },
                {
                    "dttm": "20240614",
                    "filePath": "rtsi/1570195400/20240614/1570195400_rtsi_20240614.zip",
                },
            ]
        },
    ]
}

3. 신호정보 이력 압축파일 제공 API (GetSignalHistData)

요청 URL

https://service.mqnicrnd5.com/api/v1/rtsi/offer/gshd

연계 주기

요청 시

프로토콜

HTTPS

HTTP 메서드

GET

데이터 포맷

참고사항

API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.

> GET /api/v1/rtsi/offer/gshd?filePath=rtsi/1570193000/20240613/1570193000_rtsi_20240613.zip HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>

요청 예시

curl --location 'https://service.mqnicrnd5.com/api/v1/rtsi/offer/gshd?filePath=rtsi/1570193000/20240613/1570193000_rtsi_20240613.zip' \
--header 'Authorization: Bearer <접근 토큰>'

응답 예시

추후 샘플 파일 업로드 예정입니다.

4. 신호정보 제공 API 구현 예제

다음은 각 언어별 실시간 신호정보 제공 API 구현 예제입니다.

신호정보 조회 API (GetSignalInfo)


import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.net.URL;

public class CallAPI {

    public static void main(String[] args) {
        String accessToken = "Bearer " + "<접근 토큰>";
        
        String csrdId = "1570062500,1570069937";
        Boolean pSignal = false;
        String stDttm = "202304011";
        String edDttm = "202304012";
                
        String apiURL = "https://service.mqnicrnd5.com/api/v1/rtsi/offer/gsi?"
                + "csrdId=" + csrdId + "&"
                + "pSignal=" + pSignal + "&"
                + "stDttm=" + stDttm + "&"
                + "edDttm=" + edDttm;

        Map<String, String> requestHeaders = new HashMap<>();
        requestHeaders.put("Authorization", accessToken);
        String responseBody = get(apiURL,requestHeaders);

        System.out.println(responseBody);
    }


    private static String get(String apiUrl, Map<String, String> requestHeaders) {
        HttpURLConnection con = connect(apiUrl);
        try {
            con.setRequestMethod("GET");
            for (Map.Entry<String, String> header : requestHeaders.entrySet()) {
                con.setRequestProperty(header.getKey(), header.getValue());
            }

            int responseCode = con.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) { // 정상 호출
                return readBody(con.getInputStream());
            } else { // 오류 발생
                return readBody(con.getErrorStream());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            con.disconnect();
        }
    }


    private static HttpURLConnection connect(String apiUrl) {
        try {
            URL url = new URL(apiUrl);
            return (HttpURLConnection) url.openConnection();
        } catch (MalformedURLException e) {
            throw new RuntimeException("API URL이 잘못되었습니다. : " + apiUrl, e);
        } catch (IOException e) {
            throw new RuntimeException("연결이 실패했습니다. : " + apiUrl, e);
        }
    }


    private static String readBody(InputStream body) {
        InputStreamReader streamReader = new InputStreamReader(body);


        try (BufferedReader lineReader = new BufferedReader(streamReader)) {
            StringBuilder responseBody = new StringBuilder();


            String line;
            while ((line = lineReader.readLine()) != null) {
                responseBody.append(line);
            }


            return responseBody.toString();
        } catch (IOException e) {
            throw new RuntimeException("API 응답을 읽는 데 실패했습니다.", e);
        }
    }

}

신호정보 이력 리스트 조회 API (GetSignalHistFilePath)


import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.net.URL;

public class CallAPI {

    public static void main(String[] args) {
        String accessToken = "Bearer " + "<접근 토큰>";
        
        String csrdId = "1570062500,1570069937";
        String stDttm = "202304011";
        String edDttm = "202304012";
                
        String apiURL = "https://service.mqnicrnd5.com/api/v1/rtsi/offer/gshf?"
                + "csrdId=" + csrdId + "&"
                + "stDttm=" + stDttm + "&"
                + "edDttm=" + edDttm;

        Map<String, String> requestHeaders = new HashMap<>();
        requestHeaders.put("Authorization", accessToken);
        String responseBody = get(apiURL,requestHeaders);

        System.out.println(responseBody);
    }


    private static String get(String apiUrl, Map<String, String> requestHeaders) {
        HttpURLConnection con = connect(apiUrl);
        try {
            con.setRequestMethod("GET");
            for (Map.Entry<String, String> header : requestHeaders.entrySet()) {
                con.setRequestProperty(header.getKey(), header.getValue());
            }

            int responseCode = con.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) { // 정상 호출
                return readBody(con.getInputStream());
            } else { // 오류 발생
                return readBody(con.getErrorStream());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            con.disconnect();
        }
    }


    private static HttpURLConnection connect(String apiUrl) {
        try {
            URL url = new URL(apiUrl);
            return (HttpURLConnection) url.openConnection();
        } catch (MalformedURLException e) {
            throw new RuntimeException("API URL이 잘못되었습니다. : " + apiUrl, e);
        } catch (IOException e) {
            throw new RuntimeException("연결이 실패했습니다. : " + apiUrl, e);
        }
    }


    private static String readBody(InputStream body) {
        InputStreamReader streamReader = new InputStreamReader(body);


        try (BufferedReader lineReader = new BufferedReader(streamReader)) {
            StringBuilder responseBody = new StringBuilder();


            String line;
            while ((line = lineReader.readLine()) != null) {
                responseBody.append(line);
            }


            return responseBody.toString();
        } catch (IOException e) {
            throw new RuntimeException("API 응답을 읽는 데 실패했습니다.", e);
        }
    }

}

신호정보 이력 압축파일 제공 API (GetSignalHistData)


import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.net.URL;

public class CallAPI {

    public static void main(String[] args) {
        String accessToken = "Bearer " + "<접근 토큰>";

        String filePath = "rtsi/1570193000/20240613/1570193000_rtsi_20240613.zip";

        String apiURL = "https://service.mqnicrnd5.com/api/v1/rtsi/offer/gshd?"
                + "filePath=" + filePath;

        Map<String, String> requestHeaders = new HashMap<>();
        requestHeaders.put("Authorization", accessToken);
        String responseBody = get(apiURL,requestHeaders);

        System.out.println(responseBody);
    }


    private static String get(String apiUrl, Map<String, String> requestHeaders) {
        HttpURLConnection con = connect(apiUrl);
        try {
            con.setRequestMethod("GET");
            for (Map.Entry<String, String> header : requestHeaders.entrySet()) {
                con.setRequestProperty(header.getKey(), header.getValue());
            }

            int responseCode = con.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_OK) { // 정상 호출
                return readBody(con.getInputStream());
            } else { // 오류 발생
                return readBody(con.getErrorStream());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            con.disconnect();
        }
    }


    private static HttpURLConnection connect(String apiUrl) {
        try {
            URL url = new URL(apiUrl);
            return (HttpURLConnection) url.openConnection();
        } catch (MalformedURLException e) {
            throw new RuntimeException("API URL이 잘못되었습니다. : " + apiUrl, e);
        } catch (IOException e) {
            throw new RuntimeException("연결이 실패했습니다. : " + apiUrl, e);
        }
    }


    private static String readBody(InputStream body) {
        InputStreamReader streamReader = new InputStreamReader(body);


        try (BufferedReader lineReader = new BufferedReader(streamReader)) {
            StringBuilder responseBody = new StringBuilder();


            String line;
            while ((line = lineReader.readLine()) != null) {
                responseBody.append(line);
            }


            return responseBody.toString();
        } catch (IOException e) {
            throw new RuntimeException("API 응답을 읽는 데 실패했습니다.", e);
        }
    }

}

Last updated