Python interface Automation 21-canonical API Interface documentation Example

Source: Internet
Author: User

Objective

What does the interface document look like? The biggest obstacle to interface testing is that there is no interface documentation, and many companies do not pay attention to the writing of the interface documentation, which leads to the test partner not seeing the interface documentation.
A little bit of luck to test the small partners may be thick skin to find the development to the interface document, but the interface document is not standardized, but also look at the face of the ignorant, then the specification of the interface document is what kind of?

Interface Name: QQ number of the test of the Cat Interface description:

Interface Address: HTTP://JAPI.JUHE.CN/QQEVALUATE/QQ
Return format: JSON
Request method: Get Post
Sample request: Http://japi.juhe.cn/qqevaluate/qq?key= the appkey&qq=283340479 you requested
Interface Note: According to the parameters of the QQ number and the appkey you applied to test QQ inauspiciousness

Request parameter description (enter parameter):

Name Required type description
Key is the string you requested for the Appkey
QQ is the QQ number that the string needs to be tested

Return parameter description (out parameter):

Name Type description
Error_code int Return Status code
Reason string return reason
Result string returns the entity content
Conclusion String QQ number test conclusion
Analysis of a string conclusion

JSON returns an example:
{    "error_code": 0,//返回状态码    "reason": "success",//返回原因    "result": {//返回实体内容        "data": {            "conclusion": "[大吉+官运+财运+才艺]如龙得云,青云直上,智谋奋进,才略奏功",//QQ号码测试结论            "analysis": "欲望难足希望高,计谋成功财力豪,猜疑嫉妒性自改,如龙乘云势运开。智能超人贯彻大志,富贵无比,不甘寂寞,叱吒风云之大吉数,但容易发生牢骚及贪心、欲望太多而永不知足,为其缺点。切忌沉迷投机,可免贻误前程。"//结论分析        }    }}

Error code reference:

Python Code Request Example:

The Appkey parameter needs to register the request, can call, the original interface address: https://www.juhe.cn/docs/api/id/166

If the key parameter is not correct, the request will not be successful!

# coding:utf-8import requestsurl = "http://japi.juhe.cn/qqevaluate/qq"par = {      "key": "******************",  # appkey需要注册申请      "qq":  "283340479"       }r = requests.get(url, params=par)print(r.text)  # 打印文本res = r.json()  # 返回的是json,用r.json解析器转成字典# 字典取某个字段conclusion = res["result"]["data"]["conclusion"]print(conclusion)analysis = res["result"]["data"]["analysis"]print(analysis)

Python interface Automation 21-API Interface documentation examples for specifications

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.