WO2016107120A1 - 一种应用程序编程接口调用方法及设备 - Google Patents

一种应用程序编程接口调用方法及设备 Download PDF

Info

Publication number
WO2016107120A1
WO2016107120A1 PCT/CN2015/082588 CN2015082588W WO2016107120A1 WO 2016107120 A1 WO2016107120 A1 WO 2016107120A1 CN 2015082588 W CN2015082588 W CN 2015082588W WO 2016107120 A1 WO2016107120 A1 WO 2016107120A1
Authority
WO
WIPO (PCT)
Prior art keywords
parameter
api
primary
value
standby
Prior art date
Application number
PCT/CN2015/082588
Other languages
English (en)
French (fr)
Inventor
江舒杭
周韡
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2016107120A1 publication Critical patent/WO2016107120A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs

Definitions

  • the invention relates to the technology of an application programming interface, in particular to a calling method and a calling device of an application programming interface.
  • API application programming interface
  • the API can provide a set of functions by calling
  • the API can implement the functionality provided by the API.
  • the public developer can develop the application (Application, APP) based on the API, and the APP can implement the function of the APP by calling the API.
  • FIG. 1 is a schematic diagram of a scenario in which an API is invoked based on an API management platform.
  • an API management platform, a terminal, and a southbound server may be included in the scenario, where the southbound server may provide one or more southbound APIs that can be invoked to the API management platform, and the southbound API may be invoked.
  • the API management platform is responsible for managing the southbound API provided by the southbound server, and provides a northbound API to invoke application calls.
  • the application can send a northbound API call request to the API management platform, and the API management platform requests the northbound API according to the received request. , determine the southbound API that needs to be called, and call the corresponding southbound API to implement the corresponding function.
  • the reliability of the API may not be guaranteed, and there is a risk that the APP developed based on the API cannot be used because the API is not available. It can be seen that the reliability of the API cannot be guaranteed. When the API is unavailable, the APP that invokes the API is unavailable, so that the reliability of the APP is not guaranteed, thereby causing the APP developer to lose the customer and directly causing the economy. loss.
  • Embodiments of the present invention provide a method and a device for calling an application programming interface, which are used to solve The reliability of the API cannot be guaranteed, and the reliability of the APP cannot be guaranteed.
  • an embodiment of the present invention provides a calling method of an application programming interface API, where the calling method is executed by an API management platform, including: receiving a main calling request from a terminal for calling a main API,
  • the primary API is a northbound API; it is detected whether the primary API is available.
  • the standby API being a northbound API, the primary API having the same functional category as the standby API
  • the detecting whether the primary API is available comprises: detecting a southbound API that needs to be invoked when the primary calling request invokes the primary API Whether it is available; when there is an unavailable southbound API in the southbound API that needs to be called when the primary calling request invokes the primary API, it is determined that the primary API is unavailable.
  • the detecting whether the primary API is available includes: detecting whether a southbound API that can be invoked when the primary API is invoked is detected Available; when there is an unavailable southbound API in the southbound API that can be called when the calling primary API is called, it is determined that the primary API is unavailable.
  • the detecting whether the primary API is available comprises: obtaining an unavailable northbound API list; and using the unavailable northbound API When the list includes the primary API, it is determined that the primary API is unavailable.
  • the unavailable northbound API list is generated by: determining that the southbound API is unavailable; according to the northbound API and the southbound API.
  • the calling relationship and the unavailable southbound API determine that the northbound API is unavailable; according to the determining, the northbound API is not available to generate the unavailable northbound API list.
  • the primary calling request includes a primary parameter and a value of the primary parameter, where the primary usage is
  • the calling request obtaining the standby call request for calling the standby API includes: determining the standby parameter corresponding to the primary parameter according to a preset correspondence between the primary parameter and the standby parameter; according to the primary parameter The value is determined to determine the value of the standby parameter; and the standby call request including the standby parameter and the value of the standby parameter is obtained.
  • the sixth possible implementation in the first aspect includes: determining that the value of the standby parameter is a value of the primary parameter; or according to the primary parameter A preset conversion rule that takes a value and a value of the standby parameter, and converts the value of the primary parameter into a value of the standby parameter.
  • the preset conversion rule of the value of the primary parameter and the value of the standby parameter includes: Calculating a rule for obtaining the value of the standby parameter by using a value of the parameter; and determining the primary parameter according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter Converting the value to the value of the standby parameter includes: calculating a value of obtaining the value of the standby parameter by using the value of the primary parameter, and calculating a value of the primary parameter, and obtaining the value The value of the standby parameter.
  • the preset conversion rule of the value of the primary parameter and the value of the standby parameter includes the primary usage a format conversion rule of the parameter and the standby parameter; converting the value of the primary parameter to the value according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter
  • the value of the standby parameter includes: performing format conversion on the value of the primary parameter according to the format conversion rule of the primary parameter and the standby parameter to obtain a value of the standby parameter.
  • the primary calling request includes a primary parameter
  • the standby calling request includes an alternate parameter
  • the calling request obtaining the alternate calling request for calling the standby API includes: using the primary parameter in the primary calling request according to a preset correspondence between the name of the primary parameter and the name of the standby parameter The name is modified to the name of the standby parameter corresponding to the primary parameter to obtain the alternate call request.
  • the primary calling request includes an active parameter
  • the standby calling request includes an alternate parameter
  • the calling request obtaining the alternate call request for invoking the standby API includes: the main in the main call request according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter The value of the parameter is converted to the value of the standby parameter to obtain the alternate call request.
  • the obtaining, by the primary calling request, an alternate call request packet for invoking an alternate API And: performing format conversion on the primary calling request according to the preset calling conversion format of the primary calling request format and the alternate calling request format, thereby obtaining the standby calling request.
  • the obtaining, by the primary calling request, an alternate calling request for calling the standby API includes: according to the primary usage Invoking a preset conversion rule of the request format and the intermediate message format, and performing format conversion on the main call request, thereby obtaining an intermediate message in an intermediate message format; and presetting according to the intermediate message format and the alternate call request format a conversion rule that formats the intermediate message to obtain the alternate call request.
  • the calling result of the standby API includes an alternate result parameter and a value of the standby result parameter
  • the result of the calling of the primary API obtained by the result of the call of the standby API includes: determining the primary result parameter corresponding to the standby result parameter according to a preset correspondence between the standby result parameter and the primary result parameter; Determining a value of the primary result parameter according to the value of the standby result parameter, thereby obtaining a calling result of the primary API including the value of the primary use parameter and the primary use parameter.
  • determining, by the value of the standby result parameter, the value of the primary usage parameter includes: determining the The value of the primary result parameter is the value of the standby result parameter; or the standby result parameter is determined according to a preset conversion rule of the value of the standby result parameter and the value of the primary use parameter. The value is converted to the value of the primary result parameter.
  • the preset conversion rule of the value of the standby result parameter and the value of the primary use parameter includes: The calculation result of the value of the standby result parameter is used to obtain a calculation rule for the value of the primary use parameter; the preset conversion rule according to the value of the standby result parameter and the value of the primary use parameter Converting the value of the standby result parameter to the value of the primary use parameter includes: calculating a rule for obtaining the value of the primary result parameter according to the value calculation by using the standby result parameter The value of the standby result parameter is calculated, and the value of the primary result parameter is obtained.
  • the preset conversion rule of the value of the standby result parameter and the value of the primary use parameter includes a a format conversion rule for the alternate result parameter and the primary result parameter; Converting the value of the standby result parameter to the preset conversion rule of the value of the primary use parameter, and converting the value of the standby result parameter to the value of the primary use parameter includes: according to the standby And a format conversion rule of the result parameter and the main result parameter, and converting the value of the standby result parameter to obtain a value of the main result parameter.
  • an embodiment of the present invention provides an application programming interface API management platform, where the API management platform includes:
  • the request receiving module is configured to receive a main call request for calling the main API, and the main API is a northbound API.
  • the detecting module is configured to detect whether the main API called by the main calling request obtained by the request obtaining module is available.
  • a requesting conversion module configured to obtain, when the detecting module detects that the primary API is unavailable, obtaining an alternate calling request for calling a standby API according to the primary calling request obtained by the request obtaining module, the standby API
  • the primary API has the same functional category as the alternate API.
  • the result obtaining module is configured to obtain a call result of the standby API.
  • a result conversion module configured to obtain a result of the calling of the primary API obtained according to the result of the calling of the standby API obtained by the module according to the result.
  • a result sending module configured to send, to the terminal, the primary API call request obtained by the result conversion module.
  • the detecting module is specifically configured to: detect whether a southbound API that needs to be invoked when the primary calling request invokes the primary API is available; When there is an unavailable southbound API in the southbound API that needs to be called when the primary calling request invokes the primary API, it is determined that the primary API is unavailable.
  • the detecting module is specifically configured to: detect whether a southbound API that can be invoked when the calling the primary API is invoked is available; When there is an unavailable southbound API in the southbound API that can be called when the calling primary API is called, it is determined that the primary API is unavailable.
  • the API management platform further includes a list generating module, where the list generating module is configured to generate The northbound API list is available, and the detecting module is specifically configured to: when the unavailable northbound API list generated by the list generating module includes the primary API, determine that the primary API is unavailable.
  • the list generating module is specifically configured to: determine that the southbound API is unavailable; and according to the calling relationship between the northbound API and the southbound API, and The unavailable southbound API determines that the northbound API is unavailable; and generates the unavailable northbound API list according to the unavailable northbound API.
  • the primary calling request includes an active parameter and a value of the primary parameter
  • the request conversion module includes: a parameter determining module, configured to determine the standby parameter corresponding to the primary parameter according to a preset correspondence between the primary parameter and the standby parameter; and the value determining module is configured to use the value of the primary parameter And determining, by the parameter determining module, a value of the standby parameter, where the message obtaining module is configured to obtain the standby parameter determined by the parameter determining module and the value of the standby parameter determined by the value determining module The alternate call request.
  • the value determining module is specifically configured to: determine a value of the standby parameter as a value of the primary parameter Or converting the value of the primary parameter to the value of the standby parameter according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter.
  • the preset conversion rule of the value of the primary parameter and the value of the standby parameter includes: Calculating a rule for obtaining the value of the standby parameter by using a value of the parameter; the value determining module according to the preset conversion rule of the value of the primary parameter and the value of the standby parameter Converting the value of the primary parameter to the value of the standby parameter includes: calculating, by the value determining module, the calculation rule and the value of the value of the standby parameter according to the value of the primary parameter The value of the primary parameter is calculated, and the value of the standby parameter is calculated.
  • the preset conversion rule of the value of the primary parameter and the value of the standby parameter includes the primary usage a format conversion rule of the parameter and the standby parameter;
  • the primary calling request includes an active parameter
  • the standby calling request includes an alternate parameter
  • the request conversion module is specifically used And: modifying a name of the primary parameter in the primary calling request to a location corresponding to the primary parameter according to a preset correspondence between a name of the primary parameter and a name of the standby parameter The name of the alternate parameter is obtained to obtain the alternate call request.
  • the primary calling request includes an active parameter
  • the standby calling request includes an alternate parameter
  • the request conversion module is specifically used Converting: the value of the primary parameter in the primary call request to the standby parameter according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter Take the value to get the alternate call request.
  • the request conversion module is specifically configured to: pre-form according to the primary call request format and the standby call request format
  • the conversion rule is set to perform format conversion on the main call request, thereby obtaining the standby call request.
  • the request conversion module is specifically configured to: perform preset conversion according to the primary call request format and an intermediate message format. a rule, the main call request is formatted to obtain an intermediate message in an intermediate message format; and the intermediate message is format converted according to the intermediate message format and a preset conversion rule of the alternate call request format , thereby obtaining the alternate call request.
  • the calling result of the standby API includes a standby result parameter and a value of the standby result parameter
  • the result conversion module The result parameter determination obtaining module is configured to determine, according to a preset correspondence relationship between the standby result parameter and the primary use result parameter, the primary use result parameter corresponding to the standby result parameter; and the result value determining module is configured to: Determining, by the value of the standby result parameter, a value of the primary result parameter determined by the parameter determining module, thereby obtaining the primary including the primary result parameter and the value of the primary use parameter The result of the call with the API.
  • the result value determining module is specifically configured to: determine that the value of the primary use parameter is the standby result And taking the value of the parameter; or converting the value of the standby result parameter to the primary result parameter according to a preset conversion rule of the value of the standby result parameter and the value of the primary use parameter Value.
  • the preset conversion rule of the value of the standby result parameter and the value of the primary use parameter includes: The calculation result of the value of the standby result parameter is used to obtain a calculation rule for the value of the primary result parameter; the result value determining module is configured according to the value of the standby result parameter and the value of the primary use parameter.
  • the preset conversion rule, the conversion of the value of the standby result parameter to the value of the primary use parameter includes: the result value determining module obtains the calculation according to the value of the parameter through the standby result
  • the calculation rule of the value of the main result parameter and the value of the standby result parameter are calculated, and the value of the main result parameter is obtained by calculation.
  • the preset conversion rule of the value of the standby result parameter and the value of the primary use parameter includes a a format conversion rule of the standby result parameter and the primary result parameter;
  • the result value determining module is configured according to a preset conversion rule of the value of the standby result parameter and the value of the primary use parameter.
  • Converting the value of the standby result parameter to the value of the primary use parameter includes: the result value determining module according to the format conversion rule of the standby result parameter and the primary use parameter, The value of the alternate result parameter is formatted to obtain the value of the primary result parameter.
  • the API management platform in the present invention can convert the calling request of the main API to obtain the calling request of the standby API when the main API is found to be unavailable, and obtain the standby API.
  • the result is called to obtain the call result of the main API, so the call result can be obtained when the main API is unavailable, and the reliability of the APP is ensured.
  • FIG. 1 is a schematic diagram of a scenario in which an application programming interface is invoked based on an API management platform in the prior art
  • FIG. 2 is a schematic diagram of an implementation scenario in accordance with some embodiments of the present invention.
  • FIG. 3 is a flow chart showing an application programming interface calling method according to some embodiments of the present invention.
  • FIG. 4 is a flow diagram of a method for calling an application programming interface in accordance with some embodiments of the present invention.
  • FIG. 5 is a schematic diagram showing the logical structure of an application programming interface management platform in accordance with some embodiments of the present invention.
  • FIG. 6 is a block diagram showing the hardware structure of a computer device in accordance with some embodiments of the present invention.
  • FIG. 2 illustrates an implementation scenario of an embodiment of the present invention.
  • the implementation scenario of the present invention includes a terminal 202, an API management platform 204, a primary API southbound server 206, and a standby API southbound server 208.
  • the primary API and the standby API are northbound APIs.
  • the terminal 202 can complete the functions required by the terminal 202 by calling the primary API. When the primary API is unavailable, the terminal 202 can also invoke the standby API to complete the functions required by the terminal 202.
  • the API management platform 204 can be a computer device such as a server or server cluster. Among them, the main API and the standby API are obtained by the developer of the application in the terminal.
  • the API management platform 204 may provide the application developer with all the northbound APIs for the developer to subscribe, or the API management platform 204 may define the features of the northbound API for each northbound API, when the developer subscribes. The features of the API that need to be subscribed will be developed, and the API management platform 204 will provide the developer with a northbound API that satisfies the features specified by the developer for the developer to subscribe.
  • the southbound API is an API provided by the service provider's southbound server.
  • the API management platform 204 can invoke the southbound API to invoke the API service provided by the service provider.
  • the northbound API is an API provided by the API management platform 204 to the application call.
  • the application cannot directly call the southbound API, and needs to call the northbound API provided by the API management platform 204.
  • the API management platform 204 parses the call request of the northbound API, and further generates a call request of the southbound API corresponding to the northbound API. API, the purpose of doing this is to complete the application calling the authentication and billing of the south to the API. After the API management platform obtains the result of the call to the southbound API, the result of converting the call result of the southbound API to the call result of the northbound API is sent to the application.
  • the terminal 202 sends a call request of the primary API to the API management platform 204 for calling the primary API to implement the functions required by the terminal 202, wherein the primary function is used.
  • the API call request is the main call request.
  • the API management platform 204 generates a call request for the southbound API corresponding to the primary API according to the received primary call request, and sends the call to the primary API southbound server 206 of the southbound API corresponding to the primary API, wherein the primary API is used.
  • the corresponding southbound API call request is the primary southbound call request.
  • the primary API south sends a primary southbound response to the API management platform 204 for responding to the primary southbound call request.
  • the API management platform 204 converts the primary southbound response to obtain a response to the primary invocation request and sends a response to the primary invocation request to the terminal 202, wherein the response of the calling request of the primary API is the primary response, the primary response Including the result of the call of the main API, the result of the call of the main API is the call result obtained by calling the main API for the main call request.
  • the terminal 202 sends a call request of the primary API to the API management platform 204 to implement the required function of the terminal 202.
  • the API management platform 204 converts the primary call request to obtain the call request of the standby API for invoking the standby API to implement the functions required by the terminal 202, wherein the call request of the standby API is an alternate call. request.
  • the API management platform 204 generates a call request from the southbound API corresponding to the standby API to the standby API southbound server 208 providing the southbound API corresponding to the standby API according to the standby call request, wherein the southbound API corresponding to the standby API is invoked.
  • the request is a request for an alternate southbound call.
  • the alternate API south sends a standby southbound response to the API management platform 204 for responding to the alternate southbound call request.
  • the API management platform 204 converts the standby southbound response to obtain a response to the alternate call request, wherein the response of the alternate call request is an alternate response, the standby response includes a result of the call of the standby API, and the result of the call of the standby API is an alternate call to the standby call request. Get the result of the call.
  • the API management platform 204 obtains the primary response according to the alternate response, which includes obtaining the result of the calling of the primary API according to the result of the call of the standby API.
  • the primary response is sent to the terminal 202 for responding to the primary call request, and the primary response includes the result of the call by the primary API.
  • the result of the call to the alternate API can be represented by an alternate result parameter in the alternate call request.
  • the result of the call to the main API can be represented by the main result parameter in the main call request.
  • the terminal 202 converts the primary call request to obtain an alternate call request.
  • Terminal 202 sends an alternate call request to API management platform 204.
  • the API management platform 204 generates a call request from the southbound API corresponding to the standby API to the standby API southbound server 208 that provides the southbound API corresponding to the standby API according to the receipt of the standby call request, wherein the southbound API corresponding to the standby API is used.
  • the call request is an alternate southbound call request.
  • the alternate API south sends a backup southbound response to the API management platform 204 to respond to the alternate southbound tone. With the request.
  • the API management platform 204 converts the alternate southbound response to obtain an alternate response and sends the alternate response to the terminal 202, the alternate response including the result of the call of the alternate API.
  • the terminal 202 converts the standby response to obtain an active response for responding to the main call request, and includes obtaining a call result of the main API according to the call result of the standby API, where the main response includes a call result of the main API.
  • FIG. 3 is a schematic flowchart diagram of a method for calling an application programming interface according to an embodiment of the present invention.
  • the application programming interface calling method may be executed by, for example, the terminal 202, or may be performed by, for example, the API management platform 204, or may be performed by, for example, the API management platform 204 and the terminal 202.
  • the method steps are as follows:
  • Step 302 Obtain a main call request for calling the main application programming interface API, and the main API is a northbound API.
  • the API management platform 204 may receive a main call request from the terminal 202 for invoking the main application programming interface API.
  • the terminal 202 may obtain a main call request for calling the main application programming interface API.
  • step 304 it is detected whether the primary API is available.
  • the API management platform 204 may determine a southbound API that needs to be invoked when the primary calling request invokes the primary API, and detects that the primary calling request invokes the primary Whether the southbound API that needs to be called when using the API is available; when there is an unavailable southbound API in the southbound API that needs to be called when the primary call request invokes the primary API, it is determined that the primary API is unavailable.
  • the technical solution does not need to determine whether all the southbound APIs that can be called by the northbound API are available, and only needs to determine whether the southbound API required for the main call request is available, thereby calling the active API more efficiently.
  • the API management platform 204 may determine a southbound API that can be invoked when the primary API is invoked, and detect the south that can be invoked when the primary API is invoked. Whether the API is available; when there is an unavailable southbound API in the southbound API that can be called when calling the main API, it is determined that the main API is not available. This technical solution solves the technical problem that it is impossible to detect whether the northbound API is available without calling the northbound API.
  • the end 202 or API management platform 204 may obtain a list of unavailable northbound APIs; when the unavailable northbound API list includes a primary API, it is determined that the primary API is unavailable.
  • the unavailable northbound API list is triggered by the API management platform 204, and the terminal 202 or the API management platform 204 can be directly obtained.
  • This technical solution makes it easier to detect whether the northbound API is available or not, as compared to the above method of detecting whether the northbound API is available.
  • the API management platform 204 can also generate an unavailable northbound API list when detecting whether the primary API is available.
  • the API management platform 204 may generate an unavailable northbound API list according to the calling relationship between the southbound API and the northbound API and the southbound API.
  • the API management platform 204 may determine that the southbound API is unavailable; determine the unavailable northbound API according to the calling relationship between the northbound API and the southbound API and the unavailable southbound API. According to the determination that the northbound API is not available, a list of unavailable northbound APIs is generated.
  • the API management platform 204 can read the database of the API management platform 204 or store the southbound API list in the storage device. The southbound API path and detect whether the southbound API corresponding to the path is available, thereby determining that the southbound API is not available. The API management platform 204 can also periodically detect whether the southbound API in the southbound API list is available, and generate an unavailable southbound API list for determining the unavailable southbound API.
  • the API management platform 204 may detect whether the northbound API to be detected corresponds to the unavailable southbound API in the calling relationship.
  • the southbound API if the northbound API to be detected corresponds to the southbound API of the southbound API in the calling relationship, the northbound API to be detected is the northbound API of the unavailable northbound API.
  • the API management platform 204 may also determine that the northbound API corresponding to the unavailable southbound API obtained according to the calling relationship is Northbound API is not available.
  • Step 306 When the primary API is unavailable, obtain an alternate call request for calling the standby API according to the primary call request.
  • the standby API is a northbound API, and the primary API has the same functional category as the standby API.
  • the active API and the standby API have the same functional category, and some or all of the functions that can be implemented by calling the active API can be implemented by calling the standby API.
  • the API management platform 204 specifies the characteristics of each northbound API when the application developer When you subscribe to the Northbound API and specify the characteristics of the Northbound API, the APIs with this feature are APIs of the same category.
  • the southbound API corresponding to the primary API and the alternate API is a southbound API provided by a different API service provider.
  • the primary call request includes the primary parameter and the value of the primary parameter, and the terminal 202 or the API
  • the management platform 204 may determine an alternate parameter corresponding to the primary parameter according to a preset correspondence between the primary parameter and the standby parameter, where the standby parameter is a parameter that can be obtained by using the value of the primary parameter to obtain an alternate call request. .
  • the value of the alternate parameter is determined according to the value of the primary parameter.
  • An alternate call request is then obtained, the alternate call request including the alternate parameter and the value of the alternate parameter.
  • the mapping between the primary parameter and the standby parameter is generated by the API management platform 204, and the terminal 202 can obtain the API management platform.
  • the API management is performed.
  • the platform generates a correspondence between the primary parameter and the standby parameter used by the API management platform 204 according to the correspondence between the primary parameter and the standby parameter specified by the developer.
  • the terminal 202 or the API management platform 204 may encapsulate the values of the standby parameter and the standby parameter according to the message format of the alternate call request to obtain an alternate call request.
  • the terminal 202 or the API management platform 204 may replace the value of the standby parameter and the standby parameter with the primary parameter in the primary call request and the primary parameter in another possible implementation manner of obtaining the standby call request. Value to get an alternate call request.
  • the replaced message is formatted to obtain an alternate call request.
  • the terminal 202 or the API management platform 204 may determine the value of the primary parameter as the value of the primary parameter, as a possible implementation manner of determining the value of the standby parameter according to the value of the primary parameter.
  • the terminal 202 or the API management platform 204 may also take the value of the preset primary parameter and the value of the standby parameter according to another possible implementation manner of determining the value of the standby parameter according to the value of the primary parameter.
  • the conversion rule converts the value of the primary parameter to the value of the alternate parameter.
  • the conversion rule of the value of the primary parameter and the value of the standby parameter is generated by the API management platform 204, and the terminal 202 can obtain the API management platform.
  • the conversion rule of the value of the primary parameter and the value of the standby parameter may include a calculation rule of the value of the primary parameter and the value of the standby parameter, and the terminal 202 or the API management platform 204
  • the value of the primary parameter can be used to calculate the value of the standby parameter according to the value of the primary parameter and the calculation rule of the applied standby parameter.
  • the conversion rule of the value of the primary parameter and the value of the standby parameter may further include a format conversion rule of the format of the primary parameter and the standby parameter, and the terminal 202 or the API management platform 204 may also According to the format of the primary parameter and the format conversion rule of the alternate parameter, the value of the primary parameter is formatted to obtain the value of the alternate parameter.
  • the terminal 202 or the API management platform 204 may further perform a format conversion rule according to the format of the primary parameter and the backup parameter, and a calculation rule of the value of the primary parameter and the value of the standby parameter.
  • the value of the primary parameter is calculated, and the obtained value is formatted to obtain the value of the standby parameter; or the terminal 202 or the API management platform 204 formats the value of the primary parameter, and then obtains the obtained value.
  • the value calculates the value of the alternate parameter.
  • the main call request includes an active parameter
  • the standby call request includes an alternate parameter
  • the terminal 202 or The API management platform 204 may also modify the name of the primary parameter in the primary calling request to the name of the standby parameter corresponding to the primary parameter according to the preset correspondence between the primary parameter and the standby parameter to obtain an alternate calling request.
  • the replaced message is formatted to obtain an alternate call request.
  • the main call request includes an active parameter
  • the standby call request includes an alternate parameter
  • the terminal 202 or The API management platform 204 may also convert the value of the primary parameter in the primary calling request to the value of the standby parameter according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter to obtain the backup. Call the request.
  • the replaced message is formatted to obtain an alternate call request.
  • the terminal 202 or the API management platform 204 may also be configured according to The preset primary call request format and the alternate call request format conversion rule convert the main call request into a format, thereby obtaining an alternate call request.
  • the conversion rule of the primary call request format and the alternate call request format is generated by the API management platform 204, and the terminal 202 can be obtained by the API management platform 204.
  • the terminal 202 or the API management platform 204 may also according to the main calling request format and the preset standard message.
  • the format conversion rule converts the main call request format to obtain a message formatted as a standard message format; according to a preset standard message format and an alternate call request format conversion rule, the message format is a message of a standard message format. Perform a format conversion to get an alternate call request.
  • the conversion rule of the primary call request format and the preset standard message format, the conversion rule of the preset standard message format and the alternate call request format are generated by the API management platform 204, and the terminal 202 can obtain the API management platform 204.
  • the main call request may directly invoke the standby API as an alternate call request.
  • Step 308 using an alternate call request to invoke the alternate API to obtain an alternate response for responding to the alternate call request, the alternate response including the result of the call of the alternate API.
  • the API management platform 204 obtains the standby southbound call request of the southbound API to be called by the standby call request according to the standby call request, and sends a call request to the standby API corresponding to the southbound API to be called by the standby call requester. .
  • the API management platform 204 then receives the alternate southbound response from the alternate API southbound server 208 for responding to the alternate southbound call request, and obtains an alternate response based on the alternate southbound response.
  • Step 310 The result of calling the primary API obtained according to the result of the call of the standby API.
  • the calling result of the standby API includes the value of the standby result parameter and the value of the standby result parameter
  • the terminal 202 the API management platform 204 may determine, according to the correspondence between the preset standby result parameter and the primary use result parameter, the primary result parameter corresponding to the standby result parameter, and the primary result parameter corresponding to the standby result parameter is a primary result parameter, where
  • the main result parameter is the main result parameter that can be obtained by taking the value of the alternate result parameter.
  • the value of the primary result parameter is determined according to the value of the alternate result parameter.
  • the result of calling the main API is obtained, and the calling result of the main API includes the main result parameter and the value of the main result parameter.
  • the alternate junction The correspondence between the parameter and the primary outcome parameter is generated by the API management platform 204, and the terminal 202 can be obtained from the API management platform.
  • the API management platform When the developer of the application on the terminal specifies the correspondence between the backup result parameter and the main result parameter, the API management platform generates a query for the API management platform 204 according to the correspondence between the alternate result parameter specified by the developer and the main result parameter. Correspondence between the alternate result parameter and the primary result parameter.
  • the terminal 202 or the API management platform 204 may determine that the value of the primary result parameter is the value of the standby result parameter, as a possible implementation manner of determining the value of the primary result parameter according to the value of the standby result parameter.
  • the terminal 202 or the API management platform 204 may also use the value of the preset standby result parameter and the main result as another possible implementation manner of determining the value of the primary result parameter according to the value of the standby result parameter.
  • the conversion rule of the value of the parameter converts the value of the alternate result parameter to the value of the main result parameter.
  • the conversion rule of the value of the standby result parameter and the value of the primary result parameter is generated by the API management platform 204, and the terminal 202 can obtain the API management platform.
  • the conversion rule of the value of the standby result parameter and the value of the primary use parameter may include a calculation rule of the value of the standby result parameter and the value of the primary use parameter, and the terminal 202 or The API management platform 204 may calculate the value of the primary result parameter according to the value of the alternate result parameter and the calculation rule of the value of the application primary result parameter.
  • the conversion rule of the value of the standby result parameter and the value of the primary result parameter may further include a format conversion rule of the format of the standby result parameter and the primary result parameter, and the terminal 202 or the API management
  • the platform 204 may further convert the value of the alternate result parameter according to the format of the alternate result parameter and the format conversion rule of the primary result parameter to obtain the value of the primary result parameter.
  • the terminal 202 or the API management platform 204 may further perform a format conversion rule according to the format of the standby result parameter and the value of the primary result parameter, and the value of the standby result parameter and the value of the primary use parameter.
  • the calculation rule calculates the value of the alternate result parameter, and then converts the obtained value into a format to obtain the value of the main result parameter; or the terminal 202 or the API management platform 204 formats the value of the alternate result parameter, and then Use the obtained values to calculate the value of the main result parameter.
  • the calling result of the standby API may be directly used as the primary The result of the API call.
  • step 312 the primary response including the result of the calling of the primary API is sent to the terminal for responding to the primary calling request.
  • the step is performed by the API management platform 204, and the API management platform transmits to the terminal 202 an active response for responding to the active call request including the result of the call of the primary API.
  • the API management platform 204 may encapsulate the values of the primary outcome parameter and the primary outcome parameter in a message format of the primary response to obtain a primary response.
  • the API management platform 204 also replaces the value of the primary result parameter and the primary result parameter with the value of the alternate result parameter and the value of the alternate result parameter in the standby response. Get the primary response.
  • the replaced message is format converted to obtain the primary response.
  • the API management platform can directly use the alternate response as the primary response.
  • the value of the primary parameter, the standby parameter, the primary result parameter, or the alternate result parameter may be a numerical value or an identifier for inter-device dialogue.
  • the primary parameter is the parameter of the calling request
  • the standby parameter is the parameter of the standby call request
  • the primary result parameter is the parameter of the calling result of the primary API
  • the standby result parameter is the parameter of the calling result of the standby API
  • the calling request of the primary API is converted to obtain a call request of the standby API, and the obtained standby API is invoked.
  • the request to call the standby API to provide the required service for the APP that calls the main API, thereby ensuring the reliability of the APP.
  • the method for detecting the downtime provided by the embodiment of the present invention is further described below with reference to the method of detecting the machine provided in FIG.
  • FIG. 4 is a schematic flowchart of a method for calling an application programming interface according to an embodiment of the present invention. The method steps are as follows:
  • Step 401 Obtain a main call request for calling the main application programming interface API, and the main API is a northbound API.
  • the API management platform 204 may receive a main call request from the terminal 202 for invoking the main application programming interface API.
  • the primary invocation request from terminal 202 is forwarded by the application server to API management platform 204.
  • the terminal 202 may obtain a main call request for calling the main application programming interface API.
  • Step 402 Detect whether the primary API is available.
  • the API management platform 204 can obtain the southbound API required to invoke the primary calling request, and detect the southbound call required for the primary calling request. Whether the API is available or not, it is determined that the primary API is unavailable when the southbound API of the primary call request is called to be unavailable. The technical solution does not need to determine whether all the southbound APIs that can be called by the northbound API are available, and only needs to determine whether the southbound API required for the main call request is available, thereby calling the active API more efficiently.
  • the API management platform 204 may check, according to the orchestration logic, a southbound API that is called by the main call to invoke the request, and the orchestration logic is used to indicate an operation performed on the main call request and an operation sequence to be called according to the main use.
  • Request a call to the south to the API.
  • the method for detecting whether the southbound API is available is that the API management platform 204 can extract the southbound API from the database or storage device of the API management platform 202, and perform heartbeat detection on the southbound API to detect whether the southbound API is It can be used, for example, to send a GET request or use a dedicated heartbeat channel for heartbeat detection to detect whether the southbound API is available.
  • the API management platform 204 may obtain a southbound API that can be called by the calling primary API, and detect the southbound direction that can be called by calling the primary API. Whether the API is available or not, and when the southbound API that can be called by the calling API is unavailable, it is determined that the primary API is unavailable.
  • the technical solution solves the problem that the northbound API cannot be detected without calling the northbound API.
  • the API management platform 204 may obtain the southbound API that can be called by the main API according to the orchestration logic, according to the calling relationship between the southbound API and the northbound API in the orchestration logic.
  • the calling relationship between the southbound API and the northbound API is used to indicate the southbound API that can be called by the northbound API, and the northbound API for instructing the call to the southbound API, and the southbound API and the northbound API.
  • the calling relationship can be recorded in the form of a table and queried.
  • API management The platform 204 can invoke the main API using the main invocation request. If the response to the main invocation request is not available, the main API is not available.
  • the primary API is a northbound API
  • the terminal 202 or the API management platform 204 can obtain a list of unavailable northbound APIs; When the main API is used, it is determined that the main API is not available.
  • the unavailable northbound API list is triggered by the API management platform 204, and the terminal 202 or the API management platform 204 can be directly obtained.
  • the API management platform 204 can also generate an unavailable northbound API list when detecting whether the primary API is available.
  • the API management platform 204 may generate an unavailable northbound API list according to the calling relationship between the southbound API and the northbound API and the southbound API, and store the data in the database or storage device of the API management platform 204.
  • the API management platform 204 can obtain a southbound API.
  • the API management platform can be extracted from a database or a storage device of the API management platform 204, as a possible implementation manner of generating an unavailable northbound API list.
  • the path to the south API the path to the south API can be stored in a database or storage device in a list. According to the path of the southbound API, it is detected whether the southbound API is available to obtain the unavailable southbound API, the unavailable northbound API is obtained according to the calling relationship and the unavailable southbound API, and the unavailable northbound API list is generated according to the unavailable northbound API.
  • Step 403 The primary calling request includes the primary parameter and the value of the primary parameter, and the standby parameter corresponding to the primary parameter is determined according to the preset correspondence between the primary parameter and the standby parameter.
  • the correspondence between the primary parameter and the standby parameter is used to indicate an alternate parameter that can be obtained by combining the primary parameter or the primary parameter, and the primary parameter and the standby parameter may have more correspondences, that is, there may be multiple
  • the primary parameter corresponds to an alternate parameter, and there may be one primary parameter corresponding to multiple standby parameters, or one primary parameter corresponding to one standby parameter.
  • the value of the primary parameter represents a matrix of multiple values, multiple values, multiple values, or multiple values.
  • Step 404 Determine the value of the standby parameter according to the value of the primary parameter.
  • the value of the alternate parameter represents a matrix of multiple values, multiple values, multiple values, or multiple values.
  • the terminal 202 or the API management platform 204 may determine the value of the primary parameter as the value of the primary parameter, as a possible implementation manner of determining the value of the standby parameter according to the value of the primary parameter.
  • the terminal 202 or the API management platform 204 may also be based on the value of the preset primary parameter, as another possible implementation manner of determining the value of the standby parameter according to the value of the primary parameter.
  • the conversion rule of the value of the alternate parameter converts the value of the primary parameter to the value of the alternate parameter.
  • Step 405 obtaining an alternate call request for invoking the standby API, the standby API is a northbound API, and the standby call request includes an alternate parameter and a value of the standby parameter.
  • the terminal 202 or the API management platform 204 may encapsulate the values of the standby parameter and the standby parameter according to the message format of the alternate call request to obtain an alternate call request.
  • the API management platform 204 may also encapsulate the parameters required by the alternate call request but not included in the standby parameter. The default value is filled in to obtain the values of the parameters and parameters that are needed to encapsulate the alternate call request but are not included in the alternate parameters.
  • the terminal 202 or the API management platform 204 may replace the value of the standby parameter and the standby parameter with the primary parameter in the primary call request and the primary parameter in another possible implementation manner of obtaining the standby call request. Value to get an alternate call request.
  • Step 406 Use an alternate call request to invoke an alternate API to obtain an alternate response for responding to the alternate call request, the alternate response including a result of the call of the alternate API.
  • the API management platform 204 obtains the standby southbound call request of the southbound API to be called by the standby call request according to the standby call request, and in the specific implementation process, the API management platform 204 can manage the content in the standby call and the API management.
  • the platform orchestration logic determines the southbound API to be called by the alternate invocation request.
  • the standby southbound server 208 corresponding to the southbound API to be called by the alternate call request sends a standby southbound call request to the server 208.
  • An alternate southbound response from the alternate API southbound server 208 for responding to the alternate southbound call request is then received, and an alternate response is obtained based on the alternate southbound response, the alternate response including the result of the call to the alternate API.
  • the API management platform 204 can also send an alternate call request to the network card or gateway or server for forwarding the API call request, and receive an alternate call request sent back by the network card or the gateway or the server.
  • Step 407 The call result of the standby API includes the value of the standby result parameter and the standby result parameter, and the primary result parameter corresponding to the standby result parameter is determined according to the preset correspondence relationship between the standby result parameter and the primary use result parameter.
  • the correspondence between the standby result parameter and the primary use result parameter is used to indicate the primary result parameter that can be obtained by the combination of the alternate result parameter or the alternate result parameter, and the alternate result parameter and the primary use parameter may have more correspondences. , that is, there may be multiple alternate result parameters corresponding to one
  • the primary result parameter may also have one alternate result parameter corresponding to multiple primary use result parameters, or one spare result parameter corresponding to one primary use result parameter.
  • the value of the alternate result parameter represents a matrix of multiple values, multiple values, multiple values, or multiple values.
  • Step 408 Determine the value of the main result parameter according to the value of the standby result parameter, thereby obtaining a calling result of the main API including the value of the main result parameter and the main result parameter.
  • the value of the primary result parameter represents a matrix of multiple values, multiple values, multiple values, or multiple values.
  • the terminal 202 or the API management platform 204 may determine that the value of the primary result parameter is the value of the standby result parameter, as a possible implementation manner of determining the value of the primary result parameter according to the value of the standby result parameter.
  • the terminal 202 or the API management platform 204 may also use the value of the preset standby result parameter and the main result as another possible implementation manner of determining the value of the primary result parameter according to the value of the standby result parameter.
  • the conversion rule of the value of the parameter converts the value of the alternate result parameter to the value of the main result parameter.
  • the API management platform 204 can also obtain the primary response, the primary response includes the calling result of the primary API, and the calling result of the primary API includes the primary result parameter and the value of the primary result parameter.
  • the API management platform 204 may encapsulate the values of the primary outcome parameter and the primary outcome parameter in a message format of the primary response to obtain a primary response.
  • the API management platform 204 may also encapsulate the primary response but is not included in the The parameters of the main result parameter are filled in with default values, so as to obtain the values of the parameters and parameters that are required for the package main response but are not included in the main result parameter.
  • the API management platform 204 may also replace the values of the primary use parameter and the primary use parameter with the alternate result parameter in the standby response and the takeover of the alternate result parameter, as another possible implementation manner of obtaining the primary response. Value to get the primary response.
  • the API management platform 204 can send an active response to the terminal 202 after obtaining the primary response.
  • the embodiment of the present invention finds that the main API is unavailable, the calling request of the main API is converted to obtain a call request of the standby API, and the obtained standby API is obtained.
  • the call request invokes the alternate API to provide the required service for the APP that calls the main API, thereby ensuring the reliability of the APP.
  • FIG. 5 is a schematic diagram showing the logical structure of the calling device 500 of the application programming interface according to an embodiment of the present invention.
  • the calling device 500 of the application programming interface may be, for example, but not limited to, the terminal 202 or the API management platform 204.
  • the calling device 500 of the application programming interface includes a request obtaining module 502, a detecting module 504, a request converting module 506, a calling module 508, a response obtaining module 510, and a result converting module 512.
  • the calling device 500 of the application programming interface is the API management platform 204
  • the calling device 500 of the application programming interface further includes a response sending module 514.
  • the request obtaining module 502 is configured to obtain a main call request for calling the main application programming interface API, and the main API is a northbound API.
  • the request obtaining module 502 may be configured to receive a main call request from the terminal 202 for calling the main application programming interface API.
  • the detecting module 504 detects whether the main API called by the main calling request obtained by the request obtaining module 502 is available.
  • the detecting module 504 may be specifically configured to obtain a southbound call required for the primary calling request.
  • the API detects whether the southbound API required for the main call request is available, and determines that the primary API is unavailable when the southbound API of the primary call request is called to be unavailable.
  • the technical solution does not need to determine whether all the southbound APIs that can be called by the northbound API are available, and only needs to determine whether the southbound API required for the main call request is available, thereby calling the active API more efficiently.
  • the detecting module 504 obtains a southbound API that can be called by the calling main API, and detects the calling main. Whether the southbound API that can be called by the API is available is available. When the southbound API that can be called by the calling API is unavailable, it is determined that the primary API is unavailable. The technical solution solves the problem that it is impossible to detect whether the northbound API is available without calling the northbound API. problem.
  • detecting whether the main API is available the main API is a northbound API
  • the calling device of the application programming interface further includes list generation.
  • the module, list generation module is used to generate a list of unavailable northbound APIs.
  • the detecting module 504 is further configured to obtain an unavailable northbound API list from the list generating module, and detect whether the northbound API list has an active API, and determine that the primary API is unavailable when the northbound API list has a primary API.
  • the unavailable northbound API list is triggered by the list generation module, and the detection module 504 can directly obtain the generated.
  • the list generation module can also generate an unavailable northbound API list when detecting whether the primary API is available.
  • the API management platform 204 may generate an unavailable northbound API list according to the calling relationship between the southbound API and the northbound API and the southbound API.
  • the list generating module is specifically configured to obtain a southbound API, and detect whether the southbound API is available to obtain an unavailable southbound API, according to the calling relationship and the unavailable southbound direction.
  • the API obtains the unavailable northbound API and generates a list of unavailable northbound APIs based on the unavailable northbound API.
  • the list generating module may be specifically configured to detect whether the northbound API to be detected corresponds to the unavailable southbound direction in the calling relationship.
  • the southbound API of the API if the northbound API to be detected corresponds to the southbound API of the southbound API in the calling relationship, the northbound API to be detected is the northbound API of the unavailable northbound API.
  • the list generating module may also be specifically used for the northbound API corresponding to the unavailable southbound API obtained according to the calling relationship.
  • the northbound API for the Northbound API is not available.
  • the request conversion module 506 is configured to receive, from the detection module, a detection result that the primary API is available, and when the primary API is unavailable, obtain an alternate call request for calling the standby API according to the request for obtaining the primary call request obtained by the module, and the standby API
  • the primary API and the alternate API are APIs with the same functional categories.
  • the main call request includes the main parameter and the main parameter
  • the value, request conversion module 506 can include a parameter determination module, a value calculation module, or a message encapsulation module.
  • the parameter determining module is configured to determine an alternate parameter corresponding to the primary parameter according to a preset correspondence between the primary parameter and the standby parameter, and the standby parameter corresponding to the primary parameter is an alternate parameter.
  • the value calculation module determines the value of the standby parameter determined by the parameter determination module according to the value of the primary parameter.
  • the value calculation module may be specifically used to determine the value of the primary parameter as the value of the primary parameter, as a possible implementation manner of determining the value of the standby parameter according to the value of the primary parameter.
  • the value calculation module may also be specifically used according to the value of the preset primary parameter and the value of the standby parameter, as a possible implementation manner of determining the value of the standby parameter according to the value of the primary parameter.
  • the conversion rule converts the value of the primary parameter to the value of the alternate parameter.
  • the conversion rule of the value of the primary parameter and the value of the standby parameter may include a calculation rule of the value of the primary parameter and the value of the standby parameter, and the value calculation module may be based on the primary Use the value of the parameter and the calculation rule of the value of the applied standby parameter, and use the value of the primary parameter to calculate the value of the alternate parameter.
  • the conversion rule of the value of the primary parameter and the value of the standby parameter may further include a format conversion rule of the format of the primary parameter and the alternate parameter, and the value calculation module may also be used according to the primary The format of the parameter and the format conversion rule of the alternate parameter, and the value of the primary parameter is formatted to obtain the value of the alternate parameter.
  • the value calculation module may further use the format conversion rule of the format of the primary parameter and the alternate parameter, and the calculation rule of the value of the primary parameter and the value of the standby parameter.
  • the value of the parameter is calculated, and the obtained value is formatted to obtain the value of the standby parameter; or the terminal 202 or the API management platform 204 formats the value of the main parameter, and then uses the obtained value to calculate the standby value.
  • the value of the parameter may further use the format conversion rule of the format of the primary parameter and the alternate parameter, and the calculation rule of the value of the primary parameter and the value of the standby parameter.
  • the message encapsulating module is configured to receive the value of the standby parameter from the value calculation module, and obtain an alternate call request according to the standby parameter determined by the parameter determining module, where the standby call request includes the standby parameter and the value of the standby parameter.
  • the message encapsulating module may be specifically configured to encapsulate the value of the standby parameter and the standby parameter according to a message format of the alternate call request to obtain an alternate call request;
  • the message encapsulation module also The value of the alternate parameter and the alternate parameter can be replaced by the value of the primary parameter in the primary call request and the value of the primary parameter to obtain an alternate call request.
  • the main call request includes an active parameter
  • the standby call request includes an alternate parameter
  • the request conversion module is requested.
  • the 506 is specifically configured to modify the name of the primary parameter in the primary calling request to the name of the standby parameter corresponding to the primary parameter according to the preset correspondence between the primary parameter and the standby parameter to obtain an alternate calling request.
  • the main call request includes an active parameter
  • the standby call request includes an alternate parameter
  • the request conversion module is requested.
  • the 506 is specifically configured to convert the value of the primary parameter in the primary call request to the value of the standby parameter according to a preset conversion rule of the value of the primary parameter and the value of the standby parameter, to obtain an alternate call request. .
  • the request conversion module 506 is specifically configured to use the preset primary call request format and the alternate call according to the preset The conversion rule of the request format, the main call request is format converted, thereby obtaining an alternate call request.
  • the request conversion module 506 is specifically configured to use the default call request format and the preset standard message.
  • the format conversion rule converts the main call request format to obtain a message formatted as a standard message format; according to a preset standard message format and an alternate call request format conversion rule, the message format is a message of a standard message format. Perform a format conversion to get an alternate call request.
  • the calling module 508 is configured to receive an alternate call request from the request conversion module 506 and invoke the alternate API using an alternate call request.
  • the calling module 508 may further include a southbound request generating module and a southbound request sending module.
  • the southbound request generation module is configured to obtain an alternate southbound call request of the southbound API to be called by the alternate call request according to the alternate call request.
  • the southbound request sending module is configured to send the standby southbound call request obtained from the southbound request generating module to the standby API southbound server 208 corresponding to the southbound API to be called by the standby call request.
  • the response obtaining module 510 is configured to obtain an alternate response for responding to the alternate call request, and the standby The response includes the result of the call to the alternate API.
  • the response obtaining module may further include a southward response receiving module and a southbound response converting module.
  • the southbound response receiving module is configured to receive a standby southbound response from the alternate API southbound server 208 for responding to the standby southbound call request.
  • the southbound response conversion module is configured to obtain an alternate response according to the standby southbound response obtained by the southbound response receiving module.
  • the result conversion module 512 is configured to obtain a result of the call of the standby API obtained by the response obtaining module from the result of the call of the standby API obtained by the response obtaining module 510.
  • the call result of the standby API includes the value of the standby result parameter and the value of the standby result parameter
  • the response conversion module 512 can include a result parameter determination module, a result value calculation module, or a response package module.
  • the result parameter determining module is configured to determine an active result parameter corresponding to the standby result parameter according to a correspondence between the preset standby result parameter and the primary use result parameter.
  • the result value calculation module determines the value of the main result parameter determined by the result parameter determination module according to the value of the standby result parameter.
  • the value calculation module may be used to determine the value of the primary result parameter as the value of the standby result parameter. .
  • the value calculation module may also be specifically used for the value of the preset standby result parameter and the primary result.
  • the conversion rule of the value of the parameter converts the value of the alternate result parameter to the value of the main result parameter.
  • the conversion rule of the value of the standby result parameter and the value of the primary use parameter may include a calculation rule of the value of the standby result parameter and the value of the primary result parameter, and the result is a value.
  • the calculation module can calculate the value of the main result parameter according to the calculation rule of the value of the standby result parameter and the value of the application main result parameter, and the value of the standby result parameter.
  • the conversion rule of the value of the standby result parameter and the value of the primary result parameter may further include a format conversion of the format of the standby result parameter and the format of the primary result parameter.
  • the rule, the result value calculation module may further convert the value of the alternate result parameter according to the format of the alternate result parameter and the format conversion rule of the primary result parameter to obtain the value of the primary result parameter.
  • the result value calculation module may further perform a format conversion rule according to the format of the standby result parameter and the primary result parameter, and a value of the standby result parameter and a value of the primary use parameter.
  • the calculation rule calculates the value of the alternate result parameter, and then converts the obtained value into a format to obtain the value of the main result parameter; or the terminal 202 or the API management platform 204 formats the value of the alternate result parameter, and then Use the obtained values to calculate the value of the main result parameter.
  • the calling device 500 of the application programming interface may further include a response sending module 514, and the response sending module 514 is configured to send the result conversion module to the terminal 202.
  • the primary response of the call result of the primary API obtained by 512 is used to respond to the primary call request received by the request receiving module 502.
  • the response sending module 514 replaces the values of the primary outcome parameter and the primary outcome parameter with the values of the alternate outcome parameter and the alternate outcome parameter in the alternate response to obtain a primary response and transmit to the terminal 202.
  • the replaced message is format converted to obtain the primary response.
  • the response sending module 514 can encapsulate the value of the primary result parameter and the primary result parameter in a message format of the primary response to obtain a primary response.
  • the calling device of the application programming interface finds that the main API is unavailable, the calling request of the main API is converted to obtain the calling request of the standby API, and the obtained call is obtained.
  • the call request of the standby API calls the standby API to provide the required service for the APP that calls the main API, thereby ensuring the reliability of the APP.
  • FIG. 6 is a schematic diagram showing the hardware structure of a device 600 according to an embodiment of the invention.
  • computer device 600 includes a processor 602, a memory 604, an input/output interface 606, a communication interface 608, and a bus 610.
  • the processor 602, the memory 604, the input/output interface 606, and the communication interface 608 implement a communication connection with each other through the bus 610.
  • the processor 602 can be a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • the memory 604 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
  • Memory 604 can store operating systems and other applications.
  • the program code for implementing the technical solution provided by the embodiment of the present invention is stored in the memory 604 and executed by the processor 602.
  • the input/output interface 606 is for receiving input data and information, and outputting data such as operation results.
  • Communication interface 608 implements communication between computer device 600 and other devices or communication networks using transceivers such as, but not limited to, transceivers.
  • Bus 610 can include a path for communicating information between various components of computer device 600, such as processor 602, memory 604, input/output interface 606, and communication interface 608.
  • Computer device 600 illustrated in FIG. 6 only shows the processor 602, the memory 604, the input/output interface 606, the communication interface 608, and the bus 610, those skilled in the art will appreciate in the specific implementation process.
  • Computer device 600 also includes other devices necessary to achieve normal operation, such as a display screen.
  • computer device 600 may also include hardware devices that implement other additional functions, depending on the particular needs.
  • computer device 600 may also only include the components necessary to implement embodiments of the present invention, and does not necessarily include all of the devices shown in FIG.
  • the apparatus shown in FIG. 6 and the above description may be the terminal 202 or the API management platform 204 for performing the method in the embodiments of the present invention.
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephonic Communication Services (AREA)
  • Telephone Function (AREA)

Abstract

一种API的调用方法及管理平台,其中API的调用方法由API管理平台执行,包括:接收来自终端的用于调用主用API的主用调用请求,所述主用API为北向API;检测所述主用API是否可用(304);在所述主用API不可用时,根据所述主用调用请求获得用于调用备用API的备用调用请求,所述备用API为北向API,所述主用API与所述备用API具有相同的功能类别;使用所述备用调用请求调用所述备用API获得用于响应所述备用调用请求的备用响应,所述备用响应包括所述备用API的调用结果(308);根据所述备用API的调用结果获得的所述主用API的调用结果(310);向所述终端发送包括所述主用API的调用结果的主用响应用于响应所述主用调用请求(312)。该方法能够保证APP的可靠性。

Description

一种应用程序编程接口调用方法及设备
本申请要求于2015年1月04日提交中国专利局、申请号为201510003920.3、发明名称为“一种应用程序编程接口调用方法及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及应用程序编程接口的技术,尤其是涉及一种应用程序编程接口的调用方法及调用设备。
背景技术
当前应用编程接口(Application Programming Interface,API)经济大规模兴起,由此衍生出了大量的API提供者把自己的API通过API管理平台向公众开发者开放,API可以提供一组功能,通过调用该API可以实现API提供的功能。公众开发者就可以基于API自行开发应用程序(Application,APP),APP可以通过调用API实现APP的功能。
图1是一种基于API管理平台调用API的场景示意图。如图1所示,在该场景中可以包括API管理平台、终端和南向服务器,其中南向服务器可以向API管理平台提供一个或多个可以被调用的南向API,南向API可以被调用从而实现相应的功能。API管理平台负责管理南向服务器提供的南向API,并提供北向API以供应用程序调用,应用程序可以向API管理平台发送北向API的调用请求,API管理平台根据收到的北向API的调用请求,确定需要调用的南向API,从而调用相应的南向API实现相应的功能。
API的可靠性可能得不到保证,存在着因为API不可用而造成基于该API开发得到的APP无法使用的风险。由此可见,由于API的可靠性不能得到保证,当API不可用时,使得调用该API的APP不可用,使得APP的可靠性得不到保证,从而给APP开发者带来客户流失,直接造成经济损失。
发明内容
本发明实施例提供了一种应用程序编程接口调用的方法及设备,用以解 决API的可靠性不能得到保证造成的APP可靠性不能得到保证的问题。
第一方面,本发明实施例提供了一种应用程序编程接口API的调用方法,所述调用方法由API管理平台执行,包括:接收来自终端的用于调用主用API的主用调用请求,所述主用API为北向API;检测所述主用API是否可用。在所述主用API不可用时,根据所述主用调用请求获得用于调用备用API的备用调用请求,所述备用API为北向API,所述主用API与所述备用API具有相同的功能类别;使用所述备用调用请求调用所述备用API获得所述备用API的调用结果;根据所述备用API的调用结果获得的所述主用API的调用结果;向所述终端发送所述主用API的调用结果。
结合第一方面,在第一方面第一种可能的实现方式中,所述检测所述主用API是否可用包括:检测所述主用调用请求调用所述主用API时需要调用的南向API是否可用;在所述主用调用请求调用所述主用API时需要调用的南向API中存在不可用南向API时,确定所述主用API不可用。
结合上述第一方面可能的实现方式,在第一方面第二种可能的实现方式中,所述检测所述主用API是否可用包括:检测调用所述主用API时能够调用的南向API是否可用;在所述调用所述主用API时能够调用的南向API中存在不可用南向API时,确定所述主用API不可用。
结合上述第一方面可能的实现方式,,在第一方面第三种可能的实现方式中,所述检测所述主用API是否可用包括:获得不可用北向API列表;在所述不可用北向API列表包括所述主用API时,确定所述主用API不可用。
结合上述第一方面可能的实现方式,,在第一方面第四种可能的实现方式中,所述不可用北向API列表采用如下方式生成:确定不可用南向API;根据北向API与南向API的调用关系以及所述不可用南向API确定不可用北向API;根据所述确定不可用北向API生成不可用北向API列表。
结合上述第一方面可能的实现方式,在第一方面第五种可能的实现方式中,所述主用调用请求包括主用参数以及所述主用参数的取值,所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:根据所述主用参数与备用参数的预设的对应关系确定与所述主用参数对应的所述备用参数;根据所述主用参数的取值确定所述备用参数的取值;获得包括所述备用参数以及所述备用参数的取值的所述备用调用请求。
结合上述第一方面可能的实现方式,,在第一方面第六种可能的实现方 式中,所述根据所述主用参数的取值确定所述备用参数的取值包括:确定所述备用参数的取值为所述主用参数的取值;或根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值。
结合上述第一方面可能的实现方式,在第一方面第七种可能的实现方式中,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括通过所述主用参数的取值计算获得所述备用参数的取值的计算规则;所述根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值包括:根据所述通过所述主用参数的取值计算获得所述备用参数的取值的计算规则及所述主用参数的取值,计算获得所述备用参数的取值。
结合上述第一方面可能的实现方式,在第一方面第八种可能的实现方式中,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括所述主用参数与所述备用参数的格式转换规则;所述根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值包括:根据所述主用参数与所述备用参数的格式转换规则,将所述主用参数的取值进行格式转换获得所述备用参数的取值。
结合上述第一方面可能的实现方式,在第一方面第九种可能的实现方式中,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数;所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:根据所述主用参数的名称与所述备用参数的名称的预设的对应关系,将所述主用调用请求中的所述主用参数的名称修改为所述主用参数对应的所述备用参数的名称,以获得所述备用调用请求。
结合上述第一方面可能的实现方式,在第一方面第十种可能的实现方式中,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数;所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用调用请求中的所述主用参数的取值转换为所述备用参数的取值,以获得所述备用调用请求。
结合上述第一方面可能的实现方式,在第一方面第十一种可能的实现方式中,所述根据所述主用调用请求获得用于调用备用API的备用调用请求包 括:根据所述主用调用请求格式与所述备用调用请求格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得所述备用调用请求。
结合上述第一方面可能的实现方式,在第一方面第十二种可能的实现方式中,所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:根据所述主用调用请求格式与中间消息格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得中间消息格式的中间消息;根据所述中间消息格式与所述备用调用请求格式的预设的转换规则,将所述中间消息进行格式转换,从而获得所述备用调用请求。
结合上述第一方面可能的实现方式,在第一方面第十三种可能的实现方式中,所述备用API的调用结果包括备用结果参数以及所述备用结果参数的取值,所述根据所述备用API的调用结果获得的所述主用API的调用结果包括:根据所述备用结果参数与主用结果参数的预设的对应关系确定与所述备用结果参数对应的所述主用结果参数;根据所述备用结果参数的取值确定所述主用结果参数的取值,从而获得包括所述主用结果参数以及所述主用结果参数的取值的所述主用API的调用结果。
结合上述第一方面可能的实现方式,在第一方面第十四种可能的实现方式中,所述根据所述备用结果参数的取值确定所述主用结果参数的取值包括:确定所述主用结果参数的取值为所述备用结果参数的取值;或根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值。
结合上述第一方面可能的实现方式,在第一方面第十五种可能的实现方式中,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括通过所述备用结果参数的取值计算获得所述主用结果参数的取值的计算规则;所述根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值包括:根据所述通过所述备用结果参数的取值计算获得所述主用结果参数的取值的计算规则及所述备用结果参数的取值,计算获得所述主用结果参数的取值。
结合上述第一方面可能的实现方式,在第一方面第十六种可能的实现方式中,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括所述备用结果参数与所述主用结果参数的格式转换规则;所述根据所 述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值包括:根据所述备用结果参数与所述主用结果参数的格式转换规则,将所述备用结果参数的取值进行格式转换获得所述主用结果参数的取值。
第二方面,本发明实施例提供了一种应用程序编程接口API管理平台,所述API管理平台包括:
请求接收模块,用于接收用于调用主用API的主用调用请求,所述主用API为北向API。
检测模块,用于检测所述请求获得模块获得的主用调用请求调用的主用API是否可用。
请求转换模块,用于在所述检测模块检测到所述主用API不可用时,根据所述请求获得模块获得的所述主用调用请求获得用于调用备用API的备用调用请求,所述备用API为北向API,所述主用API与所述备用API具有相同的功能类别。
调用模块,用于使用所述请求生成模块获得的备用调用请求调用所述备用API。
结果获得模块,用于获得所述备用API的调用结果。
结果转换模块,用于根据所述结果获得模块获得的备用API的调用结果获得的所述主用API的调用结果。
结果发送模块,用于向所述终端发送所述结果转换模块获得的所述主用API调用请求。
结合第二方面,在第二方面第一种可能的实现方式中,所述检测模块具体用于:检测所述主用调用请求调用所述主用API时需要调用的南向API是否可用;在所述主用调用请求调用所述主用API时需要调用的南向API中存在不可用南向API时,确定所述主用API不可用。
结合上述第二方面可能的实现方式,在第二方面第二种可能的实现方式中,所述检测模块具体用于:检测调用所述主用API时能够调用的南向API是否可用;在所述调用所述主用API时能够调用的南向API中存在不可用南向API时,确定所述主用API不可用。
结合上述第二方面可能的实现方式,在第二方面第三种可能的实现方式中,所述API管理平台还包括列表生成模块,所述列表生成模块用于生成不 可用北向API列表,所述检测模块具体用于:在所述列表生成模块生成的所述不可用北向API列表包括所述主用API时,确定所述主用API不可用。
结合上述第二方面可能的实现方式,在第二方面第四种可能的实现方式中,所述列表生成模块具体用于:确定不可用南向API;根据北向API与南向API的调用关系以及所述不可用南向API确定不可用北向API;根据所述不可用北向API生成所述不可用北向API列表。
结合上述第二方面可能的实现方式,在第二方面第五种可能的实现方式中,所述主用调用请求包括主用参数以及所述主用参数的取值,所述请求转换模块包括:参数确定模块,用于根据所述主用参数与备用参数的预设的对应关系确定所述主用参数对应的所述备用参数;取值确定模块,用于根据所述主用参数的取值确定所述参数确定模块确定的所述备用参数的取值;消息获得模块,用于获得包括所述参数确定模块确定的备用参数以及所述取值确定模块确定的所述备用参数的取值的所述备用调用请求。
结合上述第二方面可能的实现方式,在第二方面第六种可能的实现方式中,所述取值确定模块具体用于:确定所述备用参数的取值为所述主用参数的取值;或根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值。
结合上述第二方面可能的实现方式,在第二方面第七种可能的实现方式中,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括通过所述主用参数的取值计算获得所述备用参数的取值的计算规则;所述取值确定模块根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值包括:所述取值确定模块根据所述通过所述主用参数的取值计算获得所述备用参数的取值的计算规则及所述主用参数的取值,计算获得所述备用参数的取值。
结合上述第二方面可能的实现方式,在第二方面第八种可能的实现方式中,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括所述主用参数的与所述备用参数的格式转换规则;所述取值确定模块根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值包括:所述取值确定模块根据所述主用参数的与所述备用参数的格式转换规则,将所述主用参数的取值进行格式转换获得所述备用参数的取值。
结合上述第二方面可能的实现方式,在第二方面第九种可能的实现方式中,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数,所述请求转换模块具体用于:根据所述主用参数的名称与所述备用参数的名称的预设的对应关系,将所述主用调用请求中的所述主用参数的名称修改为所述主用参数对应的所述备用参数的名称,以获得所述备用调用请求。
结合上述第二方面可能的实现方式,在第二方面第十种可能的实现方式中,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数,所述请求转换模块具体用于:根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用调用请求中的所述主用参数的取值转换为所述备用参数的取值,以获得所述备用调用请求。
结合上述第二方面可能的实现方式,在第二方面第十一种可能的实现方式中,所述请求转换模块具体用于:根据所述主用调用请求格式与所述备用调用请求格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得所述备用调用请求。
结合上述第二方面可能的实现方式,在第二方面第十二种可能的实现方式中,所述请求转换模块具体用于:根据所述主用调用请求格式与中间消息格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得中间消息格式的中间消息;根据所述中间消息格式与所述备用调用请求格式的预设的转换规则,将所述中间消息进行格式转换,从而获得所述备用调用请求。
结合上述第二方面可能的实现方式,在第二方面第十三种可能的实现方式中,所述备用API的调用结果包括备用结果参数以及所述备用结果参数的取值,所述结果转换模块包括:结果参数确定获得模块,用于根据所述备用结果参数与主用结果参数的预设的对应关系确定所述备用结果参数对应的所述主用结果参数;结果取值确定模块,用于根据所述备用结果参数的取值确定所述参数确定模块确定的所述主用结果参数的取值,从而获得包括所述主用结果参数以及所述主用结果参数的取值的所述主用API的调用结果。
结合上述第二方面可能的实现方式,在第二方面第十四种可能的实现方式中,所述结果取值确定模块具体用于:确定所述主用结果参数的取值为所述备用结果参数的取值;或根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值。
结合上述第二方面可能的实现方式,在第二方面第十五种可能的实现方式中,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括通过所述备用结果参数的取值计算获得所述主用结果参数的取值的计算规则;所述结果取值确定模块根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值包括:所述结果取值确定模块根据所述通过所述备用结果参数的取值计算获得所述主用结果参数的取值的计算规则及所述备用结果参数的取值,计算获得所述主用结果参数的取值。
结合上述第二方面可能的实现方式,在第二方面第十六种可能的实现方式中,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括所述备用结果参数的与所述主用结果参数的格式转换规则;所述结果取值确定模块根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值包括:所述结果取值确定模块根据所述备用结果参数的与所述主用结果参数的格式转换规则,将所述备用结果参数的取值进行格式转换获得所述主用结果参数的取值。
从本发明提供的以上技术方案可以看出,由于本发明中API管理平台能够在发现主用API不可用时,能够将主用API的调用请求进行转换获得备用API的调用请求,并获得备用API的调用结果,从而获得该主用API的调用结果,因此能够在主用API不可用时也能获得调用结果,保证了APP的可靠性。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是现有技术中基于API管理平台调用应用程序编程接口的场景示意图;
图2是依据本发明某些实施例的实施场景的示意图;
图3是依据本发明某些实施例的应用程序编程接口调用方法的流程示意 图;
图4是依据本发明某些实施例的应用程序编程接口调用方法的流程示意图;
图5是依据本发明某些实施例的应用程序编程接口管理平台的逻辑结构示意图;
图6是依据本发明某些实施例的计算机设备的硬件结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
图2描述了一种本发明实施例的实施场景,在本发明实施场景中包括终端202、API管理平台204、主用API南向服务器206以及备用API南向服务器208。主用API和备用API为北向API,终端202可以通过调用主用API完成终端202所需功能,在主用API不可用时,终端202还可以调用备用API完成终端202所需功能。API管理平台204可以是计算机设备,如服务器或服务器集群。其中,主用API和备用API由终端中应用程序的开发者订阅得到。在具体实现过程中,API管理平台204可以向应用程序开发者提供所有的北向API供开发者订阅,也可以是API管理平台204为每个北向API定义了该北向API的特性,开发者订阅时会制定需要订阅的API的特性,API管理平台204会向开发者提供满足开发者指定的特性的北向API供开发者订阅。其中,南向API是服务提供商的南向服务器提供的API,API管理平台204可以调用南向API来调用服务提供商提供的API服务,北向API是API管理平台204提供给应用程序调用的API,应用程序不能直接调用南向API,需要调用API管理平台204提供的北向API,由API管理平台204对北向API的调用请求进行解析,进一步生成北向API对应的南向API的调用请求调用南向API,这样做的目的完成应用程序调用南向API的认证和计费等工作。当API管理平台获得南向API的调用结果后,将该南向API的调用结果转换为北向API的调用结果发送给应用程序。
在主用API为可用北向API时,终端202向API管理平台204发送主用API的调用请求用于调用主用API实现终端202所需功能,其中,主用 API的调用请求为主用调用请求。API管理平台204根据收到的主用调用请求,生成主用API对应的南向API的调用请求发往提供主用API对应的南向API的主用API南向服务器206,其中,主用API对应的南向API的调用请求为主用南向调用请求。主用API南向服务器206向API管理平台204发送主用南向响应用于响应主用南向调用请求。API管理平台204将主用南向响应进行转换获得主用调用请求的响应并将主用调用请求的响应发送给终端202,其中,主用API的调用请求的响应为主用响应,主用响应包括主用API的调用结果,主用API的调用结果为主用调用请求调用主用API获得的调用结果。
可选的,在主用API为不可用北向API时,终端202向API管理平台204发送主用API的调用请求实现终端202所需功能。API管理平台204根据收到的主用调用请求,API管理平台204将主用调用请求转换获得备用API的调用请求用于调用备用API实现终端202所需功能,其中备用API的调用请求为备用调用请求。API管理平台204根据备用用调用请求,生成备用API对应的南向API的调用请求发往提供备用API对应的南向API的备用API南向服务器208,其中,备用API对应的南向API的调用请求为备用南向调用请求。备用API南向服务器208向API管理平台204发送备用南向响应用于响应备用南向调用请求。API管理平台204将备用南向响应进行转换获得备用调用请求的响应,其中,备用调用请求的响应为备用响应,备用响应包括备用API的调用结果,备用API的调用结果为备用调用请求调用备用API获得的调用结果。API管理平台204根据备用响应获得主用响应,其中包括了根据备用API的调用结果获得主用API的调用结果。并将主用响应发送给终端202用于响应主用调用请求,主用响应包括主用API的调用结果。备用API的调用结果可以用备用调用请求中的备用结果参数表示。主用API的调用结果可以用主用调用请求中的主用结果参数表示。
可选的,在主用API为不可用北向API时,终端202将主用调用请求进行转换获得备用调用请求。终端202向API管理平台204发送备用调用请求。API管理平台204根据收到备用用调用请求,生成备用API对应的南向API的调用请求发往提供备用API对应的南向API的备用API南向服务器208,其中,备用API对应的南向API的调用请求为备用南向调用请求。备用API南向服务器208向API管理平台204发送备用南向响应用于响应备用南向调 用请求。API管理平台204将备用南向响应进行转换获得备用响应并将备用响应发送给终端202,备用响应包括备用API的调用结果。终端202将备用响应进行转换获得用于响应主用调用请求的主用响应,其中包括了根据备用API的调用结果获得主用API的调用结果,主用响应包括主用API的调用结果。
应注意,本领域的技术人员应当明白,虽然本发明可以应用于上述实施场景中,但是本发明的保护范围不受上述场景的限制。
如图3所示是本发明实施例提供的一种应用程序编程接口调用方法的流程示意图。在具体的实现过程中,应用程序编程接口调用方法可以由例如终端202来执行,也可以由例如API管理平台204来执行,也可由例如API管理平台204和终端202配合执行。该方法步骤如下:
步骤302,获得用于调用主用应用程序编程接口API的主调用请求,主用API为北向API。
可选的,具体来说,可以是API管理平台204接收来自终端202的用于调用主用应用程序编程接口API的主调用请求。
可选的,具体来说,也可以是终端202获得用于调用主用应用程序编程接口API的主调用请求。
步骤304,检测主用API是否可用。
可选的,具体来说,作为一种检测主用API是否可用的实施方式,API管理平台204可以确定主用调用请求调用主用API时需要调用的南向API,检测主用调用请求调用主用API时需要调用的南向API是否可用;在主用调用请求调用主用API时需要调用的南向API中存在不可用南向API时,确定主用API不可用。该技术方案不需要确定调用北向API所能调用的所有南向API是否可用,仅需确定主用调用请求所需调用的南向API是否可用,从而更加有效的调用主用API。
可选的,具体来说,作为另一种检测主用API是否可用的实施方式,API管理平台204可以确定调用主用API时能够调用的南向API,检测调用主用API时能够调用的南向API是否可用;在调用主用API时能够调用的南向API中存在不可用南向API时,确定主用API不可用。该技术方案解决了无法在不调用北向API的前提下检测北向API是否可用的技术问题。
可选的,具体来说,作为另一种检测主用API是否可用的实施方式,终 端202或API管理平台204可以获得不可用北向API列表;在不可用北向API列表包括主用API时,确定主用API不可用。
可选的,在具体实现过程中,不可用北向API列表被API管理平台204定时触发生成,终端202或API管理平台204可以直接获得。该技术方案使得检测北向API是否可用相比于上述检测北向API是否可用的方法更加便捷。API管理平台204也可以在检测主用API是否可用时生成不可用北向API列表。其中,API管理平台204可以根据南向API与北向API的调用关系和南向API生成不可用北向API列表。
其中,作为一种生成不可用北向API列表的可能的实现方式,API管理平台204可以确定不可用南向API;根据北向API与南向API的调用关系以及不可用南向API确定不可用北向API;根据确定不可用北向API生成不可用北向API列表。
在具体实现过程中,作为检测南向API是否可用或确定不可用南向API的可能的实现方式,API管理平台204可以读取API管理平台204的数据库或存储设备中的南向API列表中存储的南向API路径,并检测路径对应的南向API是否可用,从而确定不可用南向API。API管理平台204也可以定时检测南向API列表中的南向API是否可用,生成不可用南向API列表用于确定不可用南向API。
可选的,作为一种根据调用关系和不可用南向API确定不可用北向API的可能的实现方式,API管理平台204可以检测待检测的北向API在调用关系中是否对应不可用南向API的南向API,如果待检测的北向API在调用关系中对应不可用南向API的南向API,则待检测的北向API为不可用北向API的北向API。
可选的,作为另一种根据调用关系和不可用南向API确定不可用北向API的可能的实现方式,API管理平台204也可以确定根据调用关系获得的不可用南向API对应的北向API为不可用北向API。
步骤306,在主用API不可用时,根据主用调用请求获得用于调用备用API的备用调用请求,备用API为北向API,主用API与备用API具有相同的功能类别。具体来说,主用API与备用API为具有相同的功能类别指调用主用API的所能实现的部分或全部功能可由调用备用API来实现。在具体实现过程中,API管理平台204规定每个北向API的特性,当应用程序开发者 订阅北向API时指定了北向API的特性,则具有该特性的API都是相同类别的API。具体来说,主用API与备用API对应的南向API为不同的API服务提供商提供的南向API。
可选的,具体来说,作为一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求包括主用参数以及主用参数的取值,终端202或API管理平台204可以根据主用参数与备用参数的预设的对应关系确定与主用参数对应的备用参数,其中,备用参数为可通过主用参数的取值获得取值的备用调用请求包括的参数。并根据主用参数的取值确定备用参数的取值。然后获得备用调用请求,备用调用请求包括备用参数以及备用参数的取值。其中,主用参数与备用参数的对应关系由API管理平台204生成,终端202可以从API管理平台获得,在终端上应用程序的开发者指定了主用参数与备用参数的对应关系时,API管理平台根据开发者指定的主用参数与备用参数的对应关系生成用于API管理平台204查询的主用参数与备用参数的对应关系。
其中,作为一种获得备用调用请求的可能的实现方式,终端202或API管理平台204可以将备用参数以及备用参数的取值按备用调用请求的消息格式进行封装获得备用调用请求。
其中,作为另一种获得备用调用请求的可能的实现方式,终端202或API管理平台204也可以将备用参数以及备用参数的取值替换主用调用请求中的主用参数以及主用参数的取值,以获得备用调用请求。作为补充,在将备用参数以及备用参数的取值替换主用调用请求中的主用参数以及主用参数的取值之后,根据预设的主用调用请求格式与备用调用请求格式的转换规则,将被替换后的消息进行格式转换,从而获得备用调用请求。
其中,作为一种根据主用参数的取值确定备用参数的取值的可能的实现方式,终端202或API管理平台204可以确定备用参数的取值为主用参数的取值。
其中,作为另一种根据主用参数的取值确定备用参数的取值的可能的实现方式,终端202或API管理平台204也可以根据预设的主用参数的取值与备用参数的取值的转换规则,将主用参数的取值转换为备用参数的取值。其中,主用参数的取值与备用参数的取值的转换规则由API管理平台204生成,终端202可以从API管理平台获得。
可选的,在具体实现过程中,主用参数的取值与备用参数的取值的转换规则可以包括主用参数的取值与备用参数的取值的计算规则,终端202或API管理平台204可以根据主用参数的取值与应用备用参数的取值的计算规则,使用主用参数的取值计算备用参数的取值。
可选的,在具体实现过程中,主用参数的取值与备用参数的取值的转换规则还可以包括主用参数的格式与备用参数的格式转换规则,终端202或API管理平台204还可以根据主用参数的格式与备用参数的格式转换规则,将主用参数的取值进行格式转换获得备用参数的取值。
可选的,在具体实现过程中,终端202或API管理平台204还可以根据上述主用参数的格式与备用参数的格式转换规则以及上述主用参数的取值与备用参数的取值的计算规则将主用参数的取值进行计算,再将获得的取值进行格式转换获得备用参数的取值;或终端202或API管理平台204将主用参数的取值进行格式转换,再使用获得的取值计算备用参数的取值。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求包括主用参数,备用调用请求包括备用参数,终端202或API管理平台204也可以根据预设的主用参数与备用参数的对应关系,将主用调用请求中的主用参数的名称修改为与主用参数对应的备用参数的名称,以获得备用调用请求。作为补充,在将备用参数以及备用参数的取值替换主用调用请求中的主用参数以及主用参数的取值之后,根据预设的主用调用请求格式与备用调用请求格式的转换规则,将被替换后的消息进行格式转换,从而获得备用调用请求。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求包括主用参数,备用调用请求包括备用参数,终端202或API管理平台204也可以根据预设的主用参数的取值与备用参数的取值的转换规则,将主用调用请求中的主用参数的取值转换为备用参数的取值,以获得备用调用请求。作为补充,在将备用参数以及备用参数的取值替换主用调用请求中的主用参数以及主用参数的取值之后,根据预设的主用调用请求格式与备用调用请求格式的转换规则,将被替换后的消息进行格式转换,从而获得备用调用请求。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,终端202或API管理平台204也可以根据 预设的主用调用请求格式与备用调用请求格式的转换规则,将主用调用请求进行格式转换,从而获得备用调用请求。其中,主用调用请求格式与备用调用请求格式的转换规则由API管理平台204生成,终端202可以通过API管理平台204获得。
其中,在具体实现过程中,作为一种将主用调用请求进行格式转换,从而获得备用调用请求的实现方式,终端202或API管理平台204也可以根据主用调用请求格式与预设的标准消息格式的转换规则,将主用调用请求进行格式转换,从而获得消息格式为标准消息格式的消息;根据预设的标准消息格式与备用调用请求格式的转换规则,将消息格式为标准消息格式的消息进行格式转换,从而获得备用调用请求。其中,主用调用请求格式与预设的标准消息格式的转换规则、预设的标准消息格式与备用调用请求格式的转换规则由API管理平台204生成,终端202可以通过API管理平台204获得。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求可直接作为备用调用请求对备用API进行调用。
步骤308,使用备用调用请求调用备用API获得用于响应备用调用请求的备用响应,备用响应包括备用API的调用结果。
具体来说,API管理平台204根据备用调用请求获得备用调用请求所要调用的南向API的备用南向调用请求,向备用调用请求所要调用的南向API对应的备用API南向服务器208发送调用请求。然后API管理平台204接收来自备用API南向服务器208的用于响应备用南向调用请求的备用南向响应,根据备用南向响应获得备用响应。
步骤310,根据备用API的调用结果获得的主用API的调用结果。
可选的,具体来说,作为一种根据备用API的调用结果获得的主用API的调用结果的可能的实现方式,备用API的调用结果包括备用结果参数以及备用结果参数的取值,终端202或API管理平台204可以根据预设的备用结果参数与主用结果参数的对应关系确定与备用结果参数对应的主用结果参数,备用结果参数对应的主用结果参数为主用结果参数,其中,主用结果参数为可通过备用结果参数的取值获得取值的主用结果参数。并根据备用结果参数的取值确定主用结果参数的取值。然后获得主用API的调用结果,主用API的调用结果包括主用结果参数以及主用结果参数的取值。其中,备用结 果参数与主用结果参数的对应关系由API管理平台204生成,终端202可以从API管理平台获得。在终端上应用程序的开发者指定了备用结果参数与主用结果参数的对应关系时,API管理平台根据开发者指定的备用结果参数与主用结果参数的对应关系生成用于API管理平台204查询的备用结果参数与主用结果参数的对应关系。
其中,作为一种根据备用结果参数的取值确定主用结果参数的取值的可能的实现方式,终端202或API管理平台204可以确定主用结果参数的取值为备用结果参数的取值。
其中,作为另一种根据备用结果参数的取值确定主用结果参数的取值的可能的实现方式,终端202或API管理平台204也可以根据预设的备用结果参数的取值与主用结果参数的取值的转换规则,将备用结果参数的取值转换为主用结果参数的取值。其中,备用结果参数的取值与主用结果参数的取值的转换规则由API管理平台204生成,终端202可以从API管理平台获得。
可选的,在具体实现过程中,备用结果参数的取值与主用结果参数的取值的转换规则可以包括备用结果参数的取值与主用结果参数的取值的计算规则,终端202或API管理平台204可以根据备用结果参数的取值与应用主用结果参数的取值的计算规则,使用备用结果参数的取值计算主用结果参数的取值。
可选的,在具体实现过程中,备用结果参数的取值与主用结果参数的取值的转换规则还可以包括备用结果参数的格式与主用结果参数的格式转换规则,终端202或API管理平台204还可以根据备用结果参数的格式与主用结果参数的格式转换规则,将备用结果参数的取值进行格式转换获得主用结果参数的取值。
可选的,在具体实现过程中,终端202或API管理平台204还可以根据备用结果参数的格式与主用结果参数的格式转换规则以及备用结果参数的取值与主用结果参数的取值的计算规则将备用结果参数的取值进行计算,再将获得的取值进行格式转换获得主用结果参数的取值;或终端202或API管理平台204将备用结果参数的取值进行格式转换,再使用获得的取值计算主用结果参数的取值。
可选的,具体来说,作为另一种根据备用API的调用结果获得的主用API的调用结果的可能的实现方式,备用API的调用结果可直接作为主用 API的调用结果。
可选的,步骤312,向终端发送包括主用API的调用结果的主用响应用于响应主用调用请求。
具体来说,该步骤由API管理平台204执行,API管理平台向终端202发送包括主用API的调用结果的用于响应主用调用请求的主用响应。
其中,作为一种获得主用响应的可能的实现方式,API管理平台204可以将主用结果参数以及主用结果参数的取值按主用响应的消息格式进行封装获得主用响应。
其中,作为另一种获得主用响应的可能的实现方式,API管理平台204也将主用结果参数以及主用结果参数的取值替换备用响应中的备用结果参数以及备用结果参数的取值,以获得主用响应。作为补充,在将主用结果参数以及主用结果参数的取值替换备用响应中的备用结果参数以及备用结果参数的取值之后,根据预设的备用响应格式与主用响应格式的转换规则,将被替换后的消息进行格式转换,从而获得主用响应。
其中,作为另一种获得主用响应的可能的实现方式,API管理平台可以直接将备用响应作为主用响应。
作为补充的,主用参数、备用参数、主用结果参数或备用结果参数的取值可以是数值、也可以是用于设备间对话的标识。
作为补充的,主用参数为主用调用请求的参数,备用参数为备用调用请求的参数,主用结果参数为主用API的调用结果的参数,备用结果参数为备用API的调用结果的参数。
有关本发明实施例与上文中相同内容的详细描述已经在上文进行了详细的描述,因此此处不再赘述。
从本发明实施例提供的以上技术方案可以看出,由于本发明实施例在主用API不可用时,将主用API的调用请求进行转换获得备用API的调用请求,并将获得的备用API的调用请求调用备用API从而为调用主用API的APP提供所需的服务,从而保证APP的可靠性。
下面结合图3中提供的宕机检测方法对本发明实施例提供的宕机检测方法进行进一步的描述。
可选的,图4是本发明实施例提供的一种应用程序编程接口的调用方法的流程示意图。该方法步骤如下:
步骤401,获得用于调用主用应用程序编程接口API的主调用请求,主用API为北向API。
可选的,具体来说,可以是API管理平台204接收来自终端202的用于调用主用应用程序编程接口API的主调用请求。在具体实现过程中,该来自终端202的主用调用请求由应用程序服务器转发至API管理平台204。
可选的,具体来说,也可以是终端202获得用于调用主用应用程序编程接口API的主调用请求。
步骤402,检测主用API是否可用。
可选的,具体来说,作为一种检测主用API是否可用的实施例,API管理平台204可以获得主用调用请求所需调用的南向API,检测主用调用请求所需调用的南向API是否可用,在主用调用请求所需调用的南向API存在南向API不可用时,确定主用API不可用。该技术方案不需要确定调用北向API所能调用的所有南向API是否可用,仅需确定主用调用请求所需调用的南向API是否可用,从而更加有效的调用主用API。在具体实现过程中,API管理平台204可以根据编排逻辑去检查主用调用该请求所需调用的南向API,编排逻辑用于指示对主用调用请求进行的操作以及操作顺序以便根据主用调用请求进行南向API的调用。在具体的实现过程中,检测南向API是否可用的方法是,API管理平台204可以从API管理平台202的数据库或存储设备中提取南向API,对南向API进行心跳检测检测南向API是否可用,例如发GET请求或使用专用心跳通道进行心跳检测检测南向API是否可用。
可选的,具体来说,作为一种检测主用API是否可用的实施例,API管理平台204可以获得调用主用API所能调用的南向API,检测调用主用API所能调用的南向API是否可用,在调用主用API所能调用的南向API存在南向API不可用时,确定主用API不可用,该技术方案解决了无法在不调用北向API的前提下检测北向API是否可用的技术问题。在具体实现过程中,API管理平台204可以根据编排逻辑,具体根据编排逻辑中的南向API与北向API的调用关系获得主用API所能调用的南向API。其中,南向API与北向API的调用关系用于指示调用北向API所能调用的南向API,以及用于指示要实现调用南向API所需调用的北向API,并且南向API与北向API的调用关系可以用表格的形式记录并被查询。
可选的,作为一中检测主用API是否可用的可能的实现方式,API管理 平台204可以使用主用调用请求调用主用API,如果不能得到主用调用请求的响应,则主用API不可用。
可选的,具体来说,作为一种检测主用API是否可用的实施例,主用API为北向API,终端202或API管理平台204可以获得不可用北向API列表;在不可用北向API列表存在主用API时,确定主用API不可用。
可选的,在具体实现过程中,不可用北向API列表被API管理平台204定时触发生成,终端202或API管理平台204可以直接获得。API管理平台204也可以在检测主用API是否可用时生成不可用北向API列表。其中,API管理平台204可以根据南向API与北向API的调用关系和南向API生成不可用北向API列表,并存储于API管理平台204的数据库或存储设备中。
其中,作为一种生成不可用北向API列表的可能的实现方式,API管理平台204可以获得南向API,在具体实现过程中,API管理平台可以从API管理平台204的数据库或存储设备中提取出南向API的路径,南向API的路径可以以列表形式存储于数据库或存储设备中。根据南向API的路径检测南向API是否可用获得不可用南向API,根据调用关系和不可用南向API获得不可用北向API,并根据不可用北向API生成不可用北向API列表。
步骤403,主用调用请求包括主用参数以及主用参数的取值,根据预设的主用参数与备用参数的对应关系确定与主用参数对应的备用参数。
具体来说,主用参数与备用参数的对应关系用于指示主用参数或主用参数的组合可以得到的备用参数,主用参数与备用参数的可以是多对应多的情况,即可以存在多个主用参数对应一个备用参数,也可以存在一个主用参数对应多个备用参数,也可以存在一个主用参数对应一个备用参数。
具体来说,主用参数的取值表示一个值、多个值、多个值组成的向量或多个值组成的矩阵。
步骤404,根据主用参数的取值确定备用参数的取值。具体来说,备用参数的取值表示一个值、多个值、多个值组成的向量或多个值组成的矩阵。
其中,作为一种根据主用参数的取值确定备用参数的取值的可能的实现方式,终端202或API管理平台204可以确定备用参数的取值为主用参数的取值。
其中,作为另一种根据主用参数的取值确定备用参数的取值的可能的实现方式,终端202或API管理平台204也可以根据预设的主用参数的取值与 备用参数的取值的转换规则,将主用参数的取值转换为备用参数的取值。
步骤405,获得用于调用备用API的备用调用请求,备用API为北向API,备用调用请求包括备用参数以及备用参数的取值。
其中,作为一种获得备用调用请求的可能的实现方式,终端202或API管理平台204可以将备用参数以及备用参数的取值按备用调用请求的消息格式进行封装获得备用调用请求。
作为补充,在将备用参数以及备用参数的取值按备用调用请求的消息格式进行封装获得备用调用请求之前,API管理平台204还可以将封装备用调用请求所需要但并没有包括在备用参数的参数进行默认值填写,从而获得封装备用调用请求所需要但并没有包括在备用参数的参数及参数的取值。
其中,作为另一种获得备用调用请求的可能的实现方式,终端202或API管理平台204也可以将备用参数以及备用参数的取值替换主用调用请求中的主用参数以及主用参数的取值,以获得备用调用请求。
步骤406,使用备用调用请求调用备用API获得用于响应备用调用请求的备用响应,备用响应包括备用API的调用结果。
具体来说,API管理平台204根据备用调用请求获得备用调用请求所要调用的南向API的备用南向调用请求,在具体实现过程中,API管理平台204可以通过备用调用请求中的内容以及API管理平台编排逻辑确定备用调用请求所要调用的南向API。向备用调用请求所要调用的南向API对应的备用API南向服务器208发送备用南向调用请求。然后接收来自备用API南向服务器208的用于响应备用南向调用请求的备用南向响应,根据备用南向响应获得备用响应,备用响应包括备用API的调用结果。
作为补充的,API管理平台204还可以向用于转发API调用请求的网卡或网关或服务器发送备用调用请求,并接收网卡或网关或服务器回发的备用调用请求。
步骤407,备用API的调用结果包括备用结果参数以及备用结果参数的取值,根据备用结果参数与主用结果参数的预设的对应关系确定与备用结果参数对应的主用结果参数。
具体来说备用结果参数与主用结果参数的对应关系用于指示备用结果参数或备用结果参数的组合可以得到的主用结果参数,备用结果参数与主用结果参数的可以是多对应多的情况,即可以存在多个备用结果参数对应一个 主用结果参数,也可以存在一个备用结果参数对应多个主用结果参数,也可以存在一个备用结果参数对应一个主用结果参数。
具体来说,备用结果参数的取值表示一个值、多个值、多个值组成的向量或多个值组成的矩阵。
步骤408,根据备用结果参数的取值确定主用结果参数的取值,从而获得包括主用结果参数以及主用结果参数的取值的主用API的调用结果。
具体来说,主用结果参数的取值表示一个值、多个值、多个值组成的向量或多个值组成的矩阵。
其中,作为一种根据备用结果参数的取值确定主用结果参数的取值的可能的实现方式,终端202或API管理平台204可以确定主用结果参数的取值为备用结果参数的取值。
其中,作为另一种根据备用结果参数的取值确定主用结果参数的取值的可能的实现方式,终端202或API管理平台204也可以根据预设的备用结果参数的取值与主用结果参数的取值的转换规则,将备用结果参数的取值转换为主用结果参数的取值。
作为补充,API管理平台204还可以获得主用响应,主用响应包括主用API的调用结果,主用API的调用结果包括主用结果参数以及主用结果参数的取值。
其中,作为一种获得主用响应的可能的实现方式,API管理平台204可以将主用结果参数以及主用结果参数的取值按主用响应的消息格式进行封装获得主用响应。
作为补充,在将主用结果参数以及主用结果参数的取值按主用响应的消息格式进行封装获得主用响应之前,API管理平台204还可以将封装主用响应所需要但并没有包括在主用结果参数的参数进行默认值填写,从而获得封装主用响应所需要但并没有包括在主用结果参数的参数及参数的取值。
其中,作为另一种获得主用响应的可能的实现方式,API管理平台204也可以将主用结果参数以及主用结果参数的取值替换为备用响应中的备用结果参数以及备用结果参数的取值,以获得主用响应。
作为补充的,API管理平台204可以在获得主用响应之后,向终端202发送主用响应。
有关本发明实施例与上文中相同内容的详细描述已经在上文进行了详 细的描述,因此此处不再赘述。
从本发明实施例提供的以上技术方案可以看出,由于本发明实施例在发现主用API不可用时,将主用API的调用请求进行转换获得备用API的调用请求,并将获得的备用API的调用请求调用备用API,从而为调用主用API的APP提供所需的服务,从而保证APP的可靠性。
图5是依据本发明实施例的应用程序编程接口的调用装置500的逻辑结构示意图,应用程序编程接口的调用装置500可以是例如但不限于终端202或API管理平台204。如图5所示,应用程序编程接口的调用装置500包括请求获得模块502、检测模块504、请求转换模块506、调用模块508、响应获得模块510和结果转换模块512。当应用程序编程接口的调用装置500为API管理平台204时,应用程序编程接口的调用装置500还包括响应发送模块514。
请求获得模块502,用于获得用于调用主用应用程序编程接口API的主调用请求,主用API为北向API。
可选的,在应用程序编程接口的调用装置500为API管理平台204时,请求获得模块502可以是用于接收来自终端202的用于调用主用应用程序编程接口API的主调用请求。
检测模块504,检测请求获得模块502获得的主用调用请求调用的主用API是否可用。
可选的,具体来说,作为一种从请求获得模块502获得主用调用请求,检测主用API是否可用的实施例,检测模块504可以具体用于获得主用调用请求所需调用的南向API,检测主用调用请求所需调用的南向API是否可用,在主用调用请求所需调用的南向API存在南向API不可用时,确定主用API不可用。该技术方案不需要确定调用北向API所能调用的所有南向API是否可用,仅需确定主用调用请求所需调用的南向API是否可用,从而更加有效的调用主用API。
可选的,具体来说,作为一种从请求获得模块502获得主用API,检测主用API是否可用的实施例,检测模块504获得调用主用API所能调用的南向API,检测调用主用API所能调用的南向API是否可用,在调用主用API所能调用的南向API存在南向API不可用时,确定主用API不可用。该技术方案解决了无法在不调用北向API的前提下检测北向API是否可用的技术 问题。
可选的,具体来说,作为另一种从请求获得模块502获得主用API,检测主用API是否可用的实施例,主用API为北向API,应用程序编程接口的调用装置还包括列表生成模块,列表生成模块用于生成不可用北向API列表。检测模块504还用于从列表生成模块获得不可用北向API列表,并检测不可用北向API列表是否存在主用API,在不可用北向API列表存在主用API时,确定主用API不可用。
可选的,在具体实现过程中,不可用北向API列表被列表生成模块定时触发生成,检测模块504可以直接获得。该技术方案使得检测北向API是否可用相比于上述检测北向API是否可用的方法更加便捷。列表生成模块也可以在检测主用API是否可用时生成不可用北向API列表。其中,API管理平台204可以根据南向API与北向API的调用关系和南向API生成不可用北向API列表。
其中,作为一种生成不可用北向API列表的可能的实现方式,列表生成模块具体用于可以获得南向API,检测南向API是否可用获得不可用南向API,根据调用关系和不可用南向API获得不可用北向API,并根据不可用北向API生成不可用北向API列表。
可选的,作为一种根据调用关系和不可用南向API获得不可用北向API的可能的实现方式,列表生成模块可以具体用于检测待检测的北向API在调用关系中是否对应不可用南向API的南向API,如果待检测的北向API在调用关系中对应不可用南向API的南向API,则待检测的北向API为不可用北向API的北向API。
可选的,作为另一种根据调用关系和不可用南向API获得不可用北向API的可能的实现方式,列表生成模块也可以具体用于根据调用关系获得的不可用南向API对应的北向API为不可用北向API的北向API。
请求转换模块506,用于从检测模块接收主用API是否可用的检测结果,在主用API不可用时,根据请求获得模块获得的主用调用请求获得用于调用备用API的备用调用请求,备用API为北向API,主用API与备用API为具有相同的功能类别的API。
可选的,具体来说,作为一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求包括主用参数以及主用参数的取 值,请求转换模块506可以包括参数确定模块、取值计算模块或消息封装模块。
参数确定模块,用于根据预设的主用参数与备用参数的对应关系确定主用参数对应的备用参数,与主用参数对应的备用参数为备用参数。
取值计算模块,根据主用参数的取值确定参数确定模块确定的备用参数的取值。
其中,作为一种根据主用参数的取值确定备用参数的取值的可能的实现方式,取值计算模块可以具体用于确定备用参数的取值为主用参数的取值。
其中,作为一种根据主用参数的取值确定备用参数的取值的可能的实现方式,取值计算模块也可以具体用于根据预设的主用参数的取值与备用参数的取值的转换规则,将主用参数的取值转换为备用参数的取值。
可选的,在具体实现过程中,主用参数的取值与备用参数的取值的转换规则可以包括主用参数的取值与备用参数的取值的计算规则,取值计算模块可以根据主用参数的取值与应用备用参数的取值的计算规则,使用主用参数的取值计算备用参数的取值。
可选的,在具体实现过程中,主用参数的取值与备用参数的取值的转换规则还可以包括主用参数的格式与备用参数的格式转换规则,取值计算模块还可以根据主用参数的格式与备用参数的格式转换规则,将主用参数的取值进行格式转换获得备用参数的取值。
可选的,在具体实现过程中,取值计算模块还可以根据上述主用参数的格式与备用参数的格式转换规则以及上述主用参数的取值与备用参数的取值的计算规则将主用参数的取值进行计算,再将获得的取值进行格式转换获得备用参数的取值;或终端202或API管理平台204将主用参数的取值进行格式转换,再使用获得的取值计算备用参数的取值。
消息封装模块,用于从取值计算模块接收备用参数的取值,并根据参数确定模块确定的备用参数获得备用调用请求,备用调用请求包括备用参数以及备用参数的取值。
其中,作为一种获得备用调用请求的可能的实现方式,消息封装模块可以具体用于将备用参数以及备用参数的取值按备用调用请求的消息格式进行封装获得备用调用请求;
其中,作为一种获得备用调用请求的可能的实现方式,消息封装模块也 可以将备用参数以及备用参数的取值替换主用调用请求中的主用参数以及主用参数的取值,以获得备用调用请求。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求包括主用参数,备用调用请求包括备用参数,请求转换模块506具体用于根据预设的主用参数与备用参数的对应关系,将主用调用请求中的主用参数的名称修改为与主用参数对应的备用参数的名称,以获得备用调用请求。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,主用调用请求包括主用参数,备用调用请求包括备用参数,请求转换模块506具体用于根据预设的主用参数的取值与备用参数的取值的转换规则,将主用调用请求中的主用参数的取值转换为备用参数的取值,以获得备用调用请求。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,请求转换模块506具体用于根据预设的主用调用请求格式与备用调用请求格式的转换规则,将主用调用请求进行格式转换,从而获得备用调用请求。
可选的,具体来说,作为另一种根据主用调用请求获得用于调用备用API的备用调用请求的实现方式,请求转换模块506具体用于根据主用调用请求格式与预设的标准消息格式的转换规则,将主用调用请求进行格式转换,从而获得消息格式为标准消息格式的消息;根据预设的标准消息格式与备用调用请求格式的转换规则,将消息格式为标准消息格式的消息进行格式转换,从而获得备用调用请求。
调用模块508,用于从请求转换模块506接收备用调用请求,使用备用调用请求调用备用API。
具体来说,调用模块508还可以包括南向请求生成模块、南向请求发送模块。
南向请求生成模块,用于根据备用调用请求获得备用调用请求所要调用的南向API的备用南向调用请求。
南向请求发送模块,用于向备用调用请求所要调用的南向API对应的备用API南向服务器208发送从南向请求生成模块获得的备用南向调用请求。
响应获得模块510,用于获得用于响应备用调用请求的备用响应,备用 响应包括备用API的调用结果。
具体来说,响应获得模块还可以包括南向响应接收模块和南向响应转换模块。
南向响应接收模块,用于接收来自备用API南向服务器208的用于响应备用南向调用请求的备用南向响应。
南向响应转换模块,用于根据南向响应接收模块获得的备用南向响应获得备用响应。
结果转换模块512,用于从响应获得模块获得备用响应的备用API的调用结果,根据响应获得模块510获得的备用API的调用结果获得的主用API的调用结果。
可选的,具体来说,作为一种根据备用API的调用刚接过获得主用API的调用结果的实现方式,备用API的调用结果包括备用结果参数以及备用结果参数的取值,响应转换模块512可以包括结果参数确定模块、结果取值计算模块或响应封装模块。
结果参数确定模块,用于根据预设的备用结果参数与主用结果参数的对应关系确定备用结果参数对应的主用结果参数。
结果取值计算模块,根据备用结果参数的取值确定结果参数确定模块确定的主用结果参数的取值。
其中,作为一种根据备用结果参数的取值确定主用结果参数的取值的可能的实现方式,结果取值计算模块可以具体用于确定主用结果参数的取值为备用结果参数的取值。
其中,作为一种根据备用结果参数的取值确定主用结果参数的取值的可能的实现方式,结果取值计算模块也可以具体用于根据预设的备用结果参数的取值与主用结果参数的取值的转换规则,将备用结果参数的取值转换为主用结果参数的取值。
可选的,在具体实现过程中,备用结果参数的取值与主用结果参数的取值的转换规则可以包括备用结果参数的取值与主用结果参数的取值的计算规则,结果取值计算模块可以根据备用结果参数的取值与应用主用结果参数的取值的计算规则,使用备用结果参数的取值计算主用结果参数的取值。
可选的,在具体实现过程中,备用结果参数的取值与主用结果参数的取值的转换规则还可以包括备用结果参数的格式与主用结果参数的格式转换 规则,结果取值计算模块还可以根据备用结果参数的格式与主用结果参数的格式转换规则,将备用结果参数的取值进行格式转换获得主用结果参数的取值。
可选的,在具体实现过程中,结果取值计算模块还可以根据上述备用结果参数的格式与主用结果参数的格式转换规则以及上述备用结果参数的取值与主用结果参数的取值的计算规则将备用结果参数的取值进行计算,再将获得的取值进行格式转换获得主用结果参数的取值;或终端202或API管理平台204将备用结果参数的取值进行格式转换,再使用获得的取值计算主用结果参数的取值。
可选的,在应用程序编程接口的调用装置500为API管理平台204时,应用程序编程接口的调用装置500还可以包括响应发送模块514,响应发送模块514用于向终端202发送包括结果转换模块512获得的主用API的调用结果的主用响应用于响应请求接收模块502接收的主用调用请求。具体来说,响应发送模块514将主用结果参数以及主用结果参数的取值替换备用响应中的备用结果参数以及备用结果参数的取值,以获得主用响应并向终端202发送。作为补充,在将主用结果参数以及主用结果参数的取值替换备用响应中的备用结果参数以及备用结果参数的取值之后,根据预设的备用响应格式与主用响应格式的转换规则,将被替换后的消息进行格式转换,从而获得主用响应。响应发送模块514可以将主用结果参数以及主用结果参数的取值按主用响应的消息格式进行封装获得主用响应。
上述装置内的各模块之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,具体内容可参见本发明方法实施例中的叙述,此处不再赘述。
从本发明实施例提供的以上技术方案可以看出,由于应用程序编程接口的调用装置在发现主用API不可用时,将主用API的调用请求进行转换获得备用API的调用请求,并将获得的备用API的调用请求调用备用API,从而为调用主用API的APP提供所需的服务,从而保证APP的可靠性。
图6是依据本发明一实施例的设备600的硬件结构示意图。如图6所示,计算机设备600包括处理器602、存储器604、输入/输出接口606、通信接口608和总线610。其中,处理器602、存储器604、输入/输出接口606和通信接口608通过总线610实现彼此之间的通信连接。
处理器602可以采用通用的中央处理器(Central Processing Unit,CPU),微处理器,应用专用集成电路(Application Specific Integrated Circuit,ASIC),或者一个或多个集成电路,用于执行相关程序,以实现本发明实施例所提供的技术方案。
存储器604可以是只读存储器(Read Only Memory,ROM),静态存储设备,动态存储设备或者随机存取存储器(Random Access Memory,RAM)。存储器604可以存储操作系统和其他应用程序。在通过软件或者固件来实现本发明实施例提供的技术方案时,用于实现本发明实施例提供的技术方案的程序代码保存在存储器604中,并由处理器602来执行。
输入/输出接口606用于接收输入的数据和信息,输出操作结果等数据。
通信接口608使用例如但不限于收发器一类的收发装置,来实现计算机设备600与其他设备或通信网络之间的通信。
总线610可包括一通路,在计算机设备600各个部件(例如处理器602、存储器604、输入/输出接口606和通信接口608)之间传送信息。
应注意,尽管图6所示的计算机设备600仅仅示出了处理器602、存储器604、输入/输出接口606、通信接口608以及总线610,但是在具体实现过程中,本领域的技术人员应当明白,计算机设备600还包含实现正常运行所必须的其他器件,例如显示屏幕。同时,根据具体需要,本领域的技术人员应当明白,计算机设备600还可包含实现其他附加功能的硬件器件。此外,本领域的技术人员应当明白,计算机设备600也可仅仅包含实现本发明实施例所必须的器件,而不必包含图6中所示的全部器件。
图6所示的设备以及上述描述可以是终端202或API管理平台204,用于执行执行本发明实施例中的方法。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以根据计算机程序来指令相关的硬件来完成,上述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,上述的存储介质可为磁碟、光盘、只读存储记忆体(ROM:Read-Only Memory)或随机存储记忆体(RAM:Random Access Memory)等。
本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其思想;同时,对于本领域的 一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本发明的限制。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以权利要求的保护范围为准。

Claims (34)

  1. 一种应用程序编程接口API的调用方法,其特征在于,所述调用方法由API管理平台执行,所述调用方法包括:
    接收来自终端的用于调用主用API的主用调用请求,所述主用API为北向API;
    检测所述主用API是否可用;
    在所述主用API不可用时,根据所述主用调用请求获得用于调用备用API的备用调用请求,所述备用API为北向API,所述主用API与所述备用API具有相同的功能类别;
    使用所述备用调用请求调用所述备用API获得用于响应所述备用调用请求的备用响应,所述备用响应包括所述备用API的调用结果;
    根据所述备用API的调用结果获得所述主用API的调用结果;
    向所述终端发送包括所述主用API的调用结果的主用响应用于响应所述主用调用请求。
  2. 根据权利要求1所述的应用程序编程接口的调用方法,其特征在于,所述检测所述主用API是否可用包括:
    检测所述主用调用请求调用所述主用API时需要调用的南向API是否可用;
    在所述主用调用请求调用所述主用API时需要调用的南向API中存在不可用南向API时,确定所述主用API不可用。
  3. 根据权利要求1所述的应用程序编程接口的调用方法,其特征在于,所述检测所述主用API是否可用包括:
    检测调用所述主用API时能够调用的南向API是否可用;
    在所述调用所述主用API时能够调用的南向API中存在不可用南向API时,确定所述主用API不可用。
  4. 根据权利要求1所述的应用程序编程接口的调用方法,其特征在于,
    所述检测所述主用API是否可用包括:
    获得不可用北向API列表;
    在所述不可用北向API列表包括所述主用API时,确定所述主用API不可用。
  5. 根据权利要求4所述的应用程序编程接口的调用方法,其特征在于, 所述不可用北向API列表采用如下方式生成:
    确定不可用南向API;
    根据北向API与南向API的调用关系以及所述不可用南向API确定不可用北向API;
    根据所述确定不可用北向API生成不可用北向API列表。
  6. 根据权利要求1至5任一所述的应用程序编程接口的调用方法,其特征在于,所述主用调用请求包括主用参数以及所述主用参数的取值,所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:
    根据所述主用参数与备用参数的预设的对应关系确定与所述主用参数对应的所述备用参数;
    根据所述主用参数的取值确定所述备用参数的取值;
    获得包括所述备用参数以及所述备用参数的取值的所述备用调用请求。
  7. 根据权利要求6所述的应用程序编程接口的调用方法,其特征在于,所述根据所述主用参数的取值确定所述备用参数的取值包括:
    确定所述备用参数的取值为所述主用参数的取值;或
    根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值。
  8. 根据权利要求7所述的应用程序编程接口的调用方法,其特征在于,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括通过所述主用参数的取值计算获得所述备用参数的取值的计算规则。
  9. 根据权利要求7所述的应用程序编程接口的调用方法,其特征在于,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括所述主用参数与所述备用参数的格式转换规则。
  10. 根据权利要求1至5任一所述的应用程序编程接口的调用方法,其特征在于,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数;
    所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:
    根据所述主用参数的名称与所述备用参数的名称的预设的对应关系,将所述主用调用请求中的所述主用参数的名称修改为所述主用参数对应的所述备用参数的名称,以获得所述备用调用请求。
  11. 根据权利要求1至5任一所述的应用程序编程接口的调用方法,其特征在于,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数;
    所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:
    根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用调用请求中的所述主用参数的取值转换为所述备用参数的取值,以获得所述备用调用请求。
  12. 根据权利要求1至5任一所述的应用程序编程接口的调用方法,其特征在于,所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:
    根据所述主用调用请求格式与所述备用调用请求格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得所述备用调用请求。
  13. 根据权利要求1至5任一所述的应用程序编程接口的调用方法,其特征在于,所述根据所述主用调用请求获得用于调用备用API的备用调用请求包括:
    根据所述主用调用请求格式与中间消息格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得中间消息格式的中间消息;
    根据所述中间消息格式与所述备用调用请求格式的预设的转换规则,将所述中间消息进行格式转换,从而获得所述备用调用请求。
  14. 根据权利要求2至13任一所述的应用程序编程接口的调用方法,其特征在于,所述备用API的调用结果包括备用结果参数以及所述备用结果参数的取值,所述根据所述备用API的调用结果获得的所述主用API的调用结果包括:
    根据所述备用结果参数与主用结果参数的预设的对应关系确定与所述备用结果参数对应的所述主用结果参数;
    根据所述备用结果参数的取值确定所述主用结果参数的取值,从而获得包括所述主用结果参数以及所述主用结果参数的取值的所述主用API的调用结果。
  15. 根据权利要求14所述的应用程序编程接口的调用方法,其特征在于,所述根据所述备用结果参数的取值确定所述主用结果参数的取值包括:
    确定所述主用结果参数的取值为所述备用结果参数的取值;或
    根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值。
  16. 根据权利要求15所述的应用程序编程接口的调用方法,其特征在于,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括通过所述备用结果参数的取值计算获得所述主用结果参数的取值的计算规则。
  17. 根据权利要求15所述的应用程序编程接口的调用方法,其特征在于,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括所述备用结果参数与所述主用结果参数的格式转换规则。
  18. 一种应用程序编程接口API管理平台,其特征在于,所述API管理平台包括:
    请求接收模块,用于接收用于调用主用API的主用调用请求,所述主用API为北向API;
    检测模块,用于检测所述请求获得模块获得的主用调用请求调用的主用API是否可用;
    请求转换模块,用于在所述检测模块检测到所述主用API不可用时,根据所述请求获得模块获得的所述主用调用请求获得用于调用备用API的备用调用请求,所述备用API为北向API,所述主用API与所述备用API具有相同的功能类别;
    调用模块,用于使用所述请求生成模块获得的备用调用请求调用所述备用API;
    响应获得模块,用于获得用于响应所述请求转换模块获得的所述备用调用请求的备用响应,所述备用响应包括所述备用API的调用结果;
    结果转换模块,用于根据所述响应获得模块获得的备用API的调用结果获得所述主用API的调用结果;
    响应发送模块,用于向所述终端发送包括所述结果转换模块获得的所述主用API的调用结果的主用响应用于响应所述请求接收模块接收的主用调用请求。
  19. 根据权利要求18所述的应用程序编程接口的调用装置,其特征在于,所述检测模块具体用于:
    检测所述主用调用请求调用所述主用API时需要调用的南向API是否可用;
    在所述主用调用请求调用所述主用API时需要调用的南向API中存在不可用南向API时,确定所述主用API不可用。
  20. 根据权利要求18所述的应用程序编程接口的调用装置,其特征在于,所述检测模块具体用于:
    检测调用所述主用API时能够调用的南向API是否可用;
    在所述调用所述主用API时能够调用的南向API中存在不可用南向API时,确定所述主用API不可用。
  21. 根据权利要求18所述的应用程序编程接口的调用装置,其特征在于,
    所述API管理平台还包括列表生成模块,所述列表生成模块用于生成不可用北向API列表,所述检测模块具体用于:
    在所述列表生成模块生成的所述不可用北向API列表包括所述主用API时,确定所述主用API不可用。
  22. 根据权利要求21所述的应用程序编程接口的调用装置,其特征在于,所述列表生成模块具体用于:
    确定不可用南向API;
    根据北向API与南向API的调用关系以及所述不可用南向API确定不可用北向API;
    根据所述不可用北向API生成所述不可用北向API列表。
  23. 根据权利要求18至22任一所述的应用程序编程接口的调用装置,其特征在于,所述主用调用请求包括主用参数以及所述主用参数的取值,所述请求转换模块包括:
    参数确定模块,用于根据所述主用参数与备用参数的预设的对应关系确定所述主用参数对应的所述备用参数;
    取值确定模块,用于根据所述主用参数的取值确定所述参数确定模块确定的所述备用参数的取值;
    消息获得模块,用于获得包括所述参数确定模块确定的备用参数以及所述取值确定模块确定的所述备用参数的取值的所述备用调用请求。
  24. 根据权利要求23所述的应用程序编程接口的调用装置,其特征在 于,所述取值确定模块具体用于:
    确定所述备用参数的取值为所述主用参数的取值;或
    根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用参数的取值转换为所述备用参数的取值。
  25. 根据权利要求24所述的应用程序编程接口的调用装置,其特征在于,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括通过所述主用参数的取值计算获得所述备用参数的取值的计算规则。
  26. 根据权利要求24所述的应用程序编程接口的调用装置,其特征在于,所述主用参数的取值与所述备用参数的取值的预设的转换规则包括所述主用参数的与所述备用参数的格式转换规则。
  27. 根据权利要求18至22任一所述的应用程序编程接口的调用装置,其特征在于,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数,所述请求转换模块具体用于:
    根据所述主用参数的名称与所述备用参数的名称的预设的对应关系,将所述主用调用请求中的所述主用参数的名称修改为所述主用参数对应的所述备用参数的名称,以获得所述备用调用请求。
  28. 根据权利要求18至22任一所述的应用程序编程接口的调用装置,其特征在于,所述主用调用请求包括主用参数,所述备用调用请求包括备用参数,所述请求转换模块具体用于:
    根据所述主用参数的取值与所述备用参数的取值的预设的转换规则,将所述主用调用请求中的所述主用参数的取值转换为所述备用参数的取值,以获得所述备用调用请求。
  29. 根据权利要求18至22任一所述的应用程序编程接口的调用装置,其特征在于,所述请求转换模块具体用于:
    根据所述主用调用请求格式与所述备用调用请求格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得所述备用调用请求。
  30. 根据权利要求18至22任一所述的应用程序编程接口的调用装置,其特征在于,所述请求转换模块具体用于:
    根据所述主用调用请求格式与中间消息格式的预设的转换规则,将所述主用调用请求进行格式转换,从而获得中间消息格式的中间消息;
    根据所述中间消息格式与所述备用调用请求格式的预设的转换规则,将 所述中间消息进行格式转换,从而获得所述备用调用请求。
  31. 根据权利要求19至30任一所述的应用程序编程接口的调用装置,其特征在于,所述备用API的调用结果包括备用结果参数以及所述备用结果参数的取值,所述结果转换模块包括:
    结果参数确定获得模块,用于根据所述备用结果参数与主用结果参数的预设的对应关系确定所述备用结果参数对应的所述主用结果参数;
    结果取值确定模块,用于根据所述备用结果参数的取值确定所述参数确定模块确定的所述主用结果参数的取值,从而获得包括所述主用结果参数以及所述主用结果参数的取值的所述主用API的调用结果。
  32. 根据权利要求31所述的应用程序编程接口的调用装置,其特征在于,所述结果取值确定模块具体用于:
    确定所述主用结果参数的取值为所述备用结果参数的取值;或
    根据所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则,将所述备用结果参数的取值转换为所述主用结果参数的取值。
  33. 根据权利要求32所述的应用程序编程接口的调用装置,其特征在于,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括通过所述备用结果参数的取值计算获得所述主用结果参数的取值的计算规则。
  34. 根据权利要求32所述的应用程序编程接口的调用装置,其特征在于,所述备用结果参数的取值与所述主用结果参数的取值的预设的转换规则包括所述备用结果参数的与所述主用结果参数的格式转换规则。
PCT/CN2015/082588 2015-01-04 2015-06-27 一种应用程序编程接口调用方法及设备 WO2016107120A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510003920.3 2015-01-04
CN201510003920.3A CN104503768B (zh) 2015-01-04 2015-01-04 一种应用程序编程接口调用方法及设备

Publications (1)

Publication Number Publication Date
WO2016107120A1 true WO2016107120A1 (zh) 2016-07-07

Family

ID=52945169

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/082588 WO2016107120A1 (zh) 2015-01-04 2015-06-27 一种应用程序编程接口调用方法及设备

Country Status (2)

Country Link
CN (1) CN104503768B (zh)
WO (1) WO2016107120A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860356A (zh) * 2021-02-10 2021-05-28 北京百度网讯科技有限公司 一种api调用控制方法、装置、电子设备和存储介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104503768B (zh) * 2015-01-04 2018-05-04 华为技术有限公司 一种应用程序编程接口调用方法及设备
CN106709333B (zh) * 2015-11-16 2019-11-22 华为技术有限公司 一种应用编程的安全性检测方法及装置
CN108268369B (zh) * 2016-12-30 2021-04-02 北京国双科技有限公司 测试数据获取方法及装置
CN106970948A (zh) * 2017-03-02 2017-07-21 努比亚技术有限公司 浏览器的频道信息管理方法与装置
CN109688202B (zh) * 2018-12-04 2021-07-02 北京腾云天下科技有限公司 一种接口数据的处理方法、装置、计算设备及存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101388887A (zh) * 2008-10-15 2009-03-18 中兴通讯股份有限公司 一种网络服务的处理方法和系统
CN101814084A (zh) * 2010-01-11 2010-08-25 北京世纪高通科技有限公司 Api管理方法及系统
CN103188204A (zh) * 2011-12-27 2013-07-03 腾讯科技(深圳)有限公司 开放平台中的服务控制方法及系统
CN104503768A (zh) * 2015-01-04 2015-04-08 华为技术有限公司 一种应用程序编程接口调用方法及设备

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100493067C (zh) * 2003-09-02 2009-05-27 华为技术有限公司 一种接口负载备份的方法
CN101582807B (zh) * 2009-07-02 2011-10-05 北京讯风光通信技术开发有限责任公司 一种基于北向接口实现网络管理的方法及系统
CN102684894B (zh) * 2011-03-07 2014-12-10 中兴通讯股份有限公司 一种实现北向接口的方法及装置
CN103699421B (zh) * 2014-01-08 2017-07-11 深圳金三立视频科技股份有限公司 嵌入式设备系统升级方法及其装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101388887A (zh) * 2008-10-15 2009-03-18 中兴通讯股份有限公司 一种网络服务的处理方法和系统
CN101814084A (zh) * 2010-01-11 2010-08-25 北京世纪高通科技有限公司 Api管理方法及系统
CN103188204A (zh) * 2011-12-27 2013-07-03 腾讯科技(深圳)有限公司 开放平台中的服务控制方法及系统
CN104503768A (zh) * 2015-01-04 2015-04-08 华为技术有限公司 一种应用程序编程接口调用方法及设备

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112860356A (zh) * 2021-02-10 2021-05-28 北京百度网讯科技有限公司 一种api调用控制方法、装置、电子设备和存储介质
CN112860356B (zh) * 2021-02-10 2023-08-15 北京百度网讯科技有限公司 一种api调用控制方法、装置、电子设备和存储介质

Also Published As

Publication number Publication date
CN104503768A (zh) 2015-04-08
CN104503768B (zh) 2018-05-04

Similar Documents

Publication Publication Date Title
WO2016107120A1 (zh) 一种应用程序编程接口调用方法及设备
CN112286503B (zh) 多注册中心的微服务统一管理方法、装置、设备及介质
US9923992B2 (en) Inter-process communication method based on application layer of android and basic application communication system
CN109002362B (zh) 一种服务方法、装置、系统以及电子设备
CN108696381B (zh) 一种协议配置方法及装置
CN109635019B (zh) 请求处理方法、装置、设备及存储介质
CN106375458B (zh) 服务调用系统、方法及装置
US20190268213A1 (en) Network function management method, management unit, and system
CN111163129A (zh) 一种基于跨链网络的资源处理方法及装置
US11561997B2 (en) Methods, systems, and computer readable media for data translation using a representational state transfer (REST) application programming interface (API)
WO2014190544A1 (zh) 应用部署方法和设备
CN114490268A (zh) 全链路监控方法、装置、设备、存储介质和程序产品
WO2010043142A1 (zh) 一种增强基于脚本业务的应用可靠性的方法、装置和系统
CN110727521A (zh) 同步转异步调用方法、装置、系统、电子设备及可读介质
WO2019153492A1 (zh) 实现web与原生功能交互的方法、电子装置及可读存储介质
CN111988418B (zh) 数据处理方法、装置、设备及计算机可读存储介质
CN111552568A (zh) 云服务调用方法和装置
CN110519388B (zh) 区块链请求的处理方法、装置、电子设备及可读存储介质
CN109388388B (zh) 功能模块间的信息交互方法、装置、设备及存储介质
US11533596B2 (en) API publish method and apparatus
US8200749B2 (en) Data processing method for generating service interface descriptions
WO2017000616A1 (zh) 访问云数据的方法及装置、存储介质
WO2020108443A1 (zh) 一种虚拟化管理方法及装置
CN112491943A (zh) 数据请求方法、装置、存储介质和电子设备
CN113918245A (zh) 一种数据调用方法、装置、设备及计算机可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15874810

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15874810

Country of ref document: EP

Kind code of ref document: A1