海冰警报
获取国家海洋预报台发布的海冰灾害预警信息
接口地址
https://api.foreocean.com/warning/seaIce
请求方式
GET
请求参数说明
参数名称 | 类型 | 是否必须 | 备注 |
---|---|---|---|
Token | String | 是 | API 调用令牌,您申请应用的 Token,放在请求头中 |
请求示例
java
public static void main(String[] args) {
Map<String, Object> params = new HashMap<>(16);
String requestUrl = "https://api.foreocean.com/warning/seaIce";
String response = get(requestUrl, params);
System.out.println(response);
}
public static String get(String url, Map<String, Object> params) {
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
url = url + "?";
for (Iterator<String> iterator = params.keySet().iterator(); iterator.hasNext();) {
String key = iterator.next();
String temp = key + "=" + params.get(key) + "&";
url = url + temp;
}
url = url.substring(0, url.length() - 1);
HttpGet httpGet = new HttpGet(url);
httpGet.addHeader("Token","API调用令牌");
CloseableHttpResponse response = httpClient.execute(httpGet);
try {
HttpEntity entity = response.getEntity();
if (entity != null) {
String str = EntityUtils.toString(entity, CHARSET);
return str;
}
} finally {
response.close();
httpClient.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
python
import requests
if __name__ == '__main__':
url = 'https://api.foreocean.com/warning/seaIce'
headers = {'Token': 'API调用令牌'}
params = {}
response = requests.get(url, headers=headers, params=params)
print(response.text)
返回结果示例
{
"code": "1000", //响应码, 1000-处理成功,其他代码说明请参考API返回错误代码说明
"data": {
"title": "海冰Ⅳ级警报(蓝色)", //警报标题
"warningLevel": "1", //警报级别, 0表示Ⅴ级消息无警报,1 表示Ⅳ级蓝色警报,2 表示Ⅲ级黄色警报,3 表示Ⅱ级橙色警报,4 表示Ⅰ级红色警报
"releaseDate": "2018-02-08 16:00:00", //发布时间
"updateDate": "2018-05-22 18:01:45", //更新时间
"validity": "72h", //预报时效
"content": "国家海洋预报台根据发布辽东湾海冰Ⅳ级警报(蓝色)... ", //警报内容
"geom": { //警报落区
"features": [{
"geometry": {
"coordinates": [
[经纬度数组]
],
"type": "MultiPolygon"
},
"type": "Feature",
"properties": {
"IceT": "5-15", //冰层厚度
"MaxIceT": "25" //最大冰层厚度
}
}],
"crs": {
"type": "name",
"properties": {
"name": "CRS:84"
}
},
"type": "FeatureCollection"
}
},
"msg": "success", //返回信息描述
"success": true //请求是否成功,true-成功,false-失败
}