How to create an API for smart? Such an api, so that creating a client for him was not a boring mechanical process, but a real adventure with elements of detective, horror and mysticism? Such api, which users will be excited about telling colleagues? Api brain-blistering, making you laugh, scream and cry? I tried to select the best practices I had to face.
{ Jacket: \[{MaterialsIds=”m1,m2”, Pockets: “p1”, Price: 12000}\], Materials: \[{Name: “Stormscale”, Color: “Tear of Elune”, InnerId=”m1”}, {Name: “Feather of Valor”, Color: “unpredictable”, InnerId=”m2”}\], Pockets:\[{Type: “Invisible”, Contents: “Soap”, InnerId="p1"}\]} }
Do not repeat.
a. Think of different systems to indicate the states of different objects. You can add color to the digital one described above: green, red, yellow.
b. Change not only the data format, but also the format for recording field names - srart_date: 25/12/05, endDay: 2012.11.23.
c. Do not forget about a huge selection of delimiters: comma, dot, semicolon. Add something non-standard to it - a percent sign or a grid.
j. The list goes on, be creative.
has_goods [-2, -1, 0, ], : [, , , ]
Add a required parameter to the query, which can have only one value.
http://example.com/myService?cloth_type=silk&and_better=1 "cloth_type" - (, , , , ), "and_better" . “ ” "and_better" (-1, 0, false, not) "and_worst" , /, , - .
http://example.com/myService?d=11.12.05&d=12.12.05&d=13.12.05&colors=green;yellow
http://example.com/myService?cats=5&dogs=4&hamsters=0 cats dogs , hamsters .
No documentation needed.
a. If you had to document, skip the most “obvious” places.
b. Do not complicate the documentation with examples.
c. Document the missing functionality, which you will definitely add later.
d. Divide the documentation into several parts and give each one only to those users who guess to ask about it.
This list is based on real events, the names are changed in the interests of confidentiality, all matches are not accidental.
PS Write about your heroes and their epic acts in the comments.
Source: https://habr.com/ru/post/344790/
All Articles