미시교통정보 (제공)
미시 교통정보 (소통정보, 회전교통량정보) 를 제공합니다.
1. 소통정보 조회 API (GetLaneLevelTrafficInfo)
요청 URL
https://service.mqnicrnd5.com/api/v1/traffic/offer/glti
연계 주기
요청 시 (정보 갱신 주기 추후 안내 예정)
프로토콜
HTTPS
HTTP 메서드
GET
데이터 포맷
참고사항
API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.
> GET /api/v1/traffic/offer/glti?locgovId=233&laneLevelNetworkType=2&linkIId=2330038601,2333031300&reqDttm=202408071021&aggregationMinutes=1 HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>
요청 예시
curl --location 'https://service.mqnicrnd5.com/api/v1/traffic/offer/glti?locgovId=233&laneLevelNetworkType=2&linkIId=2330038601,2333031300&reqDttm=202408071021&aggregationMinutes=1' \
--header 'Authorization: Bearer <접근 토큰>'
응답 예시
{
"laneLevelNetworkType": "2",
"dttm": "2025-02-10 12:05:00",
"aggregationMinutes": 1,
"laneLevelTrafficInfo": [
{
"linkId": "557630183_201_000061",
"minSpeed": 12.09,
"maxSpeed": 19.0,
"avgSpeed": 15.429833,
"stdSpeed": 3.45308,
"minVehicleCount": 0.0,
"maxVehicleCount": 1.0,
"avgVehicleCount": 0.516667,
"stdVehicleCount": 0.499722,
"minRatio": 70.876495,
"maxRatio": 99.628038
},
{
"linkId": "557630183_201_000142",
"minSpeed": 11.86,
"maxSpeed": 19.0,
"avgSpeed": 17.294,
"stdSpeed": 2.98221,
"minVehicleCount": 0.0,
"maxVehicleCount": 1.0,
"avgVehicleCount": 0.25,
"stdVehicleCount": 0.433013,
"minRatio": 0.473351,
"maxRatio": 97.454143
},
{
"linkId": "557630183_201_000197",
"minSpeed": 7.62,
"maxSpeed": 19.0,
"avgSpeed": 15.129056,
"stdSpeed": 3.458018,
"minVehicleCount": 0.0,
"maxVehicleCount": 2.0,
"avgVehicleCount": 0.85,
"stdVehicleCount": 0.792149,
"minRatio": 0.097617,
"maxRatio": 10.524431
},
{
"linkId": "557630183_201_000198",
"minSpeed": 7.97,
"maxSpeed": 19.0,
"avgSpeed": 17.878167,
"stdSpeed": 3.138064,
"minVehicleCount": 0.0,
"maxVehicleCount": 1.0,
"avgVehicleCount": 0.116667,
"stdVehicleCount": 0.321023,
"minRatio": 2.159346,
"maxRatio": 37.36488
},
{
"linkId": "557630194_201_000031",
"minSpeed": 14.23,
"maxSpeed": 19.0,
"avgSpeed": 16.532,
"stdSpeed": 2.236728,
"minVehicleCount": 0.0,
"maxVehicleCount": 3.0,
"avgVehicleCount": 0.733333,
"stdVehicleCount": 0.793025,
"minRatio": 21.814903,
"maxRatio": 99.997028
},
{
"linkId": "557630200_201_000026",
"minSpeed": 14.23,
"maxSpeed": 16.0,
"avgSpeed": 15.845,
"stdSpeed": 0.386685,
"minVehicleCount": 0.0,
"maxVehicleCount": 1.0,
"avgVehicleCount": 0.166667,
"stdVehicleCount": 0.372678,
"minRatio": 38.348948,
"maxRatio": 99.957391
},
{
"linkId": "557630200_201_000027",
"minSpeed": 14.23,
"maxSpeed": 16.0,
"avgSpeed": 15.678847,
"stdSpeed": 0.648662,
"minVehicleCount": 0.0,
"maxVehicleCount": 2.0,
"avgVehicleCount": 0.283333,
"stdVehicleCount": 0.608048,
"minRatio": 3.162231,
"maxRatio": 96.020519
}
]
}
2. 회전교통량 조회 API (GetTurnTrafficInfo)
요청 URL
https://service.mqnicrnd5.com/api/v1/traffic/offer/gtti
연계 주기
요청 시 (정보 갱신 주기 추후 안내 예정)
프로토콜
HTTPS
HTTP 메서드
GET
데이터 포맷
참고사항
API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.
> GET /api/v1/traffic/offer/gtti?locgovId=233&intersectionNetworkType=2&intersectionId=2330296200&reqDttm=202408080945&aggregationMinutes=15 HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>
요청 예시
curl --location 'https://service.mqnicrnd5.com/api/v1/traffic/offer/gtti?locgovId=233&intersectionNetworkType=2&intersectionId=2330296200&reqDttm=202408080945&aggregationMinutes=15' \
--header 'Authorization: Bearer <접근 토큰>'
응답 예시
{
"intersectionNetworkType": "2",
"dttm": "2024-08-08 09:45:00",
"aggregationMinutes": 15,
"turnTrafficInfo": [
{
"intersectionId": "2330296200",
"entryLinkId": "2333055308",
"exitLinkId": "2333055305",
"counter": 3
},
{
"intersectionId": "2330296200",
"entryLinkId": "2333055308",
"exitLinkId": "2334349301",
"counter": 4
},
{
"intersectionId": "2330296200",
"entryLinkId": "2333055406",
"exitLinkId": "2333913701",
"counter": 1
},
{
"intersectionId": "2330296200",
"entryLinkId": "2333055406",
"exitLinkId": "2333055407",
"counter": 1
},
{
"intersectionId": "2330296200",
"entryLinkId": "2333913802",
"exitLinkId": "2333055305",
"counter": 2
}
]
}
3. 미시교통정보 제공 API 구현 예제
다음은 각 언어별 미시교통정보 제공 API 구현 예제입니다.
소통정보 조회 API (GetLaneLevelTrafficInfo)
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 locgovId = "11110";
String laneLevelNetworkType = "1";
String linkIId = "3920212600";
String reqDttm = "202304012050";
int aggregationMinutes = 5;
String apiURL = "https://service.mqnicrnd5.com/api/v1/traffic/offer/glti?"
+ "locgovId=" + locgovId + "&"
+ "laneLevelNetworkType=" + laneLevelNetworkType + "&"
+ "linkIId=" + linkIId + "&"
+ "reqDttm=" + reqDttm + "&"
+ "aggregationMinutes=" + aggregationMinutes;
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 (GetTurnTrafficInfo)
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 locgovId = "11110";
String intersectionNetworkType = "1";
String intersectionId = "3920212600";
String reqDttm = "202304012050";
int aggregationMinutes = 5;
String apiURL = "https://service.mqnicrnd5.com/api/v1/traffic/offer/gtti?"
+ "locgovId=" + locgovId + "&"
+ "intersectionNetworkType=" + intersectionNetworkType + "&"
+ "intersectionId=" + intersectionId + "&"
+ "reqDttm=" + reqDttm + "&"
+ "aggregationMinutes=" + aggregationMinutes;
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