在线文档api接口(在线接口对接文档)

网友投稿 312 2023-02-18


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

本文目录一览:

什么是API接口?主要作用是什么?

API英文全称为:Application Programming Interface,中文意思是应用程序编程接口,它是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力。

主要作用:

API之主要目的是提供应用程序与开发人员以访问一组例程的能力,而又无需访问源码,或理解内部工作机制的细节。提供API所定义的功能的软件称作此API的实现。API是一种接口,故而是一种抽象。

扩展资料:

API数据接口的好处:

1、良好的接口设计可以降低系统各部分的相互依赖,提高组成单元的内聚性,降低组成单元间的耦合程度,从而提高系统的维护性和扩展性。应用程序接口是一组数量上千、极其复杂的函数和副程序,可让程序员做很多任务。

2、98数据致力于打造高质量API,除了自身的数据外,来自合作伙伴的各类API数据也是经过慎重的筛选,接口的质量和稳定性比较好,适合对接口质量和稳定性有较高要求的开发者。API数据接口作为众多开发人员进行开发工作最有效的助手,以后也会发挥着更大的作用,所以找到合适的接口才是最为重要的。

参考资料来源:百度百科-api

请教在线文档的api

Android中文版
api手册地址:http://www.matools.com/api/android

Ant最新版
api手册地址:http://www.matools.com/api/ant

ASM字节码操作
api手册地址:http://www.matools.com/api/asm

Axis2最新版
api手册地址:http://www.matools.com/api/axis2

Bash脚本
api手册地址:http://www.matools.com/api/bash

Bootstrap 3
api手册地址:http://www.matools.com/api/bootstrap3

Bootstrap 4
api手册地址:http://www.matools.com/api/bootstrap4

C/C++
api手册地址:http://www.matools.com/api/c

C3P0连接池
api手册地址:http://www.matools.com/api/c3p0

CentOS使用文档
api手册地址:http://www.matools.com/api/centos

Commons-Beanutils
api手册地址:http://www.matools.com/api/commons-beanutils

Commons-Fileupload
api手册地址:http://www.matools.com/api/commons-fileupload

Commons-IO最新版
api手册地址:http://www.matools.com/api/commons-io

Commons-Lang最新版
api手册地址:http://www.matools.com/api/commons-long

Commons-Net最新版
api手册地址:http://www.matools.com/api/commons-net

CSS 3
api手册地址:http://www.matools.com/api/css

DBCP连接池
api手册地址:http://www.matools.com/api/dbcp

Dom4j
api手册地址:http://www.matools.com/api/dom4j

dubbo中文文档
api手册地址:http://www.matools.com/api/dubbo

EhCache
api手册地址:http://www.matools.com/api/ehcache

Freemarker
api手册地址:http://www.matools.com/api/freemarker

Go语言
api手册地址:http://www.matools.com/api/go

Hadoop
api手册地址:http://www.matools.com/api/hadoop

Hibernate中文版
api手册地址:http://www.matools.com/api/hibernate

IKAnalyzer中文版
api手册地址:http://www.matools.com/api/ikanalyzer

Java 10
api手册地址:http://www.matools.com/api/java10

Java 6
api手册地址:http://www.matools.com/api/java6

Java 7
api手册地址:http://www.matools.com/api/java7

Java 8中文版
api手册地址:http://www.matools.com/api/java8

jqGrid中文版
api手册地址:http://www.matools.com/api/jqgrid

Jquery中文版
api手册地址:http://www.matools.com/api/jquery

Json-lib
api手册地址:http://www.matools.com/api/json-lib

Junit4最新版
api手册地址:http://www.matools.com/api/junit

Kryo
api手册地址:http://www.matools.com/api/kryo

Log4j最新版
api手册地址:http://www.matools.com/api/log4j

Lucene
api手册地址:http://www.matools.com/api/lucene

Maven
api手册地址:http://www.matools.com/api/maven

Windows MFC中文版
api手册地址:http://www.matools.com/api/msdn

Mybatis
api手册地址:http://www.matools.com/api/mybatis

MySql中文版
api手册地址:http://www.matools.com/api/mysql

Netty 3.6
api手册地址:http://www.matools.com/api/netty

Nginx中文版
api手册地址:http://www.matools.com/api/nginx

OpenJPA最新版
api手册地址:http://www.matools.com/api/openjpa

PHP中文版
api手册地址:http://www.matools.com/api/php

POI-apache
api手册地址:http://www.matools.com/api/poi

QuickServer
api手册地址:http://www.matools.com/api/quickserver

redis中文参考文档
api手册地址:http://www.matools.com/api/redis

Ruby
api手册地址:http://www.matools.com/api/ruby

Ruby-library
api手册地址:http://www.matools.com/api/ruby-library

Ruby on Rails
api手册地址:http://www.matools.com/api/rubyonrails

Shiro
api手册地址:http://www.matools.com/api/shiro

Spring最新版
api手册地址:http://www.matools.com/api/spring

Spring for Android
api手册地址:http://www.matools.com/api/spring-android

Spring Boot
api手册地址:http://www.matools.com/api/spring-boot

Spring Cloud中文文档
api手册地址:http://www.matools.com/api/spring-cloud

Spring Security
api手册地址:http://www.matools.com/api/spring-security

Spring中文版
api手册地址:http://www.matools.com/api/spring-zh

Struts 2最新版
api手册地址:http://www.matools.com/api/struts2

Taperstry
api手册地址:http://www.matools.com/api/taperstry

TensorFlow中文
api手册地址:http://www.matools.com/api/tensorflow

Tomcat
api手册地址:http://www.matools.com/api/tomcat

Ubuntu
api手册地址:http://www.matools.com/api/ubuntu

Velocity 1.7
api手册地址:http://www.matools.com/api/velocity

VelocityTools2.0
api手册地址:http://www.matools.com/api/velocity-tools

Vue Router中文参考
api手册地址:http://www.matools.com/api/vue-router

vue.js中文文档
api手册地址:http://www.matools.com/api/vuejs

XMLBeans
api手册地址:http://www.matools.com/api/xmlbeans

Yahoo UI中文版
api手册地址:http://www.matools.com/api/yui

Zend Framework中文版
api手册地址:http://www.matools.com/api/zend-framework

Zookeeper
api手册地址:http://www.matools.com/api/zookeeper

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

1.1 SwaggerUI
SwaggerUI 是一个简单的Restful API 测试和文档工具。简单、漂亮、易用(官方demo)。通过读取JSON 配置显示API. 项目本身仅仅也只依赖一些 html,css.js静态文件. 你可以几乎放在任何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 相关展示行为的。如图:
将配置文件大概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请求头中是再好不过了。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 文档展示效果

怎么写api接口

一些刚开始写接口文档的服务端同学,很容易按着代码的思路去编写接口文档,这让客户端同学或者是服务对接方技术人员经常吐槽,看不懂接口文档。这篇文章提供一个常规接口文档的编写方法,给大家参考。


推荐使用的是docway 写接口文档,方便保存和共享,支持导出PDF MARKDOWN,支持团队项目管理。

一、请求参数

1. 请求方法

GET

用于获取数据

POST

用于更新数据,可与PUT互换,语义上PUT支持幂等

PUT

用于新增数据,可与POST互换,语义上PUT支持幂等

DELETE

用于删除数据

其他

其他的请求方法在一般的接口中很少使用。如:PATCH HEAD OPTIONS

2. URL

url表示了接口的请求路径。路径中可以包含参数,称为地址参数,如**/user/{id}**,其中id作为一个参数。

3. HTTP Header

HTTP Header用于此次请求的基础信息,在接口文档中以K-V方式展示,其中Content-Type则是一个非常必要的header,它描述的请求体的数据类型。

常用的content-type:

application/x-www-form-urlencoded

请求参数使用“”符号连接。

application/json

内容为json格式

application/xml

内容为xml格式

multipart/form-data

内容为多个数据组成,有分隔符隔开

4. HTTP Body

描述http body,依赖于body中具体的数据类型。如果body中的数据是对象类型。则需要描述对象中字段的名称、类型、长度、不能为空、默认值、说明。以表格的方式来表达最好。

示例:

二、响应参数

1. 响应 HTTP Body

响应body同请求body一样,需要描述请清除数据的类型。

另外,如果服务会根据不同的http status code 返回不同的数据结构, 也需要针对不同的http status code对内容进行描述。

三、接口说明

说明接口的应用场景,特别的注意点,比如,接口是否幂等、处理是同步方式还是异步方式等。

四、示例

上个示例(重点都用红笔圈出来,记牢了):

五、接口工具

推荐使用的是http://docway.net(以前叫小幺鸡) 写接口文档,方便保存和共享,支持导出PDF MARKDOWN,支持团队项目管理。

关于在线文档api接口和在线接口对接文档的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。 在线文档api接口的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于在线接口对接文档、在线文档api接口的信息别忘了在本站进行查找喔。

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

上一篇:Spring Boot打war包的实例教程
下一篇:java递归与非递归实现扫描文件夹下所有文件
相关文章

 发表评论

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