API call configuration and calling methods, electronic devices and computer program products
By determining basic and incremental configuration information, automatically parsing API documentation and generating calling rules, the problem of human error during API version updates is solved, achieving efficient and stable API version management.
Patent Information
- Application Number
- CN202611284253.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-24
- Publication Date
- 2026-11-10
AI Technical Summary
The existing API call solution requires manual reconfiguration of configuration information when the external API version is updated. This is prone to inconsistencies in configuration information due to human error, resulting in low efficiency and high error rate.
By determining basic and incremental configuration information, an API version management architecture based on 'basic configuration + incremental configuration' is generated. The API documentation is automatically parsed to obtain the initial configuration information, and the calling rules for the new version API are automatically generated through calling rules, reducing manual operations and configuration redundancy.
It has achieved automated configuration of API version management, which improves configuration efficiency and stability, reduces the risk of manual operation and configuration inconsistency, and reduces configuration redundancy.
Smart Images

Figure CN123069346A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology. More specifically, it relates to an API call configuration method, an API call method, an electronic device, and a computer program product. Background Technology
[0002] As risk control scenarios evolve towards real-time and multi-dimensional approaches, the importance of Application Programming Interfaces (APIs), as the core link for inter-system communication, has significantly increased in terms of their call configuration and calling methods. In this context, calling external APIs not only needs to meet efficiency requirements but also needs to address challenges such as version control.
[0003] While the current API calling scheme can guarantee the correct sending of API call requests and receipt of response results, it has a significant drawback: when the external API version is updated, the configuration information needs to be manually reset. However, when the new version API and the old version API have the same configuration information, inconsistencies in the same configuration information between the old and new versions can easily occur due to human error. Summary of the Invention
[0004] The present invention was proposed in view of the above-mentioned problems. Embodiments of the present invention disclose an API invocation configuration and invocation method, an electronic device, and a computer program product.
[0005] According to one aspect of the present invention, an API invocation configuration method is provided, comprising:
[0006] In response to the user's configuration operation, determine the basic configuration information and incremental configuration information related to the new version API. The basic configuration information is the configuration information of the new version API that has not changed compared to the previous version API, and the incremental configuration information is the configuration information of the new version API that has changed compared to the previous version API.
[0007] The first rule part is obtained based on the incremental configuration information, and the first rule part is the calling rule corresponding to the incremental configuration information;
[0008] Retrieve the second rule part corresponding to the basic configuration information from the calling rules corresponding to the previous version of the API;
[0009] The second rule section is associated with the first rule section to obtain the calling rules used by the caller when calling the new version of the API.
[0010] For example, before determining the basic and incremental configuration information related to the new version of the API in response to the user's configuration operation, the API call configuration method further includes:
[0011] Get the API documentation corresponding to the new version of the API;
[0012] Automatically parse the API documentation to obtain the initial configuration information for the new version of the API;
[0013] The initial configuration information is determined as the first overall configuration information of the new version, or, in response to the user's first update operation, the initial configuration information is updated to obtain the first overall configuration information of the new version. The first overall configuration information includes basic configuration information and incremental configuration information.
[0014] or,
[0015] Retrieve the API documentation for any older version of the API released before the new version;
[0016] Automatically parse the API documentation to obtain the initial configuration information for older API versions;
[0017] The initial configuration information is determined to be the second overall configuration information of the old version, or, in response to the user's second update operation, the initial configuration information is updated to obtain the second overall configuration information of the old version;
[0018] In response to the user's third update operation, the second overall configuration information of the old version is updated to obtain the first overall configuration information of the new version. The first overall configuration information includes basic configuration information and incremental configuration information.
[0019] For example, after obtaining the initial configuration information for the new or old version, the API call configuration method also includes:
[0020] The initial configuration information is validated. If the validation fails, the first error message is output to inform the user that there are erroneous fields in the initial configuration information. The operation to update the initial configuration information is performed when the validation passes.
[0021] For example, after obtaining the first overall configuration information for the new version, the API call configuration method also includes:
[0022] The first overall configuration information is validated. If the validation fails, a second error message is output. The second error message is used to inform the user that there are erroneous fields in the first overall configuration information. The operation of determining the basic configuration information and incremental configuration information related to the new version API in response to the user's configuration operation is executed when the validation passes.
[0023] For example, the first update operation, the second update operation, and the third update operation include one or more of the following operations:
[0024] Configure encryption / decryption settings. These settings are used to configure the encryption / decryption methods for API call requests and response results.
[0025] Configure log settings. Log settings are used to configure the log attributes of API call logs. Log attributes include the field content of the call logs and / or the retention time of the call logs.
[0026] Configure retry policy information. The retry policy configuration information is used to configure retry parameters when making API calls. Retry parameters include one or more of the following: retry error type, retry interval and retry circuit breaker threshold. The retry error type is used to limit the types of errors that are allowed to be retried. The retry circuit breaker threshold is the maximum number of consecutive retries.
[0027] Configure resource management information. Resource management information is used to configure the resource usage control parameters when API calls are made. The control parameters include one or more of the following: maximum concurrency of a single API, maximum global concurrency, and caching rules. Maximum concurrency of a single API is the maximum number of calls to a single API that can be processed at the same time. Maximum global concurrency is the maximum number of calls to all APIs that can be processed at the same time. Caching rules are used to limit the cache validity period of the target call request and / or the target response result corresponding to the target call request.
[0028] Configure canary deployment information. Canary deployment information is used to configure canary deployment parameters. Canary deployment parameters include canary ratio and / or whitelist rules. The canary ratio is the proportion of callers allowed to call the API among all callers. Whitelist rules are used to specify the callers allowed to call the API.
[0029] For example, after obtaining the invocation rules, the API invocation configuration method also includes:
[0030] Receive test parameters input by the user;
[0031] In response to the simulated call command input by the user, the system simulates the call process of the new version API according to the call rules, processes the test parameters, and obtains the simulated response results and simulated call logs.
[0032] Output the simulation response results and simulation call log;
[0033] When the caller receives a simulated success command from the user, it invokes the new version of the API based on the invocation rules.
[0034] According to another aspect of the present invention, an API invocation method is also provided, including the API invocation configuration method of any of the above, and further including:
[0035] When the current call request is generated, the new version of the API is invoked based on the calling rules.
[0036] For example, after invoking the new version of the API using the invocation rules, the API invocation method also includes:
[0037] Receive the current response result returned by the callee corresponding to the current call request;
[0038] Based on the preset log configuration information and the current response result, generate a call log corresponding to the current call request and save the call log in the log collection;
[0039] In response to a user's search operation, retrieve matching call logs from the log collection, and / or, in response to a user's export operation, export the call logs corresponding to the current call request to a preset format file.
[0040] According to another aspect of the present invention, an electronic device is also provided, comprising: a processor and a memory, wherein the memory stores computer program instructions, which, when executed by the processor, are used to perform the API call configuration method and the API call method described above.
[0041] According to another aspect of the present invention, a computer program product is also provided, including computer program instructions, which, when run, are used to execute the API call configuration method and API call method as described above.
[0042] The API call configuration method described above enables an API version management architecture based on "basic configuration + incremental configuration." When an API version changes, only the first rule portion corresponding to the incremental configuration information needs to be generated, and associated with the second rule portion corresponding to the unchanged basic configuration information to generate the call rules for the new version API. There's no need to regenerate the rule portion corresponding to the basic configuration information of the new version API. This reduces manual operations and effectively avoids inconsistencies between old and new versions of the same configuration information. Furthermore, this approach reduces configuration redundancy and improves version management efficiency.
[0043] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0044] The above and other objects, features, and advantages of the present invention will become more apparent from the more detailed description of the embodiments of the invention in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof.
[0045] Figure 1 A flowchart illustrating an API call configuration method according to an embodiment of the present invention is shown;
[0046] Figure 2 A schematic block diagram of an API invocation configuration apparatus according to an embodiment of the present invention is shown;
[0047] Figure 3 A schematic block diagram of an electronic device according to an embodiment of the present invention is shown. Detailed Implementation
[0048] To make the objectives, technical solutions, and advantages of the present invention more apparent, exemplary embodiments according to the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely a part of the embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein. Based on the embodiments of the present invention described herein, all other embodiments obtained by those skilled in the art without inventive effort should fall within the protection scope of the present invention.
[0049] As risk control scenarios evolve towards real-time and multi-dimensional approaches, higher demands are placed on API call management. Currently, most common API call configuration methods focus on "static parameter configuration," supporting only basic URL and parameter mapping settings. While this method can correctly send call requests and receive response results, it largely relies on manual configuration, resulting in low efficiency and high error rates. To at least partially address these technical problems, this invention provides an API call configuration method that enables automated configuration management of API versions, effectively improving API call configuration efficiency and call stability.
[0050] The API invocation configuration method described in this document can be applied to callers of the API. These callers can be any electronic device with data processing and / or instruction execution capabilities, including but not limited to personal computers, mobile terminals, and servers. The server may include one or more servers, which may include, but are not limited to, physical servers and / or cloud servers. Figure 1 A flowchart illustrating an API invocation configuration method according to an embodiment of the present invention is shown. Figure 1As shown, the API call configuration method includes steps S110, S120, S130 and S140.
[0051] In step S110, in response to the user's configuration operation, basic configuration information and incremental configuration information related to the new version API are determined. The basic configuration information is the configuration information of the new version API that has not changed compared to the previous version API, and the incremental configuration information is the configuration information of the new version API that has changed compared to the previous version API.
[0052] It can be understood that API configuration information is the set of necessary parameters required for a caller to successfully connect to and invoke the API, including but not limited to one or more of the following: interface name, protocol type (e.g., HTTP, HTTPS, WebSocket, etc.), base URL (i.e., URL path), request method, parameter names, parameter types, required fields, response data structure definition (response schema), error code list, etc. For ease of description and distinction, all configuration information required for an API call is referred to as the overall API configuration information. During API version iteration, any new version of the API has corresponding basic configuration information and incremental configuration information. Basic configuration information refers to the configuration information of the new version of the API that has not changed compared to the previous version, while incremental configuration information refers to the configuration information of the new version of the API that has changed compared to the previous version. This basic and incremental configuration information can be specified by the user. For example, the caller can provide a configuration platform for users, who can initiate configuration operations through the platform's visual interface to set the basic and incremental configuration information related to the new version of the API. Users can compare the overall configuration information of the new version with that of the previous API version. The unchanged parts are designated as the basic configuration information, while the changed parts are designated as the incremental configuration information. For example, suppose the overall configuration information of the previous API version includes: URL path https: / / api.credit.com / v1 / getReport, request method POST, and request parameters user_id and id_card. The overall configuration information of the new API version includes: URL path https: / / api.credit.com / v2 / getReport, request method POST, and request parameters user_code and id_card. Upon comparison, the request method POST and request parameter id_card remain unchanged and can be used as the basic configuration information. However, since the URL path changes from "https: / / api.credit.com / v1 / getReport" to "https: / / api.credit.com / v2 / getReport," and the request parameter user_id changes to user_code, then "URL path https: / / api.credit.com / v2 / getReport" and "request parameter user_code" can be used as the incremental configuration information.
[0053] User interaction with the visual interface can be achieved through any input method, including but not limited to inputting information via mouse, keyboard, touchscreen, microphone, etc. It is understood that interaction can include various user operations described herein, such as configuration operations and the first update operation described below. For example, configuration operations can include directly inputting basic configuration information and incremental configuration information. For instance, the visual interface can display two different text boxes, corresponding to basic configuration information and incremental configuration information respectively. The information entered by the user in the first text box can be directly identified as basic configuration information, and the information entered by the user in the second text box can be directly identified as incremental configuration information. Alternatively, configuration operations can include classifying the configuration information displayed by the configuration platform through the visual interface, such as dividing the configuration information into basic configuration information and incremental configuration information through drag-and-drop. The configuration information displayed on the visual interface can be pre-parsed by the caller and / or pre-input by the user. Of course, the above implementation methods of configuration operations are merely examples; any operation that can distinguish between basic configuration information and incremental configuration information can be executed as a configuration operation.
[0054] For example, the overall configuration information of any version of the API can be stored in a preset storage location (which may be referred to as the first preset storage location). For example, the preset storage location may include any one or more combinations of relational databases, non-relational databases, local file systems, memory caches, etc., to support persistent storage and high-speed reading of configuration information.
[0055] In step S120, a first rule part is obtained based on the incremental configuration information. The first rule part is the calling rule corresponding to the incremental configuration information.
[0056] The first rule section consists of the program code corresponding to the incremental configuration information, and is part of the invocation rules. Invocation rules are the rules used by the caller when invoking a new version of the API, and can be represented in the form of program code. This program code can be implemented using programming languages such as JavaScript Object Notation (JSON) or YAML (Yin't Markup Language). The caller can invoke the API by executing the invocation rules (i.e., executing the program code corresponding to the invocation rules). Invocation rules can include one or more code blocks, each corresponding to one or more configuration information. For example, assuming the API request parameters include `user_id` and `id_card`, the invocation rule can contain code blocks corresponding to the request parameters, and these code blocks can contain code snippets corresponding to `user_id` and `id_card`. For a new version of the API, the corresponding first rule section can be created based on its incremental configuration information, that is, code snippets or code blocks corresponding to this incremental configuration information can be created. For example, if the incremental configuration information includes the request parameter `user_code`, code snippets corresponding to the request parameter `user_code` can be created in JSON or YAML formats.
[0057] In step S130, the second rule part corresponding to the basic configuration information is obtained from the calling rules corresponding to the previous version of the API.
[0058] Similar to the first rule section, the second rule section consists of program code corresponding to the basic configuration information and is part of the calling rules. The representation of the second rule section can be understood through the above description of the calling rules and the first rule section, and will not be repeated here. Unchanged code blocks or code snippets corresponding to the basic configuration information can be obtained from the calling rules of the previous version of the API and used as the second rule section. For example, in the above example, the request method `post` and the request parameter `id_card` have not changed, so the code snippets or code blocks corresponding to the request method `post` and the request parameter `id_card` can be obtained from the calling rules of the previous version stored in a preset storage location (which can be called the second preset storage location) as the second rule section. The implementation of the second preset storage location is similar to that of the first preset storage location, and will not be repeated here. The second preset storage location and the first preset storage location can be the same storage location or different storage locations. The calling rules of each version of the API can be stored in the aforementioned second preset storage location.
[0059] In step S140, the second rule part and the first rule part are associated to obtain the calling rule used by the caller when calling the new version of the API.
[0060] Specifically, unchanged parts can be associated with changed parts to form a complete calling rule for the new version of the API. This calling rule is a series of code instructions that the caller needs to execute when calling the API, including but not limited to: API access path, request method, request parameters, encryption method, retry strategy, and log attributes. For ease of description, different configuration information is referred to as different configuration items. For example, the URL path https: / / api.credit.com / v2 / getReport, the request method post, the request parameter user_code, and the request parameter id_card are all different configuration items. In the calling rule, each configuration item can have unique identification information to mark the code snippet or code block corresponding to that configuration item. For example, the code snippet or code block corresponding to the basic configuration information can be obtained from the complete calling rule of the previous version of the API through the identification information. These code snippets or code blocks can be directly inherited. The code snippets or code blocks corresponding to the basic configuration information can be merged with the code snippets or code blocks corresponding to the incremental configuration information to finally form the complete calling rule of the new version of the API. This calling rule can be stored in the second preset storage location mentioned above.
[0061] The API call configuration method described above enables an API version management architecture based on "basic configuration + incremental configuration." When an API version changes, only the first rule portion corresponding to the incremental configuration information needs to be generated, and associated with the second rule portion corresponding to the unchanged basic configuration information to generate the call rules for the new version API. There's no need to regenerate the rule portion corresponding to the basic configuration information of the new version API. This reduces manual operations and effectively avoids inconsistencies between old and new versions of the same configuration information. Furthermore, this approach reduces configuration redundancy and improves version management efficiency.
[0062] According to an embodiment of the present invention, before step S110, that is, before determining the basic configuration information and incremental configuration information related to the new version API in response to the user's configuration operation, the method further includes an operation to obtain first overall configuration information, which may include the following steps S210, S220 and S230.
[0063] Step S210: Obtain the API documentation corresponding to the new version of the API.
[0064] For example, API documentation can be in formats such as OpenAPI, Swagger, or Postman Collection provided by the service provider. API documentation can include basic interface information, request parameters, request examples, response structures, etc. The caller can obtain the user-uploaded API documentation through the configuration platform.
[0065] Step S220: Automatically parse the API documentation to obtain the initial configuration information for the new version of the API.
[0066] Specifically, an API resolver can automatically parse the API documentation and extract the parameters required for API calls, such as the URL path, request method, parameter name, parameter type, required fields, response schema, and error code list, to obtain the initial configuration information for the new version of the API. The API resolver can be an OpenAPI resolver, a Swagger resolver, or similar.
[0067] Step S230: Determine the initial configuration information as the first overall configuration information of the new version, or, in response to the user's first update operation, update the initial configuration information to obtain the first overall configuration information of the new version. The first overall configuration information includes basic configuration information and incremental configuration information.
[0068] In one embodiment, the initial configuration information can be directly determined as the first overall configuration information of the new version. In this case, the parsed initial configuration information can be assumed to be the first overall configuration information of the new version. In another embodiment, users can be allowed to update the initial configuration information. Specifically, users can perform a first update operation on the initial configuration information through the visual interface of the configuration platform. The first update operation can include one or more of the following operations: adding new configuration information to the initial configuration information; deleting at least some configuration information from the initial configuration information; modifying at least some configuration information from the initial configuration information. The first update operation facilitates users to achieve personalized configuration, such as improving incomplete configuration information of the new version API to obtain the first overall configuration information. For example, the first update operation may include, but is not limited to: supplementing exception handling strategies, supplementing field mapping rules, configuring encryption methods, etc. Exception handling strategies are the measures taken by the system when API calls fail, and may include retry strategies, alarm strategies, rate limiting strategies, etc. Retry strategies are the methods for re-initiating API calls after a failure. Field mapping rules are rules that establish a correspondence between response parameters in the API response and internal fields of the calling system. For example, if the API response parameter is `user_name` and the calling system's internal field is `userName`, a correspondence can be established. The system determines that `userName` corresponds to `user_name` based on this correspondence, ensuring that the data returned by the API can be correctly identified, parsed, and used by the system. Encryption methods are the algorithms and methods used to encrypt data, protecting data and preventing privacy leaks during transmission and storage. For example, if the initial configuration information of a new version API lacks encryption algorithm configuration information, the user can supplement the encryption algorithm through the configuration platform's visual interface, using, for example, "SM4 symmetric encryption" to encrypt the call request. In this embodiment, in response to the user's first update operation, the updated initial configuration information can be used as the first overall configuration information of the new version. The first overall configuration information includes the aforementioned basic configuration information and incremental configuration information. After obtaining the first overall configuration information, in response to the user's configuration operation, it can be determined which information in the first overall configuration information is basic configuration information and which is incremental configuration information. For example, the initial configuration information obtained through automatic parsing can be classified as basic configuration information by default, and the user can then adjust the classification of the configuration information as needed. Since the initial configuration information usually does not change much between different versions, this information can be defaulted to basic configuration information, for example, automatically displayed in the text box corresponding to basic configuration information. This helps reduce the workload of users in subsequent classification.
[0069] By adopting the above technical solution, initial configuration information can be obtained by automatically parsing the API documentation corresponding to the new version of the API. Then, based on this, the initial overall configuration information can be obtained directly or in response to the user's first update operation. Existing technologies require manual input of configuration information from API documentation, while this technical solution enables automatic parsing and acquisition of configuration information, eliminating the need for manual input and effectively improving configuration efficiency, for example, by more than 60%.
[0070] According to another embodiment of the present invention, the method for obtaining the first overall configuration information may also include the following steps S240, S250, S260 and S270.
[0071] Step S240: Obtain the API documentation corresponding to any older version of the API released before the new version of the API.
[0072] Step S250: Automatically parse the API documentation to obtain the initial configuration information for the old version of the API.
[0073] Step S260: Determine the initial configuration information as the old version of the second overall configuration information, or, in response to the user's second update operation, update the initial configuration information to obtain the old version of the second overall configuration information.
[0074] In step S270, in response to the user's third update operation, the second overall configuration information is updated to obtain the new version of the first overall configuration information, which includes basic configuration information and incremental configuration information.
[0075] The old version API refers to any version of the API released before the new version API, such as the previous version API or an earlier version of the API. The method for obtaining the initial configuration information and the second overall configuration information of the old version API is similar to the method for obtaining the initial configuration information and the first overall configuration information of the new version API in the previous embodiment, and will not be repeated here. Furthermore, the implementation methods of the third update operation and the second update operation are also similar to those of the first update operation described above, and will not be repeated here.
[0076] In this embodiment, the second overall configuration information corresponding to the API has already been determined in any previous version of the API through automatic parsing or a combination of automatic parsing and user updates. Since the configuration information usually does not change significantly during iterations between different versions, the second overall configuration information of the previous old version of the API can be reused. Updates can then be made based on this second overall configuration information to obtain the first overall configuration information of the new version of the API. For example, the overall configuration information can be determined only when configuring the call to the first version of the API using automatic parsing or a combination of automatic parsing and user updates. With each subsequent version update, the overall configuration information of the new version of the API can be obtained through user updates based on the overall configuration information of the first version of the API. It can be understood that in this example, for each version of the API after the second version, it can be updated directly based on the overall configuration information of the first version of the API, or it can be updated based on the overall configuration information of a previous version of the API (different from the first version). The latter case can be considered an indirect update of the overall configuration information of the first version of the API.
[0077] By employing the above technical solution, initial configuration information can be obtained by automatically parsing the API documentation corresponding to the old version API. Then, based on this, a second overall configuration information for the old version API can be obtained directly or in response to a user's second update operation. Finally, based on this second overall configuration information, the first overall configuration information for the new version API can be obtained. As mentioned above, existing technologies extract configuration information from API documentation through manual input. This technical solution, however, enables automatic parsing and acquisition of configuration information, eliminating the need for manual input and significantly improving configuration efficiency. Furthermore, this solution avoids re-parsing the initial configuration information for each new version API, instead reusing some of the overall configuration information from the old version API, thereby reducing repetitive parsing operations and computational load. When the changes in configuration information between different versions are small, this solution achieves a better balance between manual and system operations.
[0078] According to an embodiment of the present invention, after step S220 or step S250, that is, after automatically parsing the API document to obtain the initial configuration information of the new version API, or after automatically parsing the API document to obtain the initial configuration information of the old version API, the API call configuration method may further include: verifying the initial configuration information, and outputting a first error message when the verification fails. The first error message is used to prompt the user that there are erroneous fields in the initial configuration information, wherein the operation of updating the initial configuration information is performed when the verification passes.
[0079] For example, after parsing the initial configuration information, the initial configuration information can be validated. The validation content may include, but is not limited to, at least one of the following: format validation, which verifies whether the URL path format is correct and whether the parameter type of the request parameter is valid; required field validation, which verifies whether all required parameters have been configured; and validity validation, which verifies whether the configuration value is within the preset range.
[0080] For example, the first error message can be output in any form, such as text, voice, or image. For instance, the first error message can be output on the configuration platform's visual interface. For example, the first error message may include: the error field name, error type, and error description. Users can locate and correct configuration errors based on the first error message, and then resubmit for verification until the verification passes before proceeding with subsequent update operations.
[0081] By employing the above technical solution, the initial configuration information obtained through automatic parsing can be automatically verified, and the user will be automatically notified when the verification fails, allowing for timely correction and preventing incorrect configurations from entering the runtime environment. This intelligent verification scheme can effectively improve the accuracy of configuration and the stability of the system, while reducing the workload of manual checks by users.
[0082] Similarly, after step S230 or step S270, that is, after updating the initial configuration information in response to the user's first update operation to obtain the new version's first overall configuration information, or after updating the old version's second overall configuration information in response to the user's third update operation to obtain the new version's first overall configuration information, the API call configuration method may further include: validating the first overall configuration information, and outputting a second error message when the validation fails. The second error message is used to prompt the user that there are erroneous fields in the first overall configuration information. The operation of determining the basic configuration information and incremental configuration information related to the new version API in response to the user's configuration operation is performed when the validation passes.
[0083] Similar to the initial configuration information, after obtaining the first overall configuration information, it can be validated. The validation content of the first overall configuration information is similar to that of the initial configuration information, and the second error message is similar in appearance and function to the first error message, which will not be elaborated here. Through automatic validation and the output of the second error message, users can locate and correct configuration errors, resubmit for validation after correction, and only after the validation passes can subsequent operations such as configuration information classification and rule generation be performed.
[0084] By employing the above technical solution, the initial overall configuration information can be automatically verified, and the user will be automatically notified if the verification fails, allowing for timely correction and preventing erroneous configurations from entering the runtime environment. This intelligent verification scheme can effectively improve the accuracy of configuration and the stability of the system, while reducing the workload of manual checks by users.
[0085] According to embodiments of the present invention, each of the first update operation, the second update operation, and the third update operation includes one or more of the following setting operations.
[0086] (a) Set encryption and decryption configuration information. The encryption and decryption configuration information is used to configure the encryption and decryption methods for API call requests and response results.
[0087] For example, encryption and decryption may include, but are not limited to, one or more of the following: encrypting request parameters, encrypting and decrypting the transmission channel, encrypting the request header, encrypting the entire request body, and decrypting response parameters.
[0088] For example, users can configure the platform to encrypt fields that require encryption, such as ID card number (id_card) and mobile phone number (phone), and select encryption algorithms, such as SM4 symmetric encryption, RSA asymmetric encryption, and HTTPS / TLS transmission encryption. The caller can generate encryption / decryption configuration information based on the user's configuration. For instance, if the user configures "Enable SM4 encryption for the id_card field," the caller can automatically encrypt the value of the id_card field using SM4 when initiating an API call, and automatically decrypt the encrypted response field upon receiving the API response.
[0089] (ii) Configure log settings. Log settings are used to configure the log attributes of API call logs. Log attributes include the field content of the call logs and / or the retention time of the call logs.
[0090] For example, users can configure the fields of the call log through the configuration platform, including but not limited to one or more of the following fields: call subject, call time, API name, API version, request parameter summary, response result, encryption / decryption status, error code, etc. Users can also set the retention period for the call logs, such as 30 days, 90 days, etc., to meet the compliance audit requirements of different business scenarios.
[0091] (iii) Set retry policy configuration information. The retry policy configuration information is used to configure the retry parameters when making API calls. For example, the retry parameters may include one or more of the following: retry error type, retry interval and retry circuit breaker threshold. The retry error type is used to limit the types of errors that are allowed to be retried, and the retry circuit breaker threshold is the maximum number of consecutive retries.
[0092] For example, users can configure retry policies through the platform's visual interface. For example, retry error types can include timeout errors, rate-limiting errors, etc. The caller can automatically identify the error type and determine whether to allow retries based on the call history, which can be obtained by viewing the call logs. For example, the retry interval can increase with the number of retries to avoid excessive burden on the callee due to frequent retries; for example, the first retry waits 1 second, the second waits 3 seconds, and the third waits 5 seconds. Of course, the retry interval can also be fixed. The retry circuit breaker threshold is the maximum number of consecutive retries. When the number of consecutive retries reaches the retry circuit breaker threshold, retries automatically stop and an alarm is triggered. For example, the retry circuit breaker threshold can be set to 5 times. When the number of consecutive retries reaches 5, retries can automatically stop and an alarm is triggered to avoid resource waste and service crashes caused by infinite retries.
[0093] (iv) Configure resource control information. Resource control configuration information is used to configure resource control parameters when API calls are made. Control parameters include one or more of the following: maximum concurrency of a single API, maximum global concurrency, and caching rules. Maximum concurrency of a single API is the maximum number of simultaneous API call requests. Maximum global concurrency is the maximum number of simultaneous API call requests. Caching rules are used to limit the cache validity period of target call requests and / or the target response results corresponding to target call requests. For example, when the caller calls the API, the target response result obtained from the callee is cached in a preset cache area according to the caching rules. When the target call request is generated, the target response result is retrieved from the preset cache area. If it is not retrieved, the target call request is sent to the callee.
[0094] For example, users can configure resource management settings through the platform's visual interface. For instance, the maximum concurrency for a single API can be set to 10, meaning a maximum of 10 concurrent API calls can be processed simultaneously. This prevents a single popular API from consuming all system resources and ensures normal calls to other APIs. Alternatively, the global maximum concurrency can be set to 100, meaning all API calls can be processed simultaneously, with a maximum of 100 concurrent calls. This prevents system overload due to excessive total requests. When configuring caching rules, users can select the conditions that API call requests should meet, including, for example, API scope, parameter conditions, and response conditions. The cache validity period is one hour, and API call requests that meet the conditions can be cached in a preset storage location (which can be called the third preset storage location). The third preset storage location is implemented similarly to the first preset storage location mentioned above, and will not be elaborated here. The third preset storage location can be the same as or different from either the second or first preset storage location. When subsequent requests for the same API are generated, the target response can be retrieved from the third preset storage location first. If it is not retrieved, i.e., a cache miss occurs, the target request can be sent to the callee for actual invocation. This can greatly reduce the time spent processing high-frequency API calls.
[0095] (v) Set grayscale configuration information. Grayscale configuration information is used to configure grayscale release parameters. Grayscale release parameters include grayscale ratio and / or whitelist rules. Grayscale ratio is the proportion of callers allowed to call the API among all callers. Whitelist rules are used to specify callers allowed to call the API.
[0096] For example, users can configure canary deployment information through the platform's visual interface. For instance, setting the canary deployment ratio to 10% means that 10% of requests will be routed to the new API version, while 90% will still be routed to the old API version. Users can also specify which IP addresses, user IDs, or request headers can be used to call the new API version through whitelist rules. Adjusting the canary deployment ratio and whitelist rules in this way allows for a gradual rollout of the new API version. Once the new API version is verified to be stable, the canary deployment ratio can be gradually increased until it reaches 100%, completing the full rollout.
[0097] Through the above configuration operations, this invention realizes comprehensive personalized configuration of API calls. Users can flexibly configure encryption, logging, retry, resource management and canary release strategies according to business needs, and complete configuration changes without modifying the code.
[0098] According to an embodiment of the present invention, after step S140, that is, after associating the second rule part and the first rule part to obtain the calling rules of the new version API, the method further includes a simulated calling operation, which may include the following steps S410, S420 and S430.
[0099] Step S410: Receive test parameters input by the user.
[0100] Specifically, users can input test parameters through the configuration platform's visual interface. The test parameters are the specific values of the request parameters required to call the log API, such as user_id=123456, id_card=11010119001011234, etc.
[0101] Step S420: In response to the simulated call command input by the user, the call flow of the new version API is simulated according to the call rules, and the test parameters are processed to obtain the simulated response result and simulated call log.
[0102] Simulated call commands can be input in any form, such as by clicking a button control. For example, in response to the user clicking the "Simulated Call" button control, the caller can process the test parameters input by the user according to the calling rules of the new version API obtained in step S140. The processing flow includes, but is not limited to, parameter concatenation, field encryption, and request construction. The caller simulates the real API call process locally without actually sending network requests to the callee. The result of the simulated call is the generation of a simulated response and a simulated call log. The simulated call log records the execution status of each step in the simulated call process, such as "parameter concatenation successful," "field encryption successful," "request sent successfully," and "response parsing successful," which helps the user locate configuration errors.
[0103] Step S430: Output the simulation response result and simulation call log. When the caller receives the simulation success instruction from the user, it calls the new version API based on the calling rules.
[0104] The simulation response results and simulation call logs can be output in any format, such as text, voice, or image information. For example, the simulation response results and simulation call logs can be displayed in text format on the configuration platform's visual interface for users to view and analyze.
[0105] Users can determine the correctness of the configuration based on the simulated response results and simulated call logs. If the configuration is correct, the user can input a simulated success command, such as clicking the "Confirm Release" button. The caller then considers the configuration verification successful and can actually call the new version API based on this calling rule. If there are errors in the configuration, users can locate the problem and modify the configuration according to the simulated call logs. After modification, the simulated call can be executed again for verification.
[0106] The above technical solution provides a closed-loop debugging mechanism of "configuration-simulation verification-modification-re-verification". After the configuration is completed, the developers can directly verify the correctness of the configuration without deploying it to the test environment for debugging, which significantly shortens the debugging cycle and reduces the debugging cost.
[0107] According to another aspect of the present invention, an API invocation method is also provided. Similar to the API invocation configuration method, the API invocation method can also be applied to a caller invoking an API. The API invocation method includes the API invocation configuration method in any of the above embodiments, and further includes step S510.
[0108] Step S510: When the current call request is generated, call the new version of the API based on the call rules.
[0109] Specifically, when a caller needs to invoke a new API, a current invocation request is generated. The caller can construct the new API invocation request based on the invocation rules obtained in step S140, including operations such as concatenating the request URL, setting the request method, adding request headers, and filling in request parameters. Then, the constructed invocation request can be sent to the callee to invoke the new version of the API.
[0110] API calling methods include API calling configuration methods. Therefore, the above technical solution can also implement an API version management architecture based on "basic configuration + incremental configuration". When the API version changes, only the first rule part corresponding to the incremental configuration information needs to be generated, and associated with the second rule part corresponding to the unchanged basic configuration information to generate the calling rules for the new version API. There is no need to regenerate the rule part corresponding to the basic configuration information of the new version API. This reduces manual operations and effectively avoids inconsistencies between the old and new versions of the same configuration information. At the same time, this solution can reduce configuration redundancy and improve version management efficiency.
[0111] According to an embodiment of the present invention, after calling the new version of the API using the calling rules, the API calling method further includes the following steps S520 and S530.
[0112] Step S520: Receive the current response result returned by the callee corresponding to the current call request.
[0113] Step S530: Based on the preset log configuration information and the current response result, generate a call log corresponding to the current call request and save the call log in the log collection.
[0114] Specifically, the caller can receive the current response result returned by the callee corresponding to the current call request, and generate a call log corresponding to the current call request based on the preset log configuration information and the current response result, and save the call log in a log set. The log set can be stored in a preset storage location (which can be called the fourth preset storage location). The implementation of the fourth preset storage location is similar to that of the first preset storage location mentioned above, and will not be repeated here. The fourth preset storage location can be the same storage location as the third, second, and first preset storage locations, or it can be a different storage location. After storing the log set, in response to the user's retrieval operation, the matching call log can be retrieved from the log set, and in response to the user's export operation, the call log corresponding to the current call request can be exported as a preset format file. The preset file format can be default or specified by the user, for example, the preset file format can be CSV, JSON, Excel, etc.
[0115] Through the above steps, this invention achieves a complete closed loop from configuration to invocation, with configuration driving invocation and invocation verifying configuration. It also realizes structured storage, flexible retrieval, and convenient export of invocation logs, meeting the requirements of application scenarios such as the financial industry for full-chain compliance traceability of API calls.
[0116] According to another aspect of the invention, see Figure 2 A configuration device 200 for invoking an API is provided, comprising:
[0117] The determination module 210 is used to respond to the user's configuration operation and determine the basic configuration information and incremental configuration information related to the new version API. The basic configuration information is the configuration information of the new version API that has not changed compared to the previous version API, and the incremental configuration information is the configuration information of the new version API that has changed compared to the previous version API.
[0118] The module 220 is used to obtain the first rule part based on the incremental configuration information. The first rule part is the calling rule corresponding to the incremental configuration information.
[0119] Module 230 is used to retrieve the second rule portion corresponding to the basic configuration information from the calling rules corresponding to the previous version of the API; and
[0120] The association module 240 is used to associate the second rule part and the first rule part to obtain the calling rule used by the caller when calling the new version of the API.
[0121] According to another aspect of the present invention, an API invocation apparatus is provided, including the API invocation configuration apparatus 200 described above, and further including: an invocation module, configured to invoke a new version of the API based on invocation rules when the current invocation request is generated.
[0122] According to another aspect of the invention, see Figure 3 An electronic device 300 is provided. The electronic device 300 includes a processor 310 and a memory 320. The memory 320 stores computer program instructions, which are executed by the processor 310 to perform any of the API call configuration methods or API call methods described above.
[0123] According to another aspect of the present invention, a storage medium is provided on which program instructions are stored, which, when executed, are used to perform any of the API call configuration methods or API call methods described above.
[0124] According to another aspect of the present invention, a computer program product is provided, comprising computer program instructions that, when executed, perform an API call configuration method or API call method as described above.
[0125] Those skilled in the art, by reading the above detailed descriptions of the API call configuration method and the API call method, can understand the specific implementation and beneficial effects of the above API call configuration device, API call device, electronic device, storage medium, and computer program product. For the sake of brevity, further details are omitted here.
[0126] Although exemplary embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above exemplary embodiments are merely illustrative and are not intended to limit the scope of the invention. Various changes and modifications can be made therein by those skilled in the art without departing from the scope and spirit of the invention. All such changes and modifications are intended to be included within the scope of the invention as claimed in the appended claims.
[0127] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0128] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed.
[0129] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0130] Similarly, it should be understood that, in order to streamline the invention and aid in understanding one or more of the various aspects of the invention, features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the description of exemplary embodiments of the invention. However, this approach should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the corresponding claims, its inventive point lies in solving the corresponding technical problem with fewer features than all of those in a single disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into that detailed description, wherein each claim itself is a separate embodiment of the invention.
[0131] Those skilled in the art will understand that, apart from the mutual exclusion of features, all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or elements of any method or apparatus so disclosed may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0132] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments can be used in any combination.
[0133] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some modules according to the embodiments of the present invention. The present invention can also be implemented as an apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0134] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0135] The above are merely specific embodiments or descriptions of the present invention, and the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. The scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for configuring API calls, characterized in that, The method includes: In response to the user's configuration operation, determine the basic configuration information and incremental configuration information related to the new version API. The basic configuration information is the configuration information of the new version API that has not changed compared to the previous version API, and the incremental configuration information is the configuration information of the new version API that has changed compared to the previous version API. A first rule part is obtained based on the incremental configuration information, and the first rule part is the invocation rule corresponding to the incremental configuration information; Obtain the second rule part corresponding to the basic configuration information from the calling rules corresponding to the previous version API; The second rule part is associated with the first rule part to obtain the calling rules used by the caller when calling the new version of the API.
2. The API call configuration method according to claim 1, characterized in that, Before determining the basic and incremental configuration information related to the new version API in response to the user's configuration operation, the API call configuration method further includes: Obtain the API documentation corresponding to the new version of the API; The API documentation is automatically parsed to obtain the initial configuration information for the new version of the API. The initial configuration information is determined as the first overall configuration information of the new version, or, in response to the user's first update operation, the initial configuration information is updated to obtain the first overall configuration information of the new version, wherein the first overall configuration information includes the basic configuration information and the incremental configuration information; or, Retrieve the API documentation corresponding to any older version of the API released prior to the new version of the API; The API documentation is automatically parsed to obtain the initial configuration information for the older version of the API. The initial configuration information is determined as the second overall configuration information of the old version, or, in response to the user's second update operation, the initial configuration information is updated to obtain the second overall configuration information of the old version; In response to the user's third update operation, the second overall configuration information is updated to obtain the new version of the first overall configuration information, which includes the basic configuration information and the incremental configuration information.
3. The API call configuration method according to claim 2, characterized in that, After obtaining the initial configuration information for the new or old version, the API call configuration method further includes: The initial configuration information is validated. If the validation fails, a first error message is output. The first error message is used to inform the user that there are erroneous fields in the initial configuration information. The operation of updating the initial configuration information is performed when the validation passes.
4. The API call configuration method according to claim 2, characterized in that, After obtaining the first overall configuration information of the new version, the API call configuration method further includes: The first overall configuration information is validated. If the validation fails, a second error message is output. The second error message is used to inform the user that there are erroneous fields in the first overall configuration information. The operation of determining the basic configuration information and incremental configuration information related to the new version API in response to the user's configuration operation is performed when the validation passes.
5. The API call configuration method according to claim 2, characterized in that, Each of the first update operation, the second update operation, and the third update operation includes one or more of the following operations: Configure encryption / decryption settings, which are used to configure the encryption / decryption methods for API call requests and response results; Set log configuration information, which is used to configure the log attributes of API call logs. The log attributes include the field content of the call logs and / or the retention time of the call logs. Set retry policy configuration information, which is used to configure retry parameters when calling API. The retry parameters include one or more of the following: retry error type, retry interval time and retry circuit breaker threshold. The retry error type is used to limit the types of errors that are allowed to be retried. The retry circuit breaker threshold is the maximum number of consecutive retries. Configure resource management information, which is used to configure resource usage control parameters when API calls are made. The control parameters include one or more of the following: maximum concurrency of a single API, maximum global concurrency, and caching rules. The maximum concurrency of a single API is the maximum number of simultaneous API call requests. The maximum global concurrency is the maximum number of simultaneous API call requests. The caching rules are used to limit the cache validity period of target call requests that are allowed to cache response results and / or the cache validity period of the target response results corresponding to the target call requests. The grayscale configuration information is set to configure grayscale release parameters, which include grayscale ratio and / or whitelist rules. The grayscale ratio is the proportion of callers allowed to call the API among all callers, and the whitelist rules are used to specify the callers allowed to call the API.
6. The API invocation configuration method according to any one of claims 1-5, characterized in that, After obtaining the invocation rules, the API invocation configuration method further includes: Receive test parameters input by the user; In response to the simulated call command input by the user, the call flow of the new version API is simulated according to the call rules, and the test parameters are processed to obtain the simulated response result and the simulated call log; Output the simulated response results and the simulated call log; Specifically, when the caller receives a simulated success command input by the user, it invokes the new version of the API based on the invocation rules.
7. A method for invoking an API, characterized in that, Includes the API invocation configuration method according to any one of claims 1-6, and further includes: When the current call request is generated, the new version of the API is invoked based on the invocation rules.
8. The API invocation method according to claim 7, characterized in that, After the new version of the API is invoked using the aforementioned invocation rules, the API invocation method further includes: Receive the current response result returned by the callee corresponding to the current call request; Based on the preset log configuration information and the current response result, generate a call log corresponding to the current call request and save the call log in the log collection; In response to a user's search operation, a matching call log is retrieved from the log set, and / or, in response to a user's export operation, the call log corresponding to the current call request is exported as a preset format file.
9. An electronic device comprising a processor and a memory, characterized in that, The memory stores computer program instructions, which, when executed by the processor, are used to perform the API call configuration method according to any one of claims 1-6 or the API call method according to claim 7 or 8.
10. A computer program product comprising computer program instructions, characterized in that, The computer program instructions, when executed, are used to perform the API invocation configuration method according to any one of claims 1-6 or the API invocation method according to claim 7 or 8.
