신호마스터정보 (제공)
신호 정보 활용을 위한 마스터 정보를 제공합니다.
Last updated
신호 정보 활용을 위한 마스터 정보를 제공합니다.
Last updated
https://service.mqnicrnd5.com/api/v1/signal/offer/gnl
요청 시
HTTPS
GET
API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.
> GET /api/v1/signal/offer/gnl?regionCd=L01 HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>
curl --location 'https://service.mqnicrnd5.com/api/v1/signal/offer/gnl?regionCd=L01' \
--header 'Authorization: Bearer <접근 토큰>'
{
"results": [
{
"nodeId": "1570063200",
"nodeName": "산전교차로",
"latitude": "35.6636009575",
"longitude": "128.417414916"
}
]
}
https://service.mqnicrnd5.com/api/v1/signal/offer/gsmi
요청 시
HTTPS
GET
API를 요청할 때 다음 예와 같이 HTTP 요청 헤더에 접근 토큰(Access Token) 을 추가해야 합니다. 접근 토큰 앞에 "Bearer " 문자열을 추가해야 한다는 점에 주의하세요.
> GET /api/v1/signal/offer/gsmi?regionCd=L29&nodeId=1570063200 HTTP/2
> Host: service.mqnicrnd5.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <접근 토큰>
curl --location 'https://service.mqnicrnd5.com/api/v1/signal/offer/gsmi?regionCd=L29&nodeId=1570063200' \
--header 'Authorization: Bearer <접근 토큰>'
{"results": [
{
"regionCd": "L29",
"data": [
{
"nodeId": "1570195600",
"phase": [
{
"phaseNo": 1,
"linkId": [
"A219AR130866",
"A219AR130863",
"A219AR130862",
"A219AR130861",
"A219AR130860",
"A219AR130868",
"A219AR130867",
"A219AR130865",
"A219AR130864"
],
"sbId": "sb_ss",
"sbAngle": 180
},
{
"phaseNo": 2,
"linkId": [
"A219AR130867",
"A219AR130866",
"A219AR130865",
"A219AR130864",
"A219AR130868"
],
"sbId": "sb_l",
"sbAngle": 0
},
{
"phaseNo": 3,
"linkId": [
"A219AR130870",
"A219AR130869"
],
"sbId": "sb_l",
"sbAngle": 90
}
},
]
}
},
]}
다음은 각 언어별 신호 마스터 정보 제공 API 구현 예제입니다.
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 regionCd = "L29";
String apiURL = "https://service.mqnicrnd5.com/api/v1/signal/offer/gnl?"
+ "regionCd=" + regionCd;
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);
}
}
}
import requests
import json
def send_get_request():
accessToken = "Bearer " + "<접근 토큰>"
regionCd = "L29"
apiURL = "https://service.mqnicrnd5.com/api/v1/signal/offer/gnl?" \
+ "regionCd=" + str(regionCd)
headers = {
"Authorization": accessToken
}
response = requests.get(apiURL, headers=headers)
print("GET Request:")
print("Response Code:", response.status_code)
print("Response:", response.text)
if __name__ == "__main__":
send_get_request()
const https = require('https');
function main() {
const accessToken = "Bearer <접근 토큰>";
const regionCd = "L29";
const apiURL = `https://service.mqnicrnd5.com/api/v1/signal/offer/gnl?regionCd=${regionCd}`;
const headers = {
'Authorization': accessToken
};
get(apiURL, headers)
.then(responseBody => {
console.log(responseBody);
})
.catch(error => {
console.error('Error:', error);
});
}
function get(apiURL, headers) {
return new Promise((resolve, reject) => {
const options = {
headers: headers
};
https.get(apiURL, options, response => {
let data = '';
response.on('data', chunk => {
data += chunk;
});
response.on('end', () => {
resolve(data);
});
}).on('error', error => {
reject(error);
});
});
}
main();
using System;
using System.IO;
using System.Net;
using System.Text;
class Program
{
static void Main(string[] args)
{
string accessToken = "Bearer <접근 토큰>";
string regionCd = "L29";
string apiURL = $"https://service.mqnicrnd5.com/api/v1/signal/offer/gnl?regionCd={regionCd}";
string responseBody = Get(apiURL, accessToken);
Console.WriteLine(responseBody);
}
static string Get(string apiUrl, string accessToken)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
request.Method = "GET";
request.Headers["Authorization"] = accessToken;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
return reader.ReadToEnd();
}
}
catch (WebException e)
{
using (WebResponse response = e.Response)
using (Stream dataStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(dataStream))
{
string errorResponse = reader.ReadToEnd();
throw new Exception($"Error occurred: {errorResponse}", e);
}
}
}
}
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 regionCd = "L29";
String nodeId = "1570063200";
String apiURL = "https://service.mqnicrnd5.com/api/v1/signal/offer/gsmi?"
+ "regionCd=" + regionCd + "&"
+ "nodeId=" + nodeId;
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);
}
}
}
import requests
import json
def send_get_request():
accessToken = "Bearer " + "<접근 토큰>"
regionCd = "L29"
nodeId = "1570063200"
apiURL = "https://service.mqnicrnd5.com/api/v1/signal/offer/gsmi?" \
+ "regionCd=" + str(regionCd) + "&" \
+ "nodeId=" + str(nodeId)
headers = {
"Authorization": accessToken
}
response = requests.get(apiURL, headers=headers)
print("GET Request:")
print("Response Code:", response.status_code)
print("Response:", response.text)
if __name__ == "__main__":
send_get_request()
const https = require('https');
function main() {
const accessToken = "Bearer <접근 토큰>";
const regionCd = "L29";
const nodeId = "1570063200";
const apiURL = `https://service.mqnicrnd5.com/api/v1/signal/offer/gsmi?regionCd=${regionCd}&nodeId=${nodeId}`;
const headers = {
'Authorization': accessToken
};
get(apiURL, headers)
.then(responseBody => {
console.log(responseBody);
})
.catch(error => {
console.error('Error:', error);
});
}
function get(apiURL, headers) {
return new Promise((resolve, reject) => {
const options = {
headers: headers
};
https.get(apiURL, options, response => {
let data = '';
response.on('data', chunk => {
data += chunk;
});
response.on('end', () => {
resolve(data);
});
}).on('error', error => {
reject(error);
});
});
}
main();
using System;
using System.IO;
using System.Net;
using System.Text;
class Program
{
static void Main(string[] args)
{
string accessToken = "Bearer <접근 토큰>";
string regionCd = "L29";
string nodeId = "1570063200";
string apiURL = $"https://service.mqnicrnd5.com/api/v1/signal/offer/gsmi?regionCd={regionCd}&nodeId={nodeId}";
string responseBody = Get(apiURL, accessToken);
Console.WriteLine(responseBody);
}
static string Get(string apiUrl, string accessToken)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
request.Method = "GET";
request.Headers["Authorization"] = accessToken;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
return reader.ReadToEnd();
}
}
catch (WebException e)
{
using (WebResponse response = e.Response)
using (Stream dataStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(dataStream))
{
string errorResponse = reader.ReadToEnd();
throw new Exception($"Error occurred: {errorResponse}", e);
}
}
}
}