Current location - Loan Platform Complete Network - Foreign exchange account opening - Restful api interface specification
Restful api interface specification
Restful api interface specification is as follows:

1, protocol

The communication protocol between API and users always uses HTTPs protocol.

2. Domain name

You should try to deploy an API under a private domain name.

If you are sure that the API is simple and will not be further expanded, you can consider putting it under the main domain name.

3. Version control

You should put the version number of the API in the URL.

Another way is to put the version number in the HTTP header information, but it is not as convenient and intuitive as putting the URL. Github takes this approach.

4. Path (endpoint)

A path, also called an "endpoint", represents the specific URL of the API.

In RESTful architecture, each URL represents a resource, so there can be no verbs in the URL, only nouns, and the nouns used often correspond to the table names of the database. Generally speaking, the tables in the database are all "collections" of similar records, so the nouns in the API should also be plural.

For example, if there is an API that provides information about zoos, including all kinds of animals and employees, its path should be designed as follows.