api接口文档在线生成(快速生成api接口)

网友投稿 1412 2023-03-08


本篇文章给大家谈谈api接口文档在线生成,以及快速生成api接口对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。 今天给各位分享api接口文档在线生成的知识,其中也会对快速生成api接口进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

如何使 WebAPI 自动生成漂亮又实用在线API文档

1.1 SwaggerUI
SwaggerUI 是一个简单的Restful API 测试和文档工具。简单、漂亮、易用(官方demo)。通过读取JSON 配置显示API. 项目本身仅仅也只依赖一些 html,css.js静态文件. api接口文档在线生成你可以几乎放在任何Web容器上使用。
1.2 Swashbuckle
Swashbuckle 是.NET类库,可以将WebAPI所有开放的控制器方法生成对应SwaggerUI的JSON配置。再通过SwaggerUI 显示出来。类库中已经包含SwaggerUI 。所以不需要额外安装。
2.快速开始
创建项目 OnlineAPI来封装百度音乐服务(示例下载) ,通过API可以搜索、获取音乐的信息和播放连接。
我尽量删除一些我们demo中不会用到的一些文件,使其看上去比较简洁。
WebAPI 安装 Swashbuckle
Install-Package Swashbuckle
代码注释生成文档说明。
Swashbuckle 是通过生成的XML文件来读取注释的,生成 SwaggerUI,JSON 配置中的说明的。
安装时会在项目目录 App_Start 文件夹下生成一个 SwaggerConfig.cs 配置文件,用于配置 SwaggerUI 相关展示行为的。如图api接口文档在线生成
将配置文件大概99行注释去掉并修改为
c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name));
并在当前类中添加一个方法
/// <summary
/// </summary
/// <param name="name"</param
/// <returns</returns
protected static string GetXmlCommentsPath(string name)
{
return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);
}
紧接着你在此Web项目属性生成选卡中勾选 “XML 文档文件”,编译过程中生成类库的注释文件
添加百度音乐 3个API
访问 lt;youhost/swagger/ui/index,最终显示效果
我们通过API 测试API 是否成功运行
3.添加自定义HTTP Header
在开发移动端 API时常常需要验证权限,验证参数放在Http请求头中是再好不过api接口文档在线生成了。WebAPI配合过滤器验证权限即可
首先我们需要创建一个 IOperationFilter 接口的类。IOperationFilter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.Description;
using System.Web.Http.Filters;
using Swashbuckle.Swagger;
namespace OnlineAPI.Utility
{
public class HttpHeaderFilter : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry
schemaRegistry, ApiDescription apiDescription)
{
if (operation.parameters == null) operation.parameters = new
List<Parameter();
var filterPipeline =
apiDescription.ActionDescriptor.GetFilterPipeline();
//判断是否添加权限过滤器
var isAuthorized = filterPipeline.Select(filterInfo =
filterInfo.Instance).Any(filter = filter is IAuthorizationFilter);
//判断是否允许匿名方法
var allowAnonymous =
apiDescription.ActionDescriptor.GetCustomAttributes<AllowAnonymousAttribute().Any();
if (isAuthorized !allowAnonymous)
{
operation.parameters.Add(new Parameter
{
name = "access-key",
@in = "header",
description = "用户访问Key",
required = false,
type = "string"
});
}
}
}
}
在 SwaggerConfig.cs 的 EnableSwagger 配置匿名方法类添加一行注册代码
c.OperationFilter<HttpHeaderFilter();
添加Web权限过滤器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using Newtonsoft.Json;
namespace OnlineAPI.Utility
{
/// <summary
///
/// </summary
public class AccessKeyAttribute : AuthorizeAttribute
{
/// <summary
/// 权限验证
/// </summary
/// <param name="actionContext"</param
/// <returns</returns
protected override bool IsAuthorized(HttpActionContext actionContext)
{
var request = actionContext.Request;
if (request.Headers.Contains("access-key"))
{
var accessKey = request.Headers.GetValues("access-key").SingleOrDefault();
//TODO 验证Key
return accessKey == "123456789";
}
return false;
}
/// <summary
/// 处理未授权的请求
/// </summary
/// <param name="actionContext"</param
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
{
var content = JsonConvert.SerializeObject(new {State = HttpStatusCode.Unauthorized});
actionContext.Response = new HttpResponseMessage
{
Content = new StringContent(content, Encoding.UTF8, "application/json"),
StatusCode = HttpStatusCode.Unauthorized
};
}
}
}
在你想要的ApiController 或者是 Action 添加过滤器
[AccessKey]
最终显示效果
4.显示上传文件参数
SwaggerUI 有上传文件的功能和添加自定义HTTP Header 做法类似,只是我们通过特殊的设置来标示API具有上传文件的功能
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Description;
using Swashbuckle.Swagger;
namespace OnlineAPI.Utility
{
/// <summary
///
/// </summary
public class UploadFilter : IOperationFilter
{
/// <summary
/// 文件上传
/// </summary
/// <param name="operation"</param
/// <param name="schemaRegistry"</param
/// <param name="apiDescription"</param
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
if (!string.IsNullOrWhiteSpace(operation.summary) operation.summary.Contains("upload"))
{
operation.consumes.Add("application/form-data");
operation.parameters.Add(new Parameter
{
name = "file",
@in = "formData",
required = true,
type = "file"
});
}
}
}
}
在 SwaggerConfig.cs 的 EnableSwagger 配置匿名方法类添加一行注册代码
c.OperationFilter<UploadFilter();
API 文档展示效果

神器 SpringDoc 横空出世!最适合 SpringBoot 的API文档工具来了

之前在SpringBoot项目中一直使用的是SpringFox提供的Swagger库,上了下官网发现已经有接近两年没出新版本了!前几天升级了SpringBoot 2.6.x 版本,发现这个库的兼容性也越来越不好了,有的常用注解属性被废弃了居然都没提供替代!无意中发现了另一款Swagger库SpringDoc,试用了一下非常不错,推荐给大家!

SpringDoc简介

SpringDoc是一款可以结合SpringBoot使用的API文档生成工具,基于OpenAPI 3,目前在Github上已有1.7K+Star,更新发版还是挺勤快的,是一款更好用的Swagger库!值得一提的是SpringDoc不仅支持Spring WebMvc项目,还可以支持Spring WebFlux项目,甚至Spring Rest和Spring Native项目,总之非常强大,下面是一张SpringDoc的架构图。

使用

接下来我们介绍下SpringDoc的使用,使用的是之前集成SpringFox的mall-tiny-swagger项目,我将把它改造成使用SpringDoc。

集成

首先我们得集成SpringDoc,在pom.xml中添加它的依赖即可,开箱即用,无需任何配置。

<!--springdoc 官方Starter--org.springdocspringdoc-openapi-ui1.6.6

从SpringFox迁移

我们先来看下经常使用的Swagger注解,看看SpringFox的和SpringDoc的有啥区别,毕竟对比已学过的技术能该快掌握新技术;

接下来我们对之前Controller中使用的注解进行改造,对照上表即可,之前在@Api注解中被废弃了好久又没有替代的description属性终于被支持了!

/**

* 品牌管理Controller

* Created by macro on 2019/4/19.

*/@Tag(name ="PmsBrandController", description ="商品品牌管理")@Controller@RequestMapping("/brand")publicclassPmsBrandController{@AutowiredprivatePmsBrandService brandService;privatestaticfinalLogger LOGGER = LoggerFactory.getLogger(PmsBrandController.class);@Operation(summary ="获取所有品牌列表",description ="需要登录后访问")@RequestMapping(value ="listAll", method = RequestMethod.GET)@ResponseBodypublicCommonResult getBrandList() {returnCommonResult.success(brandService.listAllBrand());    }@Operation(summary ="添加品牌")@RequestMapping(value ="/create", method = RequestMethod.POST)@ResponseBody@PreAuthorize("hasRole('ADMIN')")publicCommonResult createBrand(@RequestBodyPmsBrand pmsBrand) {        CommonResult commonResult;        int count = brandService.createBrand(pmsBrand);if(count ==1) {            commonResult = CommonResult.success(pmsBrand);            LOGGER.debug("createBrand success:{}", pmsBrand);        }else{            commonResult = CommonResult.failed("操作失败");            LOGGER.debug("createBrand failed:{}", pmsBrand);        }returncommonResult;    }@Operation(summary ="更新指定id品牌信息")@RequestMapping(value ="/update/{id}", method = RequestMethod.POST)@ResponseBody@PreAuthorize("hasRole('ADMIN')")publicCommonResult updateBrand(@PathVariable("id")Longid,@RequestBodyPmsBrand pmsBrandDto, BindingResult result) {        CommonResult commonResult;        int count = brandService.updateBrand(id, pmsBrandDto);if(count ==1) {            commonResult = CommonResult.success(pmsBrandDto);            LOGGER.debug("updateBrand success:{}", pmsBrandDto);        }else{            commonResult = CommonResult.failed("操作失败");            LOGGER.debug("updateBrand failed:{}", pmsBrandDto);        }returncommonResult;    }@Operation(summary ="删除指定id的品牌")@RequestMapping(value ="/delete/{id}", method = RequestMethod.GET)@ResponseBody@PreAuthorize("hasRole('ADMIN')")publicCommonResult deleteBrand(@PathVariable("id")Longid) {        int count = brandService.deleteBrand(id);if(count ==1) {            LOGGER.debug("deleteBrand success :id={}", id);returnCommonResult.success(null);        }else{            LOGGER.debug("deleteBrand failed :id={}", id);returnCommonResult.failed("操作失败");        }    }@Operation(summary ="分页查询品牌列表")@RequestMapping(value ="/list", method = RequestMethod.GET)@ResponseBody@PreAuthorize("hasRole('ADMIN')")publicCommonResult listBrand(@RequestParam(value ="pageNum", defaultValue ="1")@Parameter(description ="页码")Integer pageNum,@RequestParam(value ="pageSize", defaultValue ="3")@Parameter(description ="每页数量")Integer pageSize) {        List brandList = brandService.listBrand(pageNum, pageSize);returnCommonResult.success(CommonPage.restPage(brandList));    }@Operation(summary ="获取指定id的品牌详情")@RequestMapping(value ="/{id}", method = RequestMethod.GET)@ResponseBody@PreAuthorize("hasRole('ADMIN')")publicCommonResult brand(@PathVariable("id")Longid) {returnCommonResult.success(brandService.getBrand(id));    }}

接下来进行SpringDoc的配置,使用OpenAPI来配置基础的文档信息,通过GroupedOpenApi配置分组的API文档,SpringDoc支持直接使用接口路径进行配置。

/**

* SpringDoc API文档相关配置

* Created by macro on 2022/3/4.

*/@ConfigurationpublicclassSpringDocConfig{@BeanpublicOpenAPImallTinyOpenAPI(){returnnewOpenAPI()                .info(newInfo().title("Mall-Tiny API")                        .description("SpringDoc API 演示")                        .version("v1.0.0")                        .license(newLicense().name("Apache 2.0").url("https://github.com/macrozheng/mall-learning")))                .externalDocs(newExternalDocumentation()                        .description("SpringBoot实战电商项目mall(50K+Star)全套文档")                        .url("http://www.macrozheng.com"));    }@BeanpublicGroupedOpenApipublicApi(){returnGroupedOpenApi.builder()                .group("brand")                .pathsToMatch("/brand/**")                .build();    }@BeanpublicGroupedOpenApiadminApi(){returnGroupedOpenApi.builder()                .group("admin")                .pathsToMatch("/admin/**")                .build();    }}

结合SpringSecurity使用

由于我们的项目集成了SpringSecurity,需要通过JWT认证头进行访问,我们还需配置好SpringDoc的白名单路径,主要是Swagger的资源路径;

/**

* SpringSecurity的配置

* Created by macro on 2018/4/26.

*/@Configuration@EnableWebSecurity@EnableGlobalMethodSecurity(prePostEnabled = true)public class SecurityConfig extends WebSecurityConfigurerAdapter {@Overrideprotected void configure(HttpSecurity httpSecurity) throws Exception {httpSecurity.csrf()// 由于使用的是JWT,我们这里不需要csrf.disable().sessionManagement()// 基于token,所以不需要session.sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests().antMatchers(HttpMethod.GET,// Swagger的资源路径需要允许访问"/","/swagger-ui.html","/swagger-ui/","/*.html","/favicon.ico","/**/*.html","/**/*.css","/**/*.js","/swagger-resources/**","/v3/api-docs/**").permitAll().antMatchers("/admin/login")// 对登录注册要允许匿名访问.permitAll().antMatchers(HttpMethod.OPTIONS)//跨域请求会先进行一次options请求.permitAll().anyRequest()// 除上面外的所有请求全部需要鉴权认证.authenticated();            }}

然后在OpenAPI对象中通过addSecurityItem方法和SecurityScheme对象,启用基于JWT的认证功能。

/**

* SpringDoc API文档相关配置

* Created by macro on 2022/3/4.

*/@ConfigurationpublicclassSpringDocConfig{privatestaticfinalString SECURITY_SCHEME_NAME ="BearerAuth";@BeanpublicOpenAPImallTinyOpenAPI(){returnnewOpenAPI()                .info(newInfo().title("Mall-Tiny API")                        .description("SpringDoc API 演示")                        .version("v1.0.0")                        .license(newLicense().name("Apache 2.0").url("https://github.com/macrozheng/mall-learning")))                .externalDocs(newExternalDocumentation()                        .description("SpringBoot实战电商项目mall(50K+Star)全套文档")                        .url("http://www.macrozheng.com"))                .addSecurityItem(newSecurityRequirement().addList(SECURITY_SCHEME_NAME))                .components(newComponents()                                .addSecuritySchemes(SECURITY_SCHEME_NAME,newSecurityScheme()                                                .name(SECURITY_SCHEME_NAME)                                                .type(SecurityScheme.Type.HTTP)                                                .scheme("bearer")                                                .bearerFormat("JWT")));    }}

测试

接下来启动项目就可以访问Swagger界面了,访问地址:http://localhost:8088/swagger-ui.html

我们先通过登录接口进行登录,可以发现这个版本的Swagger返回结果是支持高亮显示的,版本明显比SpringFox来的新;

然后通过认证按钮输入获取到的认证头信息,注意这里不用加bearer前缀;

之后我们就可以愉快地访问需要登录认证的接口了;

看一眼请求参数的文档说明,还是熟悉的Swagger样式!

常用配置

SpringDoc还有一些常用的配置可以了解下,更多配置可以参考官方文档。

springdoc:swagger-ui:# 修改Swagger UI路径path:/swagger-ui.html# 开启Swagger UI界面enabled:trueapi-docs:# 修改api-docs路径path:/v3/api-docs# 开启api-docsenabled:true# 配置需要生成接口文档的扫描包packages-to-scan:com.macro.mall.tiny.controller# 配置需要生成接口文档的接口路径paths-to-match:/brand/**,/admin/**

总结

在SpringFox的Swagger库好久不出新版的情况下,迁移到SpringDoc确实是一个更好的选择。今天体验了一把SpringDoc,确实很好用,和之前熟悉的用法差不多,学习成本极低。而且SpringDoc能支持WebFlux之类的项目,功能也更加强大,使用SpringFox有点卡手的朋友可以迁移到它试试!

参考资料

项目地址:https://github.com/springdoc/springdoc-openapi

官方文档:https://springdoc.org/

项目源码地址

https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-springdoc

https://mp.weixin.qq.com/s/scityFhZp9BOJorZSdCG0w

java api接口文档怎么编写?

Java语言提供了一种强大的注释形式:文档注释。可以将源代码里的文档注释提取成一份系统的API文档。我们在开发中定义类、方法时可以先添加文档注释,然后使用javadoc工具来生成自己的API文档。

文档注释以斜线后紧跟两个星号(/**)开始,以星号后紧跟一个斜线(*/)作为结尾,中间部分全部都是文档注释,会被提取到API文档中。

自行搜索一下javadoc即可,示例如下:

1234567891011121314151617181920212223242526272829/** * 类描述 * * @author 作者 * @version 版本 */public class DemoClass {    /**     * 内部属性:name     */    private String name;           /**     * Setter方法     * @return name     */    public String getName() {        return name;    }     /**     * Getter方法     * @param name     */    public void setName(String name) {        this.name = name;    } }

如何优雅的“编写”api接口文档

1. 拼写要准确
接口函数一旦发布就不能改了,要保持兼容性,拼写错误也不能改了,所以要仔细检查拼写,否则会被同行嘲笑很多年。
著名悲剧:unix 的 creat
2. 不仅是英文单词不要拼错,时态也不要错。
比如:
返回bool的判断函数,单数要用 is 复数要用are,这样你的命名就和文档中的描述保持了一致性。
表示状态的变量或者函数要注意时态,比如 onXxxxChanged 表示xxx已经变化了,isConnecting表示正在连接。
正确的时态可以给使用者传递更丰富的信息。
3. 函数最好是动宾结构
动宾结构就是 doSomething,这样的函数命名含义明确
比如: openFile, allocBuffer, setName
如果这个函数的动词宾语就是这个对象本身,那么可以省略掉宾语
4. 属性命名最好是定语+名词
比如 fileName, maxSize, textColor
5. 不要用生僻单词,这不是秀英语的地方,也不要用汉语拼音
比如:rendezvous,估计大多数人要去查词典才知道什么意思,这个词源自法语,是约会的意思。
Symbian OS里有个用它命名的函数,开发Symbian的是英国人,也许人家觉得很平常吧,反正我是查了词典才知道的。
6. 不要自己发明缩写
除非是约定俗成已经被广泛使用的缩写,否则老老实实用完整拼写。
坏例子: count-cnt, manager-mngr password-pw button-btn
现代的IDE都有很好的自动完成功能,名字长一点没关系的,可读性更重要。
7. 保持方法的对称性,有些方法一旦出现就应该是成对的,
比如 有open就要有close,有alloc就要有free,有add就要有remove,这些单词基本是固定搭配的,使用者就很容易理解。
如果 open对应clear就有点让人困惑了。

django drf_yasg 非restful风格的api怎么在swagger上展示?

使用Swagger
Swagger 是一款RESTFUL接口的文档在线自动生成+功能测试功能软件。
在web api 使用swagger可以说非常简单,不需要编写任何代码,完全依赖于插件。具体步骤如下:
  1.新建一个web api项目

2.使用nuget添加Swashbuckle包

3.完成
没错,就是这么简单!运行项目,转到地址 http://localhost:57700/swagger/ui/index 会看到如下页面,这是默认添加的两个apicontroller:
这个时候接口还没有具体的描述信息等,例如我们给ValuesController.Get添加注释描述,在页面上还是没有显示出来。需要按照如下步骤实现:
1. 在app_start 下 SwaggerConfig 大100行的位置找到 //c.IncludeXmlComments(GetXmlCommentsPath()); 如下注释,改为:c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name)); (注意去掉注释了)
2. 在SwaggerConfig添加一个方法代码:
1
2
3
4
protected static string GetXmlCommentsPath(string name)
{
return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);
}
3. 修改项目生成,在bin下对应的xml文件可以看到具体的描述文档,如下:

重新生成项目,就要可以看到完整的接口描述了。例如我们心中一个TestController如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/// <summary
/// 测试控制器
/// </summary
public class TestController : ApiController
{
/// <summary
/// 测试Get方法
/// </summary
/// <remarks测试Get方法</remarks
/// <returns</returns
[HttpGet]
public string Get()
{
return "Get";
}

/// <summary
/// 测试Post方法
/// </summary
/// <param name="name"姓名</param
/// <param name="age"年龄</param
/// <remarks测试Post方法</remarks
/// <returns</returns
[HttpPost]
public string Post(string name, int age)
{
return name + age.ToString();
}
}
生成的页面如下,可以看到接口的描述,点击Try it out 即可调用:

三、非依赖代码
上面的方式依赖于Swashbuckle包,它已经包含了Swagger-UI组件。我们的代码需要引入这个包,实际上也可以不需要在项目中引入,单独部署Swagger,包括Swagger-Ui(api展示) 和 Swagger-Editor(在线编辑器),它需要依赖nodejs环境,所以需要先按照nodejs。部署其实也很简单,例如这是我部署的结果:
swagger-editor:
swagger-ui:
编辑后只需要将文件保存为json文件,然后拷贝到指定的目录即可。这个部署也非常简单,具体可以参照:

免费API接口的试用开发文档有吗

Api接口就好比一个媒介工具,比如买东西的时候我们要计算价格,可以用算盘、计算器、手机或者电脑进行计算得出结果。接口与其类似,当你需要用到这个功能时就可以调用。
Api接口可以应用于pc端、app、软件等,除了接口一般会有Api接口文档说明来帮助开发者使用。
下面来分享一下免费的api接口以及文档说明:
1. 邮编查询:
接口地址:http://v.juhe.cn/postcode/query
返回格式:json/xml
请求方式:http get/post
请求示例:http://v.juhe.cn/postcode/query?postcode=215001key=申请的KEY
接口备注:通过邮编查询对应的地名
请求参数说明:
名称 类型 必填 说明
postcode 是 string 邮编,如:215001
key 是 string 应用APPKEY(应用详细页查询)
page 否 int 页数,默认1
pagesize 否 int 每页返回,默认:20,最大不超过50
dtype 否 string 返回数据的格式,xml或json,默认json
返回参数说明:
名称 类型 说明
error_code int 返回码
reason string 返回说明
JSON返回示例:
{
"reason": "successed",
"result": {
"list": [
{
"PostNumber": "215001",
"Province": "江苏省",
"City": "苏州市",
"District": "平江区",
"Address": "廖家巷新光里"
},
{
"PostNumber": "215001",
"Province": "江苏省",
"City": "苏州市",
"District": "平江区",
"Address": "龙兴桥顺德里"
}
],
"totalcount": 352,
"totalpage": 176,
"currentpage": 1,
"pagesize": "2"
},
"error_code": 0
}
2. 手机号码归属地:
接口地址:http://apis.juhe.cn/mobile/get
返回格式:json/xml
请求方式:get
请求示例:http://apis.juhe.cn/mobile/get?phone=13429667914key=您申请的KEY
请求参数说明:
名称 类型 必填 说明
phone 是 int 需要查询的手机号码或手机号码前7位
key 是 string 应用APPKEY(应用详细页查询)
dtype 否 string 返回数据的格式,xml或json,默认json
返回参数说明:
名称 类型 说明
error_code int 返回码
reason string 返回说明
result string 返回结果集
province string 省份
city string 城市,(北京、上海、重庆、天津直辖市可能为空)
areacode string 区号,(部分记录可能为空)
zip string 邮编,(部分记录可能为空)
company string 运营商
JSON返回示例:
{
"resultcode":"200",
"reason":"Return Successd!",
"result":{
"province":"浙江",
"city":"杭州",
"areacode":"0571",
"zip":"310000",
"company":"中国移动",
"card":""
}
}
XML返回示例:
<?xml version="1.0" encoding="utf-8" ?
- <root
<resultcode200</resultcode
<reasonReturn Successd!</reason
- <result
<province浙江</province
<city杭州</city
<areacode0571</areacode
<zip310000</zip
<company中国移动</company
<card</card
</result
</root
3. 影视影讯检索:
接口地址:http://op.juhe.cn/onebox/movie/video
返回格式:json/xml
请求方式:http get/post
请求事例http://op.juhe.cn/onebox/movie/video?key=APPKEYq=%E5%BA%B7%E7%86%99%E7%8E%8B%E6%9C%9D
接口备注:电影:q=心花路放;电视剧:q=继承者们;动漫:q=柯南
请求参数说明:
名称 类型 必填 说明
key 是 string 应用APPKEY(应用详细页查询)
dtype 否 string 返回数据的格式,xml或json,默认json
q 是 string 影视搜索名称
返回参数说明:
名称 类型 说明
error_code int 返回码
reason string 返回说明
JSON返回示例:
{
"reason": "查询成功",
"result": {
"title": "闪电侠第一季",
"tag": "科幻 / 动作",
"act": "格兰特·古斯汀 埃涅·赫德森 汤姆·卡瓦纳夫",
"year": "2014",
"rating": null,
"area": "美国",
"dir": "大卫·努特尔",
"desc": "《闪电侠》精彩看点:二次元超级英雄再登电视荧屏,《闪电侠》无缝对接《绿箭侠》闪耀登场。《闪电侠》剧情梗概:《闪电侠》的漫画连载开始于1940年,讲述了一名拥有超级速度的学生的故事。50年代起,这个角色则被重新诠释,成为了巴里·艾伦,一名为警署工作的科学家,使用他的超级速度来对抗超级反派们。",
"cover": "http://i.gtimg.cn/qqlive/img/jpgcache/files/qqvideo/0/0l01jm9yobh4xo4.jpg",
"vdo_status": "play",
"playlinks": {
"youku": "http://v.youku.com/v_show/id_XODQ1NTAzNDE2.html?tpa=dW5pb25faWQ9MTAyMjEzXzEwMDAwNl8wMV8wMQ",
"qq": "http://v.qq.com/cover/0/0l01jm9yobh4xo4/g0015dn2fw1.html",
"leshi": "http://www.letv.com/ptv/vplay/21416940.html",
"pptv": "http://v.pptv.com/show/2uhW1T2jE1G0Mr4.html",
"sohu": "http://tv.sohu.com/20141210/n406824703.shtml?txid=4e4df35dda9d8ed32c874b1ad590ef59"
},
"video_rec": [
{
"detail_url": "http://kan.com/tv/PrVtaX7kRzXsMn.html",
"cover": "http://p2.qhimg.com/t01f969930fae67d1ec.jpg",
"title": "神盾局特工 第2季"
},
{
"detail_url": "http://kan.com/tv/Q4RvaqOoRmDuMX.html",
"cover": "http://p6.qhimg.com/t0160a8a6f5b768034a.jpg",
"title": "遗失的世界"
},
{
"detail_url": "http://kan.com/tv/Q4Frc3GoRmbuMX.html",
"cover": "http://p7.qhimg.com/t01513514907831e055.jpg",
"title": "浩劫余生 第一季"
},
{
"detail_url": "http://kan.com/tv/QrFob33oRGboMX.html",
"cover": "http://p6.qhimg.com/d/_hao360/video/img200909_18_145544738.jpg",
"title": "新绿野仙踪之铁皮人"
},
{
"detail_url": "http://kan.com/tv/QrRtbaOpRz4nOH.html",
"cover": "http://p1.qhimg.com/t01d2996b3305923b91.jpg",
"title": "陨落星辰第三季"
}
],
"act_s": [
{
"name": "格兰特·古斯汀",
"url": "http://baike.so.com/doc/2041872.html",
"image": "http://p3.qhimg.com/dmsmty/120_110_100/t019f2fb2f92c6cb2cf.jpg"
},
{
"name": "埃涅·赫德森",
"url": "http://baike.so.com/doc/3938849.html",
"image": "http://p2.qhimg.com/dmsmty/120_110_100/t0169332727e692e9fa.jpg"
},
{
"name": "汤姆·卡瓦纳夫",
"url": "http://baike.so.com/doc/7521211.html",
"image": "http://p0.qhimg.com/dmsmty/120_110_100/t01d271d8c090330ae2.jpg"
}
]
},
"error_code": 0
}
4. 商品比价查询:
API调用地址:
http://sapi.manmanbuy.com/Search.aspx?AppKey=申请appkeyKey=搜索关键词Class=分类IDBrand=品牌IDSite=商城IDPriceMin=最低价PriceMax=最高价PageNum=页号PageSize=每页商品数OrderBy=排序方式ZiYing=是否自营ExtraParameter=扩展参数
调用示例
http://sapi.manmanbuy.com/Search.aspx?AppKey=123456Key=iphoneClass=0Brand=0Site=0PriceMin=0PriceMax=0PageNum=1PageSize=30OrderBy=scoreZiYing=falseExtraParameter=0
返回结果示例(以iphone为例,显示前2条商品信息):
{"State":1000,"SearchItemsCount":101520,"SearchCount":5109,"ClassList":"57|1074|手机,893|29964|iPhone 配件,892|19512|手机保护套,910|11169|苹果配件, 890|8766|手机贴膜 ,894|6201|其它配件,900|3189|移动电源,889|2067|手机充电器,898|1923|电池/充电器,101|1518|耳机,888|1290|手机电池, 100|1074|蓝牙耳机","BrandList":"155|47184|苹果,0|40476|,634|2166|洛克,6|1134|三星,622|1023|倍思,261|564|品胜,652|558|SGP, 639|537|ESR,623|474|邦克仕,10|423|飞利浦,604|330|摩米士,664|291|优胜仕","SiteList":"1|66732|京东商城,4|8478|亚马逊,3|7917| 当当,13|4821|1号店,6|4605|苏宁易购,8|4149|国美在线,11|3882|易迅网,9|360|新蛋网,161|168|飞牛网,185|147|顺电网,124|123|高鸿商城, 123|69|华强北","SearchResultList":[{"spname":"苹果(Apple)iPhone 6 (A1586) 16GB 金色 移动联通电信4G手机", "sppic":"http://img14.360buyimg.com/n7/jfs/t277/193/1005339798/768456/29136988/542d0798N19d42ce3.jpg", "spurl":"http://item.jd.com/1217499.html","spprice":"5188.00","className":"手机","brandName":"苹果","siteName":"京东商城", "commentUrl":"http://item.jd.com/1217499.html#comments-list","commentCount":"8773", "TitleHighLighter":"苹果(Apple)iPhone 6 (A1586) 16GB 金色 移动联通电信4G手机","ziying":"1","siteid":"1","id":"98084930"}, {"spname":"苹果(Apple)iPhone 6 Plus (A1524) 16GB 金色 移动联通电信4G手机", "sppic":"http://img14.360buyimg.com/n7/jfs/t346/302/1010969394/231745/50f20b36/542d0e26N894372e9.jpg", "spurl":"http://item.jd.com/1217524.html","spprice":"5988.00","className":"手机","brandName":"苹果","siteName":"京东商城", "commentUrl":"http://item.jd.com/1217524.html#comments-list","commentCount":"10288", "TitleHighLighter":"苹果(Apple)iPhone 6 Plus (A1524) 16GB 金色 移动联通电信4G手机","ziying":"1","siteid":"1","id":"98084932"}]} 关于api接口文档在线生成和快速生成api接口的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。 api接口文档在线生成的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于快速生成api接口、api接口文档在线生成的信息别忘了在本站进行查找喔。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信API网关系统(微信api接口有哪些)
下一篇:接口文档如何测试用例(接口文档如何测试用例性能)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~