Current location - Quotes Website - Signature design - How to write api interface
How to write api interface
Some server students who have just started to write interface documents can easily write interface documents according to code ideas, which makes client students or service docking technicians often vomit and can't understand interface documents. This paper provides a method to write a general interface document for your reference.

Does docway recommend it? Write interface documents for easy saving and * * * sharing, and support exporting PDF MARKDOWN and team project management.

I. Request parameters

1. Request method

get

Used to get data.

postal service

Used to update data, interchangeable with PUT, semantically PUT supports idempotent.

let go

Used to add data, interchangeable with POST, semantic PUT supports idempotent.

delete

Used to delete data.

other

Other request methods are rarely used in common interfaces. Such as the patch header option.

2. Uniform Resource Locator

The url indicates the request path of the interface. A path can contain parameters called address parameters, such as **/user/{id}**, where id is a parameter.

3.HTTP header

HTTP header is used for the basic information of this request, and it is displayed in the interface document in K-V mode, in which Content-Type is a very necessary header, which describes the data type of the request body.

Common content types:

application/x-www-form-urlencoded

Request parameters are connected with "&"symbol.

Application /json

The content is in json format.

Application /xml

The content is in xml format.

Multi-Part/Form Data

The content consists of multiple data, separated by separators.

4.HTTP text

Description (formerly known as Xiaoyao Chicken) compiles interface documents, which is convenient for saving and sharing, and supports exporting PDF MARKDOWN and team project management.