CN114490124A - Method, device, equipment and medium for calling Application Programming Interface (API) - Google Patents

Method, device, equipment and medium for calling Application Programming Interface (API) Download PDF

Info

Publication number
CN114490124A
CN114490124A CN202210057840.6A CN202210057840A CN114490124A CN 114490124 A CN114490124 A CN 114490124A CN 202210057840 A CN202210057840 A CN 202210057840A CN 114490124 A CN114490124 A CN 114490124A
Authority
CN
China
Prior art keywords
version
api
target
calling
function
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202210057840.6A
Other languages
Chinese (zh)
Inventor
刁宇辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202210057840.6A priority Critical patent/CN114490124A/en
Publication of CN114490124A publication Critical patent/CN114490124A/en
Pending legal-status Critical Current

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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • 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
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to the technical field of operation and maintenance, and provides a method, a device, equipment and a medium for calling an Application Programming Interface (API), wherein the method comprises the following steps: if a calling request of a first application service is received, sending a preset API calling configuration to the first application service, wherein the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration is an API calling configuration of a preset version of the target API; if receiving a call failure message of the first application service, acquiring version information of each version of a target API; selecting a target version from the versions of the target API based on the calling requirement and the version information of each version of the target API; generating a target API call configuration of a target version; sending the target API call configuration to the first application service. By adopting the method and the device, the success rate of calling the API and the compatibility of the system can be improved.

Description

Method, device, equipment and medium for calling Application Programming Interface (API)
Technical Field
The application relates to the technical field of operation and maintenance, and mainly relates to a method, a device, computer equipment and a medium for calling an Application Programming Interface (API).
Background
With the rapid development of the software industry, the software functions are more and more powerful, and more application services open their own resources to developers in the form of Application Programming Interfaces (APIs) for calling. With the increase of enterprise services, more and more application services supporting the development of enterprise services are provided, and particularly, the development of microservices is popular, and the calling relationship of the API between the application services is more and more complicated. However, API calls between application services are managed by the respective systems independently. When the API version is updated, it is typically notified orally or by mail. If there is no immediate update, it is easy to cause version calling error or incompatible problem.
Disclosure of Invention
The embodiment of the application provides a method, a device, computer equipment and a medium for calling an Application Programming Interface (API), which can improve the success rate of calling the API and the compatibility of a system.
In a first aspect, an embodiment of the present application provides a method for calling an application programming interface API, where:
if a calling request of a first application service is received, sending a preset API calling configuration to the first application service; the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration is an API calling configuration of a preset version of the target API;
if receiving a call failure message of the first application service, acquiring version information of each version of the target API; wherein the call failure message is used for indicating that the first application service fails to call the target API;
selecting a target version from the versions of the target API based on the calling requirement and the version information of each version of the target API;
generating a target API call configuration of the target version;
sending the target API call configuration to the first application service.
In a second aspect, an embodiment of the present application provides an apparatus for calling an application programming interface API, where:
the communication unit is used for sending preset API (application program interface) calling configuration to a first application service if a calling request of the first application service is received; the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration comprises a preset version of the target API;
an obtaining unit, configured to obtain version information of each version of the target API if a call failure message of the first application service is received; wherein the call failure message is used for indicating that the first application service fails to call the target API;
the selecting unit is used for selecting a target version from the versions of the target API based on the calling requirement and the version information of each version of the target API;
the generating unit is used for generating target API calling configuration of the target version;
the communication unit is further configured to send the target API call configuration to the first application service.
In a third aspect, an embodiment of the present application provides a computer device, including a processor, a memory, a communication interface, and a computer program, where the memory stores the computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for some or all of the steps described in the first aspect.
In a fourth aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program, where the computer program makes a computer execute to implement part or all of the steps described in the first aspect.
The embodiment of the application has the following beneficial effects:
after the method, the device, the computer equipment and the medium for calling the application programming interface API are adopted, after a calling request of the first application service is received, the preset API calling configuration is sent to the first application service, so that the first application service calls the preset version of the target API in the second application service based on the preset API calling configuration. If the call failure message of the first application service is received, the call failure message indicates that the first application service fails to call the target API, and version information of each version of the target API can be acquired. And selecting a target version from the versions of the target API based on the version information and the calling requirement in the calling request, and regenerating the target API calling configuration of the target version. The target API call configuration is sent to the first application service such that the first application service calls a target version of the target API based on the target API call configuration. Therefore, the success rate of calling the API and the compatibility of the system can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Wherein:
fig. 1 is a schematic flowchart of a method for calling an application programming interface API according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of an apparatus for calling an application programming interface API according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions of the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art without any inventive work according to the embodiments of the present application are within the scope of the present application.
The terms "first," "second," and the like in the description and claims of the present application and in the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The network architecture applied by the embodiment of the application comprises a server and electronic equipment. The number of the electronic devices and the number of the servers are not limited in the embodiment of the application, and the servers can provide services for the electronic devices at the same time. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like. The server may alternatively be implemented as a server cluster consisting of a plurality of servers.
The electronic device may be a Personal Computer (PC), a notebook computer, or a smart phone, and may also be an all-in-one machine, a palm computer, a tablet computer (pad), a smart television playing terminal, a vehicle-mounted terminal, or a portable device. The operating system of the PC-side electronic device, such as a kiosk or the like, may include, but is not limited to, operating systems such as Linux system, Unix system, Windows series system (e.g., Windows xp, Windows 7, etc.), Mac OS X system (operating system of apple computer), and the like. The operating system of the electronic device at the mobile end, such as a smart phone, may include, but is not limited to, an operating system such as an android system, an IOS (operating system of an apple mobile phone), a Window system, and the like.
The electronic device may install and run the application program, and the server may be a server corresponding to the application program installed in the electronic device, and provide an application service for the application program. The application program may be a single integrated application software, or an applet embedded in another application, or a system on a web page, etc., which is not limited herein.
The server is specifically used for providing the electronic equipment with application services related in each application service system. The server may include an API version management module operable to store version information for each API in the application service. The version information may include a version number, version update content, compatibility, and the like, which are not limited herein. Version numbers are used to indicate versions. The version updating content is used for describing the newly added content of the version. Compatibility is used to describe whether previous versions are compatible.
In the embodiment of the present application, the application service that calls the other application service may be referred to as a first application service, and the other application service that is called may be referred to as a second application service. The API called by the first application service in the second application service is referred to as the target API. The API version management module is also used for configuring the target API to obtain API calling configuration of each version of the target API, so that the first application service calls the target API of the corresponding version based on the API calling configuration.
It should be noted that there may be 1 or more target API versions. If the target API has a plurality of versions, a preset version can be selected, and the preset API calling configuration of the preset version is configured. The method for selecting the preset version is not limited in the present application, and exemplarily, the first application service needs to call a target API of the second application service, where the target API has 3 versions, V1.0, V1.1, and V1.2. In this way, the latest version (V1.2) of V1.0, V1.1, V1.2 may be selected as the preset version of the target API called by the first application service. Or the version with the maximum compatibility in V1.0, V1.1 and V1.2 can be selected as the preset version of the target API called by the first application service. Or based on a preset condition in the call request of the first application service, selecting a version meeting the preset condition from V1.0, V1.1 and V1.2 as a preset version of the target API called by the first application service. Or may be a preset version of the target API called by the first application service from the last version successfully called by the first application service, etc.
In one possible example, the API version management module is further configured to send an approval request to a corresponding person in charge of the first application service and the second application service after the version of the target API is updated or the API call configuration is updated, so as to determine whether the update is valid. That is, whether or not it is a valid modification is determined by approval. If the approval is passed, the update information can be synchronized to all the application services or systems corresponding to the first application service and the second application service, so that the synchronization of calling version information is realized, and the success rate of calling the API and the compatibility of the system are improved.
The embodiment of the application provides a method for calling an Application Programming Interface (API), which can be executed by a device for calling the API. The device can be realized by software and/or hardware, can be generally integrated in a server, and can improve the success rate of calling the API and the compatibility of the system.
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a method for calling an API according to the present application. Taking the application of the method to a server as an example for illustration, the method includes the following steps S101 to S105, wherein:
s101, if a calling request of the first application service is received, sending a preset API calling configuration to the first application service.
In the embodiment of the application, the call request is a request message sent by the first application service and used for calling the target API of the second application service. The first application service, the second application service and the target API are not limited in the application. The target API includes at least two versions, and version information of each version may be stored in advance. The version information may include version number, version update content, compatibility, and the like, which are not limited herein.
The invocation request may include invocation requirements. The calling requirement may include a data type to be called, a service type of data corresponding to the data type, processing accuracy, processing efficiency, and the like. The content of the calling request and the calling requirement is not limited. The call request may also include identification information of the first application service, identification information of the second application service, or identification information of the target API, etc. The identification information is used for identity identification. As such, the data of the first application service may be obtained based on the identification information of the first application service, the target API may also be determined to be an API in the second application service based on the identification information of the target API, or it may also be determined that the call request is the first application service request call target API based on the identification information of the first application service and the identification information of the target API, and so on.
In the embodiment of the application, the preset API call configuration is preset configuration information for calling a preset version of the target API, and may be stored based on the identification information of the target API. The preset version is a default version of a target API of the second application service called by the first application service pre-configured by the server. That is, after receiving a call request for the first application service to call a target API of the second application service, the first application service may call a preset version of the target API in advance based on the preset API call configuration. The preset version may be determined by referring to the foregoing method, and may be a latest version of the multiple versions corresponding to the target API as the preset version, or a version with the highest compatibility of the multiple versions corresponding to the target API is selected as the preset version, or a version with the highest stability of the multiple versions corresponding to the target API is selected as the preset version, or a version called most frequently of the multiple versions corresponding to the target API is selected as the preset version, or a version called successfully last time by the first application service is selected as the preset version, and the like.
In one possible example, after receiving the call request of the first application service, before sending the preset API call configuration to the first application server, the following steps may be further included: searching preset API calling configuration; if the preset API calling configuration is not found, acquiring a history record of calling a target API by the first application service; determining a preset version of a target API based on the history; and generating preset API calling configuration of the preset version based on the version information of the preset version.
Wherein the history is a record of the first application service calling the target API. The history may be obtained based on a log of the first application service or a log of the target API. It should be noted that the version of the target API called in the history may include a plurality of versions.
The preset version may be the most called version in the history, or the most recently called version, or the most stable version, etc. In one possible example, the calling information of each version is determined based on the history record; calculating an evaluation value of the version based on the calling information of the version; and taking the version corresponding to the maximum value of the evaluation value as a preset version of the target API.
The calling information comprises calling duration, calling success rate, calling compatibility and the like of each version. It is understood that the call information of the version of each call is determined based on the history, and then the evaluation value of the corresponding version is determined based on the call information. And taking the version corresponding to the maximum value of the evaluation value as a preset version of the target API. Therefore, the success rate of calling the preset version can be improved.
The preset API call configuration may be generated based on version information of the preset version, and the generation method may refer to a method of generating the target API call configuration, which will be described later. It can be understood that the preset API calling configuration is obtained through the version information of the preset version, the accuracy of the configuration can be improved, and the calling success rate can be improved.
It is understood that after receiving the call request of the first application service, the preset call configuration of the target API may be searched based on the identification information of the target API. And if the preset API calling configuration is not found, indicating that the configuration information of the target API of the first application service calling the second application service is not configured in advance. The preset version of the target API can be determined based on the history of calling the target API by the first application service, and then the preset API calling configuration corresponding to the preset version is generated based on the version information of the preset version. And sending the preset API calling configuration to the first application service so that the first application service calls the preset version of the target API based on the preset API calling configuration. And when the call is successful, the preset API call configuration can be stored. Therefore, when calling next time, the preset version of the calling target API can be configured based on the preset API call, so that the calling efficiency is improved.
S102, if a call failure message of the first application service is received, version information of each version of the target API is obtained.
In this embodiment of the application, if the first application service fails to call the target API based on the preset API call configuration, a call failure message may be sent to the server to indicate that the first application service fails to call the target API. Therefore, new configuration information of another target API version or a preset version can be requested to be configured, so that new API calling configuration is obtained, and the calling success rate is improved.
S103, selecting a target version from the versions of the target API based on the calling requirement and the version information of each version corresponding to the target API.
In the embodiment of the application, the target version is a version selected from versions of the target API based on the calling requirement and version information of each version corresponding to the target API. The target API call configuration is a target version of the API call configuration. It should be noted that the target version and the preset version may be the same or different, and the target API call configuration and the preset API call configuration are different configuration information. Therefore, the calling target API can be called and configured through the target API corresponding to the newly configured target version, and the calling success rate and the system compatibility are improved.
In one possible example, step S103 may include the following steps A1-A3, wherein:
and A1, analyzing the call requirement to obtain a first function to be called and a second function associated with the first function.
In this embodiment, the first function refers to a function that needs to be called by the first application service this time. The second function refers to a function associated with the first function in the second application service. Thus, when a first function is invoked, a second function may be invoked.
The method for analyzing the calling requirement is not limited, and the text can be analyzed based on a natural language processing algorithm to obtain the part of speech, the word meaning and the word frequency of each participle. And determining the processing items of the calling requirement based on the part of speech, the word sense and the word frequency of the participle so as to determine the first function to be called. A second function associated with the first function is then determined based on the association between the functions in the second application service. Therefore, the function called this time is determined based on the calling requirement, and the function associated with the function is determined, so that the accuracy of selecting the target version to be called can be improved, and the calling success rate can be improved.
In one possible example, if the call requirement does not specify the handling item, the importance of each function may be determined based on the function description of each function in the target API, and the first function and the second function may be determined based on the importance of each function. Therefore, the first function and the second function of the target API are determined and selected based on the importance of the called function, and the calling success rate is improved.
And A2, acquiring the success rate of calling the first function and the second function by each version based on the version information of each version of the target API.
In the embodiment of the application, the success rate of the version calling the first function and the second function is used for describing the success probability of calling the target API of the version. The method for obtaining the success rate is not limited in the present application, and in one possible example, the step a2 may include the following steps a21 to a24, where:
and A21, acquiring the function description of each version based on the version information of each version of the target API.
In the embodiment of the present application, the function description of a version is information for describing each function in the version. Such as function type, application scenario, usage method, usage effect, etc. The method for obtaining the function description is not limited in the present application, and in a possible example, the version information includes a version number, version update content, and compatibility, and step a21 may include the following steps a211 to a213, where:
and A211, acquiring compatible version contents of the version based on the compatibility and the version number of the version.
A212, the version-based version update content and the compatible version content constitute a version of the target version content.
In the embodiment of the present application, the version-compatible version content may include version information for version forward compatibility and may further include version information for backward compatibility. The content of other versions compatible with the version can be determined based on the compatibility of the version, and then the content of the compatible version of each version is obtained based on the version number and the compatibility of each version.
The version updating content includes the content of the version updating this time, namely the content which is not available in the previously released version. The target version content of a version refers to all content supported by that version. Therefore, the version updating content and the compatible version content of the version can be combined to obtain the target version content of the version.
And A213, acquiring the function description of the version based on the content of the target version.
It is understood that in steps a211 to a213, compatible version contents of the versions are first obtained based on the compatibility and the version numbers of the versions. And then acquiring the target version content of the version based on the version updating content and the compatible version content of the version. After the target version content is obtained, the description information of each function in the target version content can be obtained one by one, so as to obtain the function description of the version. Therefore, the function of losing the version can be avoided, and the accuracy of selecting the target version can be improved.
And A22, acquiring a first text vector corresponding to the first function and a second text vector corresponding to the second function.
In an embodiment of the present application, the first text vector is text description information of the first function. The first text vector includes tag information describing vocabularies, which may be part of speech, product between Term Frequency (TF) and Inverse text Frequency (IDF), etc. of each vocabulary. The second text vector is text description information of a second function, and the content of the second text vector can refer to the description of the first text vector.
A23, obtaining a first similarity value between the function description of the version and the first text vector, and obtaining a second similarity value between the function description and the second text vector.
In the embodiment of the present application, the first similarity value is used to describe the matching degree between the function description and the first text vector, and the second similarity value is used to describe the matching degree between the function description and the second text vector. The first similarity value is exemplified below, and the calculation may be performed based on a cosine similarity between the text vector corresponding to the function description and the first text vector. Or may be obtained based on the proportion of the target vocabulary of the first function in the function description in the first text vector. Or the target function corresponding to the first text vector and the matching value between the version function descriptions can be obtained.
And A24, carrying out weighted calculation on the first similarity value and the second similarity value to obtain the success rate of the version calling the first function and the second function.
The success rate of the version call of the first function and the second function may be equal to a sum of a product between the first similarity value and a preset weight of the first function and a product between the second similarity value and a preset weight of the second function. Wherein the preset weight of the first function and the preset weight of the second function can be determined based on the importance and relevance between the first function and the second function. For example, the larger the preset weight of the second function associated with the first function, the larger the preset weight of the second function having a larger influence on the second application service.
It is understood that in steps a 21-a 24, the function description of each version is obtained based on the version information of each version of the target API. And respectively acquiring a first text vector corresponding to the first function and a second text vector corresponding to the second function. And then, carrying out weighted calculation on a first similarity value between the version of the function description and the first text vector and a second similarity value between the version of the function description and the second text vector to obtain the success rate of calling the first function and the second function by the version. Therefore, the accuracy of the success rate can be improved, and the success rate of calling is favorably improved.
And A3, selecting the version corresponding to the maximum value of the success rate from the versions of the target API to obtain the target version.
In the embodiment of the present application, the target version is a version corresponding to a maximum value of the power in the version of the target API. Illustratively, the target API's versions include 3 versions V1.0, V1.1, V1.2. If the success rate of V1.0 calling the first function and the second function is 80%, the success rate of V1.1 calling the first function and the second function is 90%, and the success rate of V1.2 calling the first function and the second function is 86%, the target version is V1.1.
It is to be understood that, in steps a1 to A3, a version corresponding to the maximum value of the success rates of calling the first function and the second function among the versions of the target API is taken as the target version. Therefore, the selected target version can meet the calling requirement as much as possible, and the selection accuracy is improved.
And S104, generating target API calling configuration of the target version.
In one possible example, step S104 may include the following steps A41-A43, wherein:
a41, determining the compatibility of the at least two third functions of the target version and the third function based on the content of the target version.
And A42, acquiring the sub-configuration information of the third function based on the compatibility of the third function.
In the embodiment of the present application, the third function refers to a function supported by the target version, and the third function includes the first function and the second function. The third function of the target version can be obtained by analyzing based on the content of the target version. The sub-configuration information of the third function may be obtained by adjusting configuration parameters of the third function based on compatibility of the third function. The configuration parameter of the third function refers to information set for calling the third function, or hardware content provided. The determination may be made based on configuration parameters set in advance for the respective third functions. If the preset configuration parameters are not found, the configuration parameters of similar functions can be found, and then the adjustment is carried out based on the difference of the functions to obtain the configuration parameters of a third function. It can be understood that the accuracy of configuration can be improved by obtaining the sub-configuration information of the third function based on the compatibility of the third function.
And A43, acquiring the target API call configuration of the target version based on the sub-configuration information.
The target API call configuration may be the composition information of each sub-configuration information, or perform cluster fusion on the sub-configuration information to obtain a target API call configuration that satisfies each configuration feature, and the like.
It is understood that, in the steps a 41-a 43, the compatibility of each third function and at least two third functions of the target version is determined based on the content of the target version. And acquiring the sub-configuration information of the third function based on the compatibility. And then obtaining the target API call configuration of the target version based on the sub-configuration information. Therefore, the accuracy of obtaining the target API calling configuration can be improved, and the calling success rate can be improved.
And S105, sending the target API call configuration to the first application service.
In the method shown in fig. 1, after receiving a call request of a first application service, a preset API call configuration is sent to the first application service, so that the first application service calls a preset version of a target API in a second application service based on the preset API call configuration. If the call failure message of the first application service is received, the call failure message indicates that the first application service fails to call the target API, and version information of each version of the target API can be acquired. And selecting a target version from the versions of the target API based on the version information and the calling requirement in the calling request, and regenerating the target API calling configuration of the target version. The target API call configuration is sent to the first application service such that the first application service calls a target version of the target API based on the target API call configuration. Therefore, the success rate of calling the API and the compatibility of the system can be improved.
In a possible example, after step S105, the following steps may be further included: if a call failure message of the first application service is received, adjusting the target API call configuration based on the call failure message to obtain a retry API call configuration of the target version; a retry API call configuration is sent to the first application service.
Wherein the call failure message is used to indicate that the first application service failed to call the target API, as described above. The call failure message may include flag information of the call failure, for example, a node of the call failure, a reason of the call failure, a connected step, and the like. Retrying the API call configuration may adjust the target API call configuration based on the call failure reason. Specifically, the target function in the third function may be determined based on the reason for the call failure, and the sub-configuration information and the adjustment content of the target function may be adjusted. Or may determine the target configuration information based on the reason for the call failure, readjust the target configuration information, and so on.
It will be appreciated that in this example, after the target API call configuration of the first application service calls the target API failure, the first application service sends a call failure message to the server. And then adjusting the target API calling configuration based on the calling failure message to obtain a retry API calling configuration. Therefore, the calling target API can be configured based on the retry API call, and the calling success rate is improved. If the calling is failed based on the retry API calling configuration, the executable step adjusts the retry API calling configuration based on the calling failure message to obtain a new retry API calling configuration, and tries based on the obtained retry API calling configuration until the calling is successful or selects another target version.
In one possible example, after step S105, the following steps may be further included: and if the calling success message of the first application service is received, replacing the preset API calling configuration with the target API calling configuration and storing the target API calling configuration.
Wherein the call success message is used to indicate that the first application service successfully calls the target API. It is appreciated that in this example, after the first application service successfully calls the target API, the target API call configuration may be stored and replaced with the preset API call configuration to increase the success rate of the call.
The method of the embodiments of the present application is set forth above in detail and the apparatus of the embodiments of the present application is provided below.
Referring to fig. 2, fig. 2 is a schematic structural diagram of an apparatus for calling an API according to the present application, consistent with the embodiment shown in fig. 1. As shown in fig. 2, the apparatus 200 for calling an application programming interface API includes:
the communication unit 201 is configured to send a preset API call configuration to a first application service if a call request of the first application service is received; the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration comprises a preset version of the target API;
the obtaining unit 202 is configured to obtain version information of each version of the target API if a call failure message of the first application service is received; wherein the call failure message is used for indicating that the first application service fails to call the target API;
the selecting unit 203 is configured to select a target version from the versions of the target API based on the call requirement and version information of each version of the target API;
the generating unit 204 is configured to generate a target API call configuration of the target version;
the communication unit 201 is further configured to send the target API call configuration to the first application service.
In a possible example, the selecting unit 203 is specifically configured to analyze the call requirement to obtain a first function to be called and a second function associated with the first function; acquiring the success rate of calling the first function and the second function by each version based on the version information of each version of the target API; and selecting the version corresponding to the maximum value of the success rate from the versions of the target API to obtain the target version.
In a possible example, the selecting unit 203 is specifically configured to obtain the function description of each version based on version information of each version corresponding to the target API; acquiring a first text vector corresponding to the first function and a second text vector corresponding to the second function; acquiring a first similarity value between the function description of the version and the first text vector and a second similarity value between the function description and the second text vector; and performing weighted calculation on the first similarity value and the second similarity value to obtain the success rate of the version calling the first function and the second function.
In a possible example, the version information of each version corresponding to the target API includes a version number, version update content, and compatibility of each version, and the selecting unit 203 is specifically configured to obtain compatible version content based on the compatibility and the version number of the version; composing a target version content of the version based on the version update content and the compatible version content of the version; and acquiring the function description of the version based on the target version content.
In a possible example, the generating unit 204 is specifically configured to determine, based on the target version content, compatibility of at least two third functions of the target version and the third functions, where the third functions include the first function and the second function; acquiring configuration information of the third function based on the compatibility of the target version; and composing the target API call configuration of the target version based on the configuration information.
In a possible example, the apparatus 200 for calling an application programming interface API further comprises a lookup unit 205 and a determination unit 206. The searching unit 205 is configured to search for the preset API call configuration. The obtaining unit 202 is further configured to obtain a history record of the first application service calling the target API if a preset API calling configuration is not found; the determining 206 is for determining a preset version of the target API based on the history; the generating unit 204 generates a preset API call configuration corresponding to the preset version based on the version information of the preset version.
In a possible example, the apparatus 200 for calling an application programming interface API further includes an adjusting unit 207, configured to, if a call failure message of the first application service is received, adjust the target API call configuration based on the call failure message, so as to obtain the retry API call configuration of the target version. The communication unit 201 is further configured to send the retry API call configuration to the first application service.
For the detailed process executed by each unit in the apparatus 200 for calling API, refer to the execution steps in the foregoing method embodiments, which are not described herein.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure. As shown in fig. 3, the computer device 300 includes a processor 310, a memory 320, and a communication interface 330. The processor 310, the memory 320, and the communication interface 330 are interconnected via a bus 350. The related functions implemented by the communication unit 201 shown in fig. 2 may be implemented by the communication interface 330, and the related functions implemented by the processing unit 202 shown in fig. 2 may be implemented by the processor 310.
The memory 320 has stored therein a computer program 340, the computer program 340 being configured to be executed by the processor 310, the computer program 340 comprising instructions for:
if a calling request of a first application service is received, sending a preset API calling configuration to the first application service; the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration is an API calling configuration of a preset version of the target API;
if receiving a call failure message of the first application service, acquiring version information of each version of the target API; wherein the call failure message is used for indicating that the first application service fails to call the target API;
selecting a target version from the versions of the target API based on the calling requirement and the version information of each version of the target API;
generating a target API call configuration of the target version;
sending the target API call configuration to the first application service.
In one possible example, in the aspect of selecting the target version from the versions of the target API based on the call requirement and the version information of each version of the target API, the computer program 340 specifically includes instructions for performing the following steps:
analyzing the calling requirement to obtain a first function to be called and a second function associated with the first function;
acquiring the success rate of calling the first function and the second function by each version based on the version information of each version of the target API;
and selecting the version corresponding to the maximum value of the success rate from the versions of the target API to obtain the target version.
In one possible example, in terms of the success rate of obtaining the versions of the target API to call the first function and the second function based on the version information of the versions, the computer program 340 specifically includes instructions for performing the following steps:
acquiring the function description of each version based on the version information of each version corresponding to the target API;
acquiring a first text vector corresponding to the first function and a second text vector corresponding to the second function;
acquiring a first similarity value between the function description of the version and the first text vector and a second similarity value between the function description and the second text vector;
and performing weighted calculation on the first similarity value and the second similarity value to obtain the success rate of the version calling the first function and the second function.
In one possible example, the version information of each version corresponding to the target API includes a version number, version update content, and compatibility of each version, and in terms of the function description of each version obtained based on the version information of each version corresponding to the target API, the computer program 340 specifically includes instructions for performing the following steps:
acquiring compatible version contents based on the compatibility and the version number of the version;
composing a target version content of the version based on the version update content and the compatible version content of the version;
and acquiring the function description of the version based on the target version content.
In one possible example, in terms of the target API call configuration to generate the target version, the computer program 340 specifically includes instructions for performing the following steps:
determining compatibility of at least two third functions of the target version and the third function based on the target version content, the third functions including the first function and the second function;
acquiring sub-configuration information of the third function based on the compatibility of the third function;
and composing the target API call configuration of the target version based on the configuration information.
In one possible example, prior to said sending a preset API call configuration to said first application service, said computer program 340 further comprises instructions for:
searching the preset API calling configuration;
if the preset API calling configuration is not found, acquiring a history record of calling the target API by the first application service;
determining a preset version of the target API based on the history;
and generating a preset API calling configuration corresponding to the preset version based on the version information of the preset version.
In one possible example, after said sending said target API call configuration to said first application service, said computer program 340 further comprises instructions for:
if a call failure message of the first application service is received, adjusting the target API call configuration based on the call failure message to obtain a retry API call configuration of the target version;
sending the retry API call configuration to the first application service.
Embodiments of the present application also provide a computer-readable storage medium, where the computer-readable storage medium stores a computer program for causing a computer to execute to implement part or all of the steps of any one of the methods described in the method embodiments, and the computer includes an electronic device or a server.
Embodiments of the application also provide a computer program product comprising a non-transitory computer readable storage medium storing a computer program operable to cause a computer to perform to implement some or all of the steps of any of the methods recited in the method embodiments. The computer program product may be a software installation package and the computer comprises an electronic device or a server.
In the above-described embodiments, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like. For example, the blockchain may store a preset API call configuration, and the like, which is not limited herein.
The block chain in the embodiment of the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (blockchain), which is essentially a decentralized database, is a string of data blocks associated by using cryptography, and each data block contains information of a batch of network transactions, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art will also appreciate that the embodiments described in this specification are presently preferred and that no particular act or mode of operation is required in the present application.
In the foregoing embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, at least one unit or component may be combined or integrated with another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may also be distributed on at least one network unit. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a hardware mode or a software program mode.
The integrated unit, if implemented in the form of a software program module and sold or used as a stand-alone product, may be stored in a computer readable memory. With such an understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a memory and includes several instructions for causing a computer (which may be a personal computer, a server, a network device, or the like) to execute all or part of the steps of the methods according to the embodiments of the present application. And the aforementioned memory comprises: various media capable of storing program codes, such as a usb disk, a read-only memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and the like.
The foregoing detailed description of the embodiments of the present application has been presented to illustrate the principles and implementations of the present application, and the above description of the embodiments is only provided to help understand the method and the core concept of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method of calling an application programming interface, API, comprising:
if a calling request of a first application service is received, sending a preset API calling configuration to the first application service; the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration is an API calling configuration of a preset version of the target API;
if receiving a call failure message of the first application service, acquiring version information of each version of the target API; wherein the call failure message is used for indicating that the first application service fails to call the target API;
selecting a target version from the versions of the target API based on the calling requirement and the version information of each version of the target API;
generating a target API call configuration of the target version;
sending the target API call configuration to the first application service.
2. The method of claim 1, wherein selecting a target version from the versions of the target API based on the call requirements and version information of the versions of the target API comprises:
analyzing the calling requirement to obtain a first function to be called and a second function associated with the first function;
acquiring the success rate of calling the first function and the second function by each version based on the version information of each version of the target API;
and selecting the version corresponding to the maximum value of the success rate from the versions of the target API to obtain the target version.
3. The method of claim 2, wherein obtaining the success rate of each version calling the first function and the second function based on the version information of each version of the target API comprises:
acquiring the function description of each version of the target API based on the version information of each version;
acquiring a first text vector corresponding to the first function and a second text vector corresponding to the second function;
acquiring a first similarity value between the function description of the version and the first text vector and a second similarity value between the function description and the second text vector;
and performing weighted calculation on the first similarity value and the second similarity value to obtain the success rate of the version calling the first function and the second function.
4. The method of claim 3, wherein the version information includes version number, version update content, and compatibility, and the obtaining the function description of each version based on the version information of each version of the target API includes:
acquiring the compatible version content of the version based on the compatibility and the version number of the version;
composing a target version content of the version based on the version update content and the compatible version content of the version;
and acquiring the function description of the version based on the target version content.
5. The method of claim 4, wherein the generating the target version of the target API call configuration comprises:
determining compatibility of at least two third functions of the target version and the third function based on the target version content, the third functions including the first function and the second function;
acquiring sub-configuration information of the third function based on the compatibility of the third function;
and acquiring the target API call configuration of the target version based on the sub-configuration information.
6. The method according to any of claims 1-5, wherein prior to said sending a preset API call configuration to said first application service, said method further comprises:
searching the preset API calling configuration;
if the preset API calling configuration is not found, acquiring a history record of calling the target API by the first application service;
determining a preset version of the target API based on the history;
and generating a preset API calling configuration of the preset version based on the version information of the preset version.
7. The method of any of claims 1-5, wherein after said sending the target API call configuration to the first application service, the method further comprises:
if a call failure message of the first application service is received, adjusting the target API call configuration based on the call failure message to obtain a retry API call configuration of the target version;
sending the retry API call configuration to the first application service.
8. An apparatus for calling an Application Programming Interface (API), comprising:
the communication unit is used for sending preset API (application program interface) calling configuration to a first application service if a calling request of the first application service is received; the calling request is used for calling a target API of a second application service, the calling request comprises a calling requirement, and the preset API calling configuration comprises a preset version of the target API;
an obtaining unit, configured to obtain version information of each version of the target API if a call failure message of the first application service is received; wherein the call failure message is used for indicating that the first application service fails to call the target API;
the selecting unit is used for selecting a target version from the versions of the target API based on the calling requirement and the version information of each version of the target API;
the generating unit is used for generating target API calling configuration of the target version;
the communication unit is further configured to send the target API call configuration to the first application service.
9. A computer device, characterized in that it comprises a processor, a memory and a communication interface, wherein the memory stores a computer program configured to be executed by the processor, the computer program comprising instructions for carrying out the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, the computer program causing a computer to execute to implement the method of any one of claims 1-7.
CN202210057840.6A 2022-01-19 2022-01-19 Method, device, equipment and medium for calling Application Programming Interface (API) Pending CN114490124A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210057840.6A CN114490124A (en) 2022-01-19 2022-01-19 Method, device, equipment and medium for calling Application Programming Interface (API)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210057840.6A CN114490124A (en) 2022-01-19 2022-01-19 Method, device, equipment and medium for calling Application Programming Interface (API)

Publications (1)

Publication Number Publication Date
CN114490124A true CN114490124A (en) 2022-05-13

Family

ID=81473334

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210057840.6A Pending CN114490124A (en) 2022-01-19 2022-01-19 Method, device, equipment and medium for calling Application Programming Interface (API)

Country Status (1)

Country Link
CN (1) CN114490124A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117687623A (en) * 2023-12-29 2024-03-12 上海宽睿信息科技有限责任公司 API code-free automatic receiving method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117687623A (en) * 2023-12-29 2024-03-12 上海宽睿信息科技有限责任公司 API code-free automatic receiving method and device
CN117687623B (en) * 2023-12-29 2024-04-26 上海宽睿信息科技有限责任公司 API code-free automatic receiving method and device

Similar Documents

Publication Publication Date Title
KR101643022B1 (en) Catalog-based software component management
US11296940B2 (en) Centralized configuration data in a distributed file system
US20180196665A1 (en) Managing, using, and updating application resources
US8239662B1 (en) Network based operating system across devices
US8443361B2 (en) Systems and methods for tracking a history of changes associated with software packages in a computing system
CN110083381B (en) Incremental upgrading method and device
CN105493045A (en) Virtual computing instance migration
CN112929401A (en) Registration method and device
CN109472540B (en) Service processing method and device
CN114490124A (en) Method, device, equipment and medium for calling Application Programming Interface (API)
US20180123791A1 (en) Highly available and reliable secret distribution infrastructure
CN114780019A (en) Electronic device management method and device, electronic device and storage medium
KR101638689B1 (en) System and method for providing client terminal to user customized synchronization service
CN111125257B (en) Dictionary updating method, device, equipment and storage medium
CN107045452B (en) Virtual machine scheduling method and device
CN110930253A (en) Intelligent contract internal main key generation method and device, computer equipment and storage medium
CN113360172B (en) Application deployment method, device, computer equipment and storage medium
CN114579167A (en) Method, device and storage medium for downloading application upgrade file
CN114385570A (en) Data synchronization method and device, electronic equipment and readable medium
US9936015B2 (en) Method for building up a content management system
CN111966413A (en) Configuration method and device
CN112749085B (en) Cross-cluster task publishing method and device, electronic equipment and storage medium
CN108763425B (en) Method and apparatus for storing and reading audio files
CN112487261B (en) Data acquisition method and device, electronic equipment and medium
CN115167769A (en) Method, device and system for writing data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination