|
API简单一点说就是接口,现在很多公司、企业的应用系统都有开放的接口,供其他应用系统、软件使用自己系统的功能。也就是说,如果我想开发一个软件,有些功能就不用自己开发,只需要接入其它公司的API接口,调用相关功能就ok。
现在开放的API接口非常丰富,有收费的,也有免费的。为了方便各类开发者,现提供免费开放Api接口,所有接口均无使用限制,返回格式全是JSON,所以基本能满足大家的开发需求。
查询统计类接口api:
快递查询:http://www.kdniao.com/api-track
创建应用接口https://www.apiopen.top/createUserKey?appId=com.chat.peakchao&passwd=123456
增加统计信息接口https://www.apiopen.top/addStatistics?appKey=00d91e8e0cca2b76f515926a36db68f5&type=点击统计&typeId=1&count=2
查询统计信息接口https://www.apiopen.top/findStatistics?appKey=00d91e8e0cca2b76f515926a36db68f5
用户注册接口https://www.apiopen.top/createUser?key=00d91e8e0cca2b76f515926a36db68f5&phone=13594347817&passwd=123654
用户登陆接口https://www.apiopen.top/login?key=00d91e8e0cca2b76f515926a36db68f5&phone=13594347817&passwd=123456
诗词歌语音视频类接口api:
随机单句诗词推荐:https://api.apiopen.top/singlePoetry
随机一首诗词推荐:https://api.apiopen.top/recommendPoetry
搜索古诗词:https://api.apiopen.top/searchPoetry?name=古风二首%20二
搜索古诗词作者:https://api.apiopen.top/searchAuthors?name=李白
模糊搜索古诗词(可搜索诗词名、诗词内容、诗词作者):https://api.apiopen.top/likePoetry?name=李白
获取宋朝古诗词:https://api.apiopen.top/getSongPoetry?page=1&count=20
获取唐朝古诗词:https://api.apiopen.top/getTangPoetry?page=1&count=20
新实时段子 https://api.apiopen.top/getJoke?page=1&count=2&type=video
通过Id查段子 https://api.apiopen.top/getSingleJoke?sid=28654780
快递查询:https://api.apiopen.top/EmailSearch?number=1012002
随机单句诗词推荐:https://api.apiopen.top/singlePoetry
随机一首诗词推荐:https://api.apiopen.top/recommendPoetry
搜索古诗词:https://api.apiopen.top/searchPoetry?name=古风二首%20二
搜索古诗词作者:https://api.apiopen.top/searchAuthors?name=李白
模糊搜索古诗词(可搜索诗词名、诗词内容、诗词作者):https://api.apiopen.top/likePoetry?name=李白
获取宋朝古诗词:https://api.apiopen.top/getSongPoetry?page=1&count=20
获取唐朝古诗词:https://api.apiopen.top/getTangPoetry?page=1&count=20
音乐搜索接口:https://api.apiopen.top/searchMusic?name=不要说话
音乐电台接口:https://api.apiopen.top/musicBroadcasting
音乐电台详情接口:https://api.apiopen.top/musicBroadcastingDetails?channelname=public_tuijian_spring
音乐详情接口:https://api.apiopen.top/musicDetails?id=604392760
音乐排行榜接口:https://api.apiopen.top/musicRankings
音乐排行榜详情接口:https://api.apiopen.top/musicRankingsDetails?type=1
每日视频推荐接口:https://api.apiopen.top/todayVideo
视频大纲获取接口:https://api.apiopen.top/videoHomeTab
视频分类推荐接口:https://api.apiopen.top/videoCategory
视频分类推荐接口:https://api.apiopen.top/videoCategoryDetails?id=14
根据ID推荐接口:https://api.apiopen.top/videoRecommend?id=127398
新闻接口:https://www.apiopen.top/journalismApi
随机推荐热门段子(包含文字、图片、GIF、视频):https://www.apiopen.top/satinApi?type=1&page=1
随机推荐热门段子【神评版本】(包含文字、图片、GIF、视频):https://www.apiopen.top/satinGodApi?type=1&page=1
随机推荐热门段子【神评版本】评论列表:https://www.apiopen.top/satinCommentApi?id=27610708&page=1
热门小说推荐列表 https://www.apiopen.top/novelApi
小说搜索接口 https://www.apiopen.top/novelSearchApi?name=盗墓笔记
小说详情接口 https://www.apiopen.top/novelInfoApi?name=盗墓笔记
天气获取接口 https://www.apiopen.top/weatherApi?city=成都
美图获取接口 https://www.apiopen.top/meituApi?page=1
个性网名获取接口 https://www.apiopen.top/femaleNameApi?page=1
快递物流接口demo:
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.UnsupportedEncodingException;import java.net.HttpURLConnection;import java.net.URL;import java.net.URLEncoder;import java.security.MessageDigest;import java.util.HashMap;import java.util.Map;
/** * * 单日超过500单查询量,建议接入物流轨迹订阅推送接口 * */
publicclass KdniaoTrackQueryAPI {//DEMOpublicstaticvoid main(String[] args) { KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI();try {String result = api.getOrderTracesByJson("ANE", "210001633605"); System.out.print(result); } catch (Exception e) { e.printStackTrace(); } }//电商IDprivateString EBusinessID="申请";//电商加密私钥,注意保管,不要泄漏privateString AppKey="申请";//请求urlprivateString ReqURL="http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx"; /** * Json方式 查询订单物流轨迹 * @throws Exception */publicString getOrderTracesByJson(String expCode, String expNo) throws Exception{String requestData= "{'OrderCode':'','ShipperCode':'" + expCode + "','LogisticCode':'" + expNo + "'}"; Map<String, String> params = new HashMap<String, String>(); params.put("RequestData", urlEncoder(requestData, "UTF-8")); params.put("EBusinessID", EBusinessID); params.put("RequestType", "1002");String dataSign=encrypt(requestData, AppKey, "UTF-8"); params.put("DataSign", urlEncoder(dataSign, "UTF-8")); params.put("DataType", "2");String result=sendPost(ReqURL, params); //根据公司业务处理返回的信息......return result; }/** * MD5加密 * @param str 内容 * @param charset 编码方式 * @throws Exception */@SuppressWarnings("unused")privateString MD5(String str, String charset) throws Exception { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(str.getBytes(charset)); byte[] result = md.digest(); StringBuffer sb = new StringBuffer(32);for (int i = 0; i < result.length; i++) { int val = result & 0xff;if (val <= 0xf) { sb.append("0"); } sb.append(Integer.toHexString(val)); }return sb.toString().toLowerCase(); }/** * base64编码 * @param str 内容 * @param charset 编码方式 * @throws UnsupportedEncodingException */privateString base64(String str, String charset) throws UnsupportedEncodingException{String encoded = base64Encode(str.getBytes(charset));return encoded; } @SuppressWarnings("unused")privateString urlEncoder(String str, String charset) throws UnsupportedEncodingException{String result = URLEncoder.encode(str, charset);return result; }/** * 电商Sign签名生成 * @param content 内容 * @param keyValue Appkey * @param charset 编码方式 * @throws UnsupportedEncodingException ,Exception * @return DataSign签名 */@SuppressWarnings("unused")privateString encrypt (String content, String keyValue, String charset) throws UnsupportedEncodingException, Exception {if (keyValue != null) {return base64(MD5(content + keyValue, charset), charset); }return base64(MD5(content, charset), charset); }/** * 向指定 URL 发送POST方法的请求 * @param url 发送请求的 URL * @param params 请求的参数集合 * @return 远程资源的响应结果 */@SuppressWarnings("unused")privateString sendPost(String url, Map<String, String> params) { OutputStreamWriter out = null; BufferedReader in = null; StringBuilder result = new StringBuilder(); try { URL realUrl = new URL(url); HttpURLConnection conn =(HttpURLConnection) realUrl.openConnection();// 发送POST请求必须设置如下两行 conn.setDoOutput(true); conn.setDoInput(true);// POST方法 conn.setRequestMethod("POST");// 设置通用的请求属性 conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("user-agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.connect();// 获取URLConnection对象对应的输出流 out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");// 发送请求参数 if (params != null) { StringBuilder param = new StringBuilder(); for (Map.Entry<String, String> entry : params.entrySet()) {if(param.length()>0){ param.append("&"); } param.append(entry.getKey()); param.append("="); param.append(entry.getValue()); //System.out.println(entry.getKey()+":"+entry.getValue()); }//System.out.println("param:"+param.toString()); out.write(param.toString()); }// flush输出流的缓冲 out.flush();// 定义BufferedReader输入流来读取URL的响应in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));String line;while ((line = in.readLine()) != null) { result.append(line); } } catch (Exception e) { e.printStackTrace(); }//使用finally块来关闭输出流、输入流finally{try{if(out!=null){ out.close(); }if(in!=null){in.close(); } }catch(IOException ex){ ex.printStackTrace(); } }return result.toString(); }privatestatic char[] base64EncodeChars = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; publicstaticString base64Encode(byte[] data) { StringBuffer sb = new StringBuffer(); int len = data.length; int i = 0; int b1, b2, b3; while (i < len) { b1 = data[i++] & 0xff; if (i == len) { sb.append(base64EncodeChars[b1 >>> 2]); sb.append(base64EncodeChars[(b1 & 0x3) << 4]); sb.append("=="); break; } b2 = data[i++] & 0xff; if (i == len) { sb.append(base64EncodeChars[b1 >>> 2]); sb.append(base64EncodeChars[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]); sb.append(base64EncodeChars[(b2 & 0x0f) << 2]); sb.append("="); break; } b3 = data[i++] & 0xff; sb.append(base64EncodeChars[b1 >>> 2]); sb.append(base64EncodeChars[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]); sb.append(base64EncodeChars[((b2 & 0x0f) << 2) | ((b3 & 0xc0) >>> 6)]); sb.append(base64EncodeChars[b3 & 0x3f]); } return sb.toString(); }}新闻接口demo
https://www.apiopen.top/journalismApi
返回值:
{"code": 200,"msg": "成功!","data": {"tech": [ {"liveInfo": null,"tcount": 1,"picInfo": [ {"ref": null,"width": null,"url": "http://cms-bucket.nosdn.127.net/2018/07/13/96e750810c7c47c7b95d6ee112cb9ab4.png","height": null } ],"docid": "DMJU4F9E00097U7R","videoInfo": null,"channel": "tech","link": "https://3g.163.com/all/article/DMJU4F9E00097U7R.html","source": "网易科技报道","title": "消息称滴滴考虑明年IPO 放慢融资计划","type": "doc","imgsrcFrom": null,"imgsrc3gtype": 1,"unlikeReason": "重复、旧闻/6,内容质量差/6","digest": "网易科技讯7月13日消息,据香港媒体报道,消息人士透露,滴滴","typeid": "","addata": null,"tag": "","category": "科技","ptime": "2018-07-13 15:47:37" } ],"auto": [ {"liveInfo": null,"tcount": 514,"picInfo": [ {"ref": null,"width": null,"url": "http://cms-bucket.nosdn.127.net/2018/07/13/bcb246ac4558454d979b593138207f39.jpeg","height": null } ],"docid": "DMIP77HO0008856R","videoInfo": null,"channel": "auto","link": "https://3g.163.com/all/article/DMIP77HO0008856R.html","source": "网易汽车","title": "尊贵到令人膨胀 这辆宾利慕尚情怀爆棚","type": "doc","imgsrcFrom": null,"imgsrc3gtype": 1,"unlikeReason": "重复、旧闻/6,内容质量差/6","digest": "宾利汽车将于2019年迎来品牌成立100周年,为庆祝这一即将","typeid": "","addata": null,"tag": "","category": "汽车","ptime": "2018-07-13 05:02:30" } ] }} |
|