当前位置:网站首页>[development team follows] API specification
[development team follows] API specification
2022-07-04 02:44:00 【ReactSpring】
URL Use horizontal bars to separate words
/system-orders
The parameters are named after the small hump
/system-orders/{orderId}
Get the plural words used in the collection
GET /users
URL Don't use verbs in it
PUT /user/{userId}
JSON The attribute is named after the small hump
{ userName: "Mohammad Faisal" userId: "1" }
The response body should contain the number of resources
{ users: [ ... ], total: 34 }
stay GET Always accept... In operation limit and offset Parameters
GET /shops?offset=5&limit=5
- Add one fields Parameters , Public only API Required fields in
Return only the name of the store , Address and contact information .
GET /shops?fields=id,name,address,contact
adopt HTTP Ask the head to carry Token
Authorization: Bearer xxxxxx, Extra yyyyy
Always verify content type
```api
content-type: application/json
```
Yes CRUD Function USES HTTP Method
GET: Retrieve the representation of the resource . POST: Create new resources and sub resources . PUT: Update existing resources . PATCH: Update existing resources , It only updates the fields provided , Without updating other fields . DELETE: Delete existing resources .
In nested data URL Use in HTTP Method
GET /shops/2/products: from shop 2 Get a list of all products . GET /shops/2/products/31: Get product 31 Details of , product 31 Belong to shop 2. DELETE /shops/2/products/31: Products should be deleted 31, It belongs to the store 2. PUT /shops/2/products/31: Products should be updated 31 Information about , Only in resource-URL Upper use PUT, It's not a collection . POST /shops: A new store should be created , And return the details of the new store created . In collection url Upper use POST.
CORS Cross-domain resource sharing
It must be for all public oriented API Support CORS( Cross source resource sharing ) Head . Consider support CORS Allow the “*” source , And through effective OAuth Token forced authorization . Avoid combining user credentials with original authentication .
Security
At all endpoints 、 Implement on resources and services HTTPS(tls encryption ). Force and require all callbacks url、 Push notification endpoint and webhooks Use HTTPS.
General principles
Flat is better than nested . Simplicity is better than complexity . Strings are better than numbers . Consistency is better than customization .
边栏推荐
- Jenkins continuous integration environment construction V (Jenkins common construction triggers)
- Problems and solutions of several concurrent scenarios of redis
- PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation
- Pagoda SSL can't be accessed? 443 port occupied? resolvent
- Méthode de calcul de la connexion MSSQL de la carte esp32c3
- Enhanced for loop
- Mysql-15 aggregate function
- The reasons why QT fails to connect to the database and common solutions
- MySQL workbench use
- Leetcode 110 balanced binary tree
猜你喜欢
Talking about custom conditions and handling errors in MySQL Foundation
LV1 tire pressure monitoring
Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog
Record a problem that soft deletion fails due to warehouse level error
Pytoch residual network RESNET
FRP intranet penetration
Final consistency of MESI cache in CPU -- why does CPU need cache
The automatic control system of pump station has powerful functions and diverse application scenarios
The reasons why QT fails to connect to the database and common solutions
AI 助力藝術設計抄襲檢索新突破!劉芳教授團隊論文被多媒體頂級會議ACM MM錄用
随机推荐
Unity controls the selection of the previous and next characters
The first spring of the new year | a full set of property management application templates are presented, and Bi construction is "out of the box"
[software implementation series] software implementation interview questions with SQL joint query diagram
17. File i/o buffer
Fudan released its first review paper on the construction and application of multimodal knowledge atlas, comprehensively describing the existing mmkg technology system and progress
The difference between int (1) and int (10)
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
PMP daily three questions (February 14, 2022)
Site favorites
Record a problem that soft deletion fails due to warehouse level error
Learn these super practical Google browser skills, girls casually flirt
[Yugong series] February 2022 attack and defense world advanced question misc-83 (QR easy)
15. System limitations and options
Sword finger offer 14- I. cut rope
Keep an IT training diary 054- opening and closing
Global and Chinese market of contour projectors 2022-2028: Research Report on technology, participants, trends, market size and share
Comment la transformation numérique du crédit d'information de la Chine passe - t - elle du ciel au bout des doigts?
A. Min Max Swap
Mysql-15 aggregate function
長文綜述:大腦中的熵、自由能、對稱性和動力學