接口簡(jiǎn)介
AI舌診基礎(chǔ)版接口主要通過拍攝舌頭圖片進(jìn)行識(shí)別,返回十種舌像出現(xiàn)的概率值,加上身體可能出現(xiàn)的證型和對(duì)應(yīng)的調(diào)理方法。
接口地址
訪問地址:http://mnpc.com.cn/admin/api/tongue_analysis
請(qǐng)求方式:POST
請(qǐng)求格式:application/x-www-form-urlencode
* 所有的請(qǐng)求和響應(yīng)數(shù)據(jù)編碼皆為utf-8格式,URL里的所有參數(shù)名和參數(shù)值請(qǐng)做URL編碼
請(qǐng)求參數(shù)
字段 | 類型 | 是否必傳 | 說明 |
---|---|---|---|
appid | String | 是 | 開放平臺(tái)創(chuàng)建的appid |
imgpath | String | 是 | 傳入進(jìn)行識(shí)別的網(wǎng)絡(luò)圖片地址 |
timestamp | String | 是 | 請(qǐng)求端口的時(shí)間,時(shí)間格式y(tǒng)yyyMMddHHmmss |
version | String | 是 | api版本,默認(rèn)為1.0 |
sign | String | 是 | 簽名。先把timestamp用MD5進(jìn)行加密加上appid對(duì)應(yīng)的key,然后再次用MD5再次進(jìn)行加密生成簽名,所有的MD5加密為大寫。 |
響應(yīng)參數(shù)
字段 | 類型 | 說明 |
---|---|---|
msg | String | 響應(yīng)信息,成功為ok,錯(cuò)誤為對(duì)應(yīng)的錯(cuò)誤信息 |
code | Int | 響應(yīng)碼,200-成功 201-沒有可用次數(shù) 400-參數(shù)缺失或錯(cuò)誤 500-異常 |
data | json | 識(shí)別結(jié)果數(shù)據(jù) |
返回結(jié)果示例:
{ "msg":"成功", "code":200, "data":{ "cutTongue":"http://tonguecut.oss-cn-beijing.aliyuncs.com/ff1e1a54-1508-11eb-ac43-f990dea5f70f.jpg", "message":"調(diào)用成功", "char":[ { "type":"深白苔", "probability":"0.99271363" }, { "type":"薄苔", "probability":"0.99126816" }, { "type":"有齒痕", "probability":"0.61665225" }, { "type":"無點(diǎn)刺", "probability":"0.99993527" }, { "type":"無裂紋", "probability":"0.8993225" }, { "type":"膩苔", "probability":"0.9810058" }, { "type":"舌形正常", "probability":"0.5198991" }, { "type":"滑苔", "probability":"0.9249092" }, { "type":"淡白舌", "probability":"0.9212495" }, { "type":"舌苔不剝", "probability":"0.9940807" } ], "zhengxing":[ { "zhengxing_name":"腎陽不足", "jieshi":"腎臟的功能活動(dòng)弱,陽氣不足", "shiyishiwu":"紅棗、小米、大米、核桃仁、芝麻、榴蓮、冬瓜、黑芝麻、 羊腎、牛骨髓、豬腰子、驢肉、烏骨雞、鴨肉、泥鰍等", "jinjishiwu":"性質(zhì)寒涼、易損傷脾氣的食品、忌吃味厚滋膩、苦瓜、冬瓜、海帶、螃蟹、鴨子、飲啤酒等", "shiyiyundong":"八段錦、五禽戲、太極拳、易筋經(jīng)、慢跑、室外有氧運(yùn)動(dòng)、吐吶法", "jinjiyundong":"激烈運(yùn)動(dòng)", "shiyiyaoshan":"鎖陽蓯蓉粥", "shiyiyinyue":"廣陵散(戴紫茹)" }, { "zhengxing_name":"氣血兩虛", "jieshi":"指氣血均虧損不足的證候。多由久病不愈,氣血兩傷所致", "shiyishiwu":"山藥、豆角、紫薯、梨、豆腐、藕、粟子、石榴、青菜、芹菜、菠菜、蘋果、香蕉、葡萄、紅棗、椰子、橄欖、草莓等", "jinjishiwu":"吸煙、飲酒、忌生冷寒涼、油炸食品、腌制品、咖啡等刺激性食物、芒果、韭菜、生姜、辣椒、胡椒、花椒等", "shiyiyundong":"慢跑、散步、八段錦、五禽戲、太極拳、易筋經(jīng)、室外有氧運(yùn)動(dòng)", "jinjiyundong":"激烈運(yùn)動(dòng)", "shiyiyaoshan":"紅棗煲大魚魚頭", "shiyiyinyue":" 廣陵散(戴紫茹)" }, { "zhengxing_name":"寒癥或者寒濕癥", "jieshi":"寒證分外肝風(fēng)寒和內(nèi)寒(是臟腑陽氣不足,主要是腎陽不足所致)。寒濕證,中醫(yī)認(rèn)為寒濕包括外感寒濕和內(nèi)生寒濕兩個(gè)方面。外感寒濕:外感寒濕邪氣,氣血運(yùn)行受阻。內(nèi)生寒濕:寒濕內(nèi)困而損傷脾陽,或脾腎陽虛而寒濕內(nèi)停", "shiyishiwu":"馬蹄、橄欖、石榴、青菜、芹菜、菠菜、柑橘、烏梅、檸檬、魚肉等", "jinjishiwu":"吸煙、飲酒、忌生冷寒涼、油炸食品、腌制品、咖啡等刺激性食物、茶葉、醬油、蟹蚌、辣椒、胡椒、花椒等", "shiyiyundong":"慢跑、散步、八段錦、五禽戲、太極拳、易筋經(jīng)、室外有氧運(yùn)動(dòng)", "jinjiyundong":"激烈運(yùn)動(dòng)", "shiyiyaoshan":"生姜羊肉湯", "shiyiyinyue":"紫竹調(diào)(純樂古箏)" }, { "zhengxing_name":"陽虛證", "jieshi":"大腸陽氣虛衰而不能固攝所表現(xiàn)的證候", "shiyishiwu":"番薯、豆腐,藕、粟子、山藥、扁豆、豇豆、扁豆、豇豆、胡蘿卜、馬鈴薯、洋蔥、平菇、豬肚、桂魚、烏雞,桃、杏", "jinjishiwu":"忌吃性質(zhì)寒涼,易損傷脾氣的食品,忌吃味厚滋膩,苦瓜、冬瓜、海帶、螃蟹、鴨子,飲啤酒", "shiyiyundong":"散步,八段錦,五禽戲", "jinjiyundong":"激烈運(yùn)動(dòng)", "shiyiyaoshan":"山藥燉牛肉", "shiyiyinyue":"十面埋伏傳奇樂坊" }, { "zhengxing_name":"寒濕癥", "jieshi":"外感寒濕以關(guān)節(jié)、筋骨疼痛為常見癥的證候;內(nèi)生寒濕以畏寒肢冷,腹痛泄瀉,或浮腫為常見癥的證候", "shiyishiwu":"馬蹄、橄欖、石榴、青菜、芹菜、菠菜、柑橘、烏梅、檸檬、魚肉等", "jinjishiwu":"吸煙、飲酒、忌生冷寒涼、油炸食品、腌制品、咖啡等刺激性食物、茶葉、醬油、蟹蚌、辣椒、胡椒、花椒等", "shiyiyundong":"慢跑、散步、八段錦、五禽戲、太極拳、易筋經(jīng)、室外有氧運(yùn)動(dòng)", "jinjiyundong":"激烈運(yùn)動(dòng)", "shiyiyaoshan":"生姜羊肉湯", "shiyiyinyue":"十面埋伏傳奇樂坊" } ] } }
返回參數(shù)說明
返回參數(shù) | 說明 |
---|---|
cutTongue | 切割后的舌頭圖片url路徑 |
tizhi | 九種體質(zhì)對(duì)應(yīng)的概率 |
xueyu | 血瘀體質(zhì)對(duì)應(yīng)的概率 |
shire | 濕熱體質(zhì)對(duì)應(yīng)的概率 |
tebing | 特稟體質(zhì)對(duì)應(yīng)的概率 |
yangxu | 陽虛體質(zhì)對(duì)應(yīng)的概率 |
yinxu | 陰虛體質(zhì)對(duì)應(yīng)的概率 |
tanshi | 痰濕體質(zhì)對(duì)應(yīng)的概率 |
pinghe | 平和體質(zhì)對(duì)應(yīng)的概率 |
qiyu | 氣郁體質(zhì)對(duì)應(yīng)的概率 |
qixu | 氣虛體質(zhì)對(duì)應(yīng)的概率 |
tiaoli | 概率最高的體質(zhì)對(duì)應(yīng)的調(diào)理建議 |
tizhi_name | 體質(zhì)名稱 |
changjianbiaoxian | 常見表現(xiàn) |
jingshentiaoyang | 精神調(diào)養(yǎng) |
fabingqingxiang | 發(fā)病傾向 |
yuletiaoshe | 娛樂調(diào)攝 |
sijiyangsheng | 四季養(yǎng)生 |
tiyuduanlian | 體育鍛煉 |
qijutiaoshe | 起居調(diào)攝 |
yinyuetiaoli | 音樂調(diào)理 |
jingluobaojian | 經(jīng)絡(luò)保健 |
yongyaojinji | 用藥禁忌 |
shiliao | 兩種具體的藥膳、適合吃的食物和禁忌食物 |
zhengxing | 可能的證型和對(duì)應(yīng)的調(diào)理方法 |
zhengxing_name | 證型名稱 |
jieshi | 證型具體的解釋 |
shiyishiwu | 適宜食物 |
jinjishiwu | 禁忌食物 |
shiyiyundong | 適宜運(yùn)動(dòng) |
jinjiyundong | 禁忌運(yùn)動(dòng) |
shiyiyaoshan | 適宜藥膳 |
shiyiyinyue | 適宜音樂 |
message | 返回的各種情況,具體說明如下 |
message參數(shù) | 說明 |
---|---|
圖片路徑有誤 | 原始圖片url路徑有誤 |
圖片質(zhì)量過低 | 拍攝舌頭圖片模糊或無舌頭圖片 |
服務(wù)器繁忙 | 服務(wù)器并發(fā)過高 |
切割圖片失敗 | 舌頭圖片不完整 |
無對(duì)應(yīng)證型 | 有舌頭和體質(zhì)相關(guān)結(jié)果,沒有對(duì)應(yīng)的證型結(jié)果 |
調(diào)用成功 | 正常返回所有結(jié)果 |
java調(diào)用代碼示例
import com.alibaba.fastjson.JSON; import com.util.HttpClient; import java.io.IOException; import java.security.MessageDigest; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; public class DemoObj { public static String MD5(String data) throws Exception { System.out.println(data); MessageDigest md = MessageDigest.getInstance("MD5"); byte[] array = md.digest(data.getBytes("UTF-8")); StringBuilder sb = new StringBuilder(); for (byte item : array) { sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); } System.out.println(sb.toString().toUpperCase()); return sb.toString().toUpperCase(); } public static void main(String[] args) { DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss"); String timestamp=df.format(new Date()); Mapbody = new HashMap<>(); body.put("appid", "你的APPID"); System.out.println(timestamp); body.put("timestamp", timestamp); body.put("version", "1.0"); body.put("imgpath", "舌頭圖片地址"); try { body.put("sign", MD5(MD5(timestamp)+"你的APPID對(duì)應(yīng)的key")); } catch (Exception e) { e.printStackTrace(); } try { String s = new HttpClient().doPostMap("http://mnpc.com.cn/admin/api/tongue_analysis", body); System.out.println(s); Map maps = (Map) JSON.parse(s); for (Object map : maps.entrySet()){ System.out.println(((Map.Entry)map).getKey()+" " + ((Map.Entry)map).getValue()); } } catch (IOException e) { e.printStackTrace(); } } }
python調(diào)用代碼示例
import hashlib # 導(dǎo)入time模塊 import time import requests import json def Md5(res): print(res) md = hashlib.md5() # 構(gòu)造一個(gè)md5 md.update(res.encode(encoding='utf-8')) # 加密 print(md.hexdigest().upper()) return md.hexdigest().upper() def testapi(): tures={} restime=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) # restime="20190829114035" #傳入?yún)?shù) tures['timestamp']=restime tures['appid']="你的APPID" tures['version']='1.0' tures['imgpath']='https://bys-tonguepicture.oss-cn-beijing.aliyuncs.com/1563412989396.jpg' tures['sign']=Md5(Md5(restime)+"你的APPID對(duì)應(yīng)的key") url = "http://api.bjbayes.com/api/tongue_analysis" response = requests.post(url, params=tures) # print(response.text) print(type(response.text)) load=json.loads(response.text) print(load)
C#調(diào)用代碼示例
using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Net; using System.Security.Cryptography; using System.Text; namespace APITest { class Program { static void Main(string[] args) { DictionarymyDictionary = new Dictionary (); DateTime dt = DateTime.Now; string ds = dt.ToString("yyyyMMddHHmmss"); myDictionary.Add("timestamp",ds); myDictionary.Add("appid", "你的APPID"); myDictionary.Add("version","1.0"); myDictionary.Add("imgpath", "待測(cè)圖片的云服務(wù)地址"); myDictionary.Add("sign",GetMD5(GetMD5(ds)+ "你的APPID對(duì)應(yīng)的key")); string finalresult = Post("http://mnpc.com.cn/admin/api/tongue_analysis",myDictionary); Object jo = JsonConvert.DeserializeObject(finalresult); //此處結(jié)果為最后的調(diào)用結(jié)果 Console.WriteLine(jo); Console.ReadKey(); } //構(gòu)造MD5 public static string GetMD5(string sDataIn) { MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] bytValue, bytHash; bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn); bytHash = md5.ComputeHash(bytValue); md5.Clear(); string sTemp = ""; for (int i = 0; i < bytHash.Length; i++) { sTemp += bytHash[i].ToString("X").PadLeft(2, '0'); } return sTemp.ToUpper(); } /// /// 指定Post地址使用Get 方式獲取全部字符串 /// /// 請(qǐng)求后臺(tái)地址 ///public static string Post(string url, Dictionary dic) { string result = ""; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; #region 添加Post 參數(shù) StringBuilder builder = new StringBuilder(); int i = 0; foreach (var item in dic) { if (i > 0) builder.Append("&"); builder.AppendFormat("{0}={1}", item.Key, item.Value); i++; } byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); req.ContentLength = data.Length; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(data, 0, data.Length); reqStream.Close(); } #endregion HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Stream stream = resp.GetResponseStream(); //獲取響應(yīng)內(nèi)容 using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) { result = reader.ReadToEnd(); } return result; } } }
javascript調(diào)用代碼示例
$.ajax({ type: "POST", url: "http://mnpc.com.cn/admin/api/tongue_analysis", data: { timestamp:restime, #restime時(shí)間格式為YYmmddHHMMSS appid='你的APPID', version='1.0', imgpath='https://bys-tonguepicture.oss-cn-beijing.aliyuncs.com/1563412989396.jpg', sign=Md5(Md5(restime)+'你的APPID對(duì)應(yīng)的key') }, success: function(msg) { console.log('返回的數(shù)據(jù):'+msg); } });