Making a new version of the API. Fast and easy

Communication rules the world. Interaction is needed between people and between software. Do you want an adequate response to your application request? API to help you! The need to implement an API arises in almost all projects, and over time we wonder whether it is possible to improve the current API? A sequence of specific steps and real examples is our recipe for creating a working web-API of the project.





, : « API?» , . «» , . «», .





, API. , , , , Μ† , API, API, API. .





, API . API, , , . !





API , .





, API

, API , :





  • API;





  • , API ;





  • API.





, , Β« Β» Β« Β».





API

, API:





  • 0: URI HTTP ( POST);





  • 1: URI HTTP ;





  • 2: URI, Μ† HTTP ;





  • 3: HATEOAS. .





API 0 1 , , :





  • URI, ;





  • , , HTTP ;





  • URI Μ† API;





  • URI ;





  • - URI, .





, «» , . .





, API

. API, API. , .





, , . , , .





3 API . :





  • URI (Uniform Resource Identifier);





  • ;





  • , Accept Header/Media Type.





. API .





  1. URI , . :





  • URI, URI;





  • URI, ;





  • HTTP Μ†;





  • URI, - Μ† ;





  • .





:





GET  v1/cats/{name}
      
      



2.  , HTTP – . URI.





:





GET  cats/{name}?version=v1
      
      



3.    Accept Header/Media Type , URI. :





  • , ;





  • , Postman, , Μ† HTTP .





:





GET  cats/{name}
Headers:  version=v1
      
      



, . , .





API

, . API backend, frontend . , , Swagger ( RESTful API), , Swagger UI:





, API. API :





  • 0 ( URI HTTP );





  • , API ;





  • API, API ;





  • , API.





, , , API.





 :





POST /cats       -         ( , 
           
requestBody: {          );
  "name": "Pushok"
}

POST /cats -         ;        
requestBody: {                                                                   
  "color": "white"
}

      
      



API

API, . , API :





  • Μ† ;





  • API;





  • API;





  • API API.





, , , , .





API

2 API. , , API.





, API 0 2 :





 1.  API ;





2.  , : GET, POST, PUT, DELETE;





3.  ;





 :





GET /cats -    
GET /cats/Pushok -      
                   (,     )
      
      



 4.    .





:





GET /cats?color=white -





API . . β€œ ”, . β€œ2.n”.





  :





, enum:





, Spring Framework Converter<S,T>. S T, Enum ApiVersion :





β€œ2.0”, β€œv2”. , , , enum. :





API Μ†, Μ† enum. Μ† Μ† , .





.





. -. API Swagger. , , , API.





. :





API , , . Swagger .





Swagger UI API:





:





API

0 API 2 , :





  • API, , ;





  • , API;





  • , .





, API , , , . .





API , . . ? !








All Articles