Apsara Clouder special skills certification: API interface implementation calls

Courseware

Technology sharing pictures

Technology sharing pictures

Technology sharing pictures

Technology sharing pictures

 

Technology sharing pictures

Technology sharing pictures

 

Technology sharing pictures

 

 

 

 Technology sharing pictures

 

Technology sharing pictures

 Technology sharing pictures

Technology sharing pictures

 

Technology sharing pictures

Technology sharing pictures

 

 Technology sharing pictures

 

 Technology sharing pictures

Technology sharing pictures

Technology sharing pictures

Technology sharing pictures

About a .API

The concept 1.API

API (Application Programming Interface Application Programming Interface) is some predefined function in order to provide application developers with a set of routines based on the ability of a software or hardware to access, but without having to access the source code or understand the inner workings of the detail

2.API features

  • API is a well-defined interfaces, we can provide specific services to other software
  • API trail may include only a single function can be achieved also contain hundreds of classes, methods, global functions, data types, and constants enumerated type
  • Implementation of the API can be private, it may also be open source

3.API classification

  • Object-oriented language API 
  • API library and framework
  • API and protocol
  • API and device interface
  • web API

4. The reason for using the api

  • Fast extensions
  • Avoid "create the wheel", to improve development efficiency
  • Reduce the coupling between modules

Two authentication request .api

1.web api protocol and http request

1.1 web api is generally used as the underlying protocol http, http request mechanism is as follows:

The client sends a request to the server, the server to the client a response, the client can tell if requested to complete its work

1.2 http request content included

  • Client: url (api address request), the request mode, headers (first request), body (request form)
  • request header headers: provide meta-information request, is a short list of items, including time client sends a request and the request body size, authentication and other information
  • request body body: the data server to a client comprising

2.api request method

  • get: server gets a request for resources
  • post: Creating a resource request to the server
  • put: requests the server to update or edit a resource
  • delete: delete a resource request to the server

3. The status return code

2xx successful return process

  • 200 ok-get: the server returns the data requested by the user successfully
  • 201 created-post / put / patch: the user to create or modify the data successfully
  • 202 accepted- * represents a request has been queued into the background (asynchronous task)
  • 204 no content-delete to delete user data successful

Server error code 5xx

  • 500 internal Error: api gateway internal error, it is recommended to retry
  • 500 Failed to invoke backend Service: api underlying service error
  • 503 service unavaliable: Service Unavailable
  • 504 async service: the back-end service timeout

Business given 4xx: parameter error generally, the wrong signature, the request mode error or flow control restrictions

4.api data format

  • json format
  • Object - key-value pairs, an array - []

5.api authentication and signature verification

5.1 Simple authentication: appcode 

Usage: Authorization Request headers added field format Authorization: APPCODE + + appcode half-size space values

5.2 Signature Verification: appkey & appsecret

Three .api commissioning and call

1.api debugging

Ali cloud api market provides online debugging function

2.api call step

Get api documentation - create an application - to get authorization - call api

3. Call api

Call api three basic conditions:

  • api
  • Application app
  • Authority relations and the app api

4.api call Precautions

  • The upper limit is 10. The number of APP at each account, app unique account name for the next application
  • Flow control to limit the call api, a single ip, qps not more than 100
  • You have the right to buy api operation and app authorization and decommissioning. Api authorized by the service provider to your app, you have no right to operate decommissioned
  • You need to include the signature information request

 

reference:

https://www.cnblogs.com/yuanpeng-java/p/10302101.html

http://www.mamicode.com/info-detail-2204294.html

Guess you like

Origin www.cnblogs.com/scriptchild/p/11868841.html