API arrangement gateway based on multiple scripting languages

Through API orchestration gateways based on multi-scripting languages, the problem that traditional API gateways are difficult to support multi-API orchestration and dynamically adjust requests and responses is solved, and breakthroughs in multi-API orchestration and data barriers are achieved, providing higher flexibility and practicality.

CN119449533APending Publication Date: 2025-02-14TROY INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411601267.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

Traditional API gateways are difficult to support multi-API orchestration and dynamic adjustment of requests and responses, and there are problems of upstream and downstream data barriers, which cannot meet the flexible needs of users.

Method used

Using a multi-script language-based API orchestration gateway, multiple API orchestration components are configured through the API orchestration module, orchestration API interfaces such as groovy scripts, and aggregate scripts to the database. Use the request cache loading module to preload scripts to the Redis cache to implement Dynamic response.

Benefits of technology

It realizes the support of multi-API orchestration, the ability to dynamically adjust requests and responses, breaks through upstream and downstream data barriers, provides higher flexibility and practicality, and reduces the pressure on the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119449533A_ABST
    Figure CN119449533A_ABST
Patent Text Reader

Abstract

The invention provides an API arrangement gateway based on multiple scripting languages, and belongs to the technical field of API gateways. The gateway comprises an API arrangement module, a request cache loading module and an API calling module; wherein the API arrangement module is used for configuring a plurality of API arrangement components, arranging the group scripts of the plurality of API interfaces through the API arrangement components, aggregating the group scripts of the plurality of API interfaces, and storing the aggregated group scripts into the database; the request cache loading module is used for pre-loading a group script corresponding to an API interface from a database to a Redis cache, and when an API calling request is received, the corresponding group script is called from the cache to respond to the request; and the API calling module is used for initiating an API calling request according to the interface address, storing a responded group script into a local temporary file of the server, and loading and executing the group script through the Lite Flow visual component. According to the invention, the dynamic processing of the API request and response is realized, and the flexibility and expansibility of the system are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of API gateways, and in particular to an API orchestration gateway based on multiple scripting languages. Background Art

[0002] In today's software architecture, API gateways are a key middleware responsible for managing and routing different API requests. However, most traditional API gateways only support single-line proxy mode, which means they can only forward requests but do not have the ability to orchestrate multiple APIs. In addition, traditional API gateways have limitations in processing complex request and response parameters, and are usually unable to dynamically adjust requests and responses based on specific user needs.

[0003] In addition, API systems often face the problem of upstream and downstream data barriers. Downstream interface manufacturers are often unable to provide detailed indicator data, while upstream users are unwilling to expose their parameters to downstream manufacturers. Upstream users hope to be able to combine downstream data for customized calculations to obtain the final desired results, but the existing system is difficult to meet this demand.

[0004] Therefore, there is an urgent need for a new API gateway solution that can support multi-API orchestration, dynamic request and response processing, while breaking through upstream and downstream data barriers and providing greater flexibility and practicality. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides an API orchestration gateway based on multiple scripting languages ​​to solve the problem that the existing API gateway is difficult to support multiple API orchestrations and dynamically adjust requests and responses.

[0006] The technical solution adopted by the present invention is: The present invention provides an API orchestration gateway based on multiple scripting languages, comprising: The API orchestration module is used to configure multiple API orchestration components, orchestrate the groovy scripts of multiple API interfaces through the API orchestration components, and aggregate the groovy scripts of multiple API interfaces and store them in the database according to a preset data format; The request cache loading module is used to preload the groovy script corresponding to the API interface from the database to the Redis cache, and when an API call request is received, the corresponding groovy script is called from the Redis cache to respond to the API call request; The API call module is used to initiate an API call request based on the interface address of the API interface, store the response groovy script in a local temporary file of the server, and load and execute the groovy script through the Lite Flow visualization component.

[0007] Furthermore, the API orchestration module includes: A component configuration unit is used to configure an orchestration engine that can dynamically load and update scripts, and import API orchestration components in a visual workflow interface; the scripts include groovy scripts, javascript scripts, Python scripts, lua scripts, java scripts, and Aviator scripts; the API orchestration components include lite flow components and custom components, and the custom components include ip gateway blacklists and whitelists and groovy script components; The script writing unit is used to obtain the groovy scripts of multiple API interfaces custom-written by the user through the API orchestration component, and aggregate the groovy scripts of multiple API interfaces into an API workflow; A data format conversion unit, used to convert the API workflow into a workflow file in a preset data format and store it in a database, and to format the return data of the API interface into the format required by the user; The interface registration unit is used to use the interface address input by the user as the key, and dynamically register the interface with the API workflow of the API interface as the execution logic, register the API interface in the request mapping processor of the spring MVC framework, and bind it to the execute function; the interface address is used to expose the API interface externally.

[0008] Furthermore, the script writing unit is also used to obtain the script requirement description input by the user, and call the big model to write the groovy script corresponding to the script requirement description, and call the big model to verify and correct the groovy script customized by the user.

[0009] Furthermore, the API orchestration module also includes a script hot backup unit, which is used to hot backup the groovy scripts submitted and modified by the user to GitHub.

[0010] Furthermore, the request cache loading module includes: The script preloading unit is used to preload the groovy script corresponding to the API interface from the database to the Redis cache when the interface service is started; The request response unit is used to determine whether there is a groovy script corresponding to the API interface in the Redis cache when receiving an API call request. If so, the corresponding groovy script is called from the Redis cache to respond to the API call request. If not, the corresponding groovy script is queried from the database and loaded into the Redis cache to respond to the API call request. The cache clearing unit is used to clear the corresponding loaded groovy script in the Redis cache when the orchestration process of the API interface is modified.

[0011] Furthermore, the API calling module includes: An interface calling unit, used to initiate an API calling request to a corresponding API interface according to the exposed interface address; The script execution unit is used to obtain the response groovy script and store it in the local temporary file of the server. At the same time, the groovy script is loaded through the Lite Flow visual component to instantiate the FlowExecutor and execute the workflow of the groovy script. After the workflow is executed, the local temporary file is deleted.

[0012] In summary, the beneficial effects of the present invention are as follows: The API orchestration gateway based on multiple scripting languages ​​provided by the present invention provides users with a visual working interface containing multiple API orchestration components, so that users can freely orchestrate the scripts of the API interface by dragging and dropping the page, realizing multiple API orchestration while also supporting the conversion and formatting of the received data to meet the specific needs of users. At the same time, the present invention also preloads the groovy script corresponding to the API interface from the database to the Redis cache, and when an API call request is received, the corresponding groovy script is called from the Redis cache to respond to the API call request, avoiding the pressure on the database caused by cache avalanche during API requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the following is a brief introduction to the drawings required for use in the embodiment of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work, and these are all within the protection scope of the present invention.

[0014] Figure 1 This is a functional module structure diagram of an API orchestration gateway based on multiple scripting languages ​​of the present invention; Figure 2 A flow chart for script loading process of the present invention; Figure 3 A flowchart of the pull-line association arrangement of the API arrangement component of the present invention; Figure 4 This is a flow chart of dynamic interface registration of the present invention; Figure 5 Modify the flow chart for the workflow arrangement of the present invention; Figure 6 The present invention is a flowchart of API calling and loading script files. DETAILED DESCRIPTION

[0015] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. If there is no conflict, the various features of the present invention and the embodiments can be combined with each other, all within the scope of protection of the present invention.

[0016] Information security is extremely important nowadays, and both upstream and downstream parties of the API interface do not want to provide detailed data to each other. Take the following real case as an example.

[0017] A bank uses the data of a company's electricity usage as an indicator for evaluating the company's loan amount. The bank hopes to refer to the credit rating of some of its own companies to get a comprehensive evaluation score when calling the company's API interface, but the bank does not want to provide its own data to the API interface provider. The API interface provider cannot provide its detailed data to the bank, which creates a data barrier.

[0018] The present invention can solve the above problems. The interface provider only needs to calculate a score based on its own algorithm. After a line obtains the score of a company's power data through the API orchestration gateway, it can add some of its own weight parameters to generate the final score before the interface is returned. Users can arrange multiple interfaces from different data vendors in a visual way according to their needs, and return data in the format they need. The detailed implementation process of the present invention is shown in the following embodiments.

[0019] Example 1: Reference Figure 1 As shown, Figure 1 This is a functional module structure diagram of an API orchestration gateway based on multiple scripting languages ​​of the present invention. Figure 1 As shown, an API orchestration gateway based on multiple scripting languages ​​includes: The API orchestration module is used to configure multiple API orchestration components, orchestrate the groovy scripts of multiple API interfaces through the API orchestration components, and aggregate the groovy scripts of multiple API interfaces and store them in the database according to a preset data format; The request cache loading module is used to preload the groovy script corresponding to the API interface from the database to the Redis cache, and when an API call request is received, the corresponding groovy script is called from the Redis cache to respond to the API call request; The API call module is used to initiate an API call request based on the interface address of the API interface, store the response groovy script in a local temporary file of the server, and load and execute the groovy script through the Lite Flow visualization component.

[0020] Furthermore, in an embodiment of the present invention, the API orchestration module includes: The component configuration unit is used to configure an orchestration engine that can dynamically load and update scripts, and import API orchestration components in a visual workflow interface; the scripts include groovy scripts, javascript scripts, Python scripts, lua scripts, java scripts and Aviator scripts; the API orchestration components include lite flow components and custom components, and the custom components include ip gateway blacklists and whitelists and groovy script components.

[0021] The script writing unit is used to obtain the groovy scripts of multiple API interfaces custom-written by the user through the API orchestration component, and aggregate the groovy scripts of the multiple API interfaces into an API workflow.

[0022] The data format conversion unit is used to convert the API workflow into a workflow file in a preset data format and store it in a database, and to format the return data of the API interface into the format required by the user.

[0023] The interface registration unit is used to use the interface address input by the user as the key, and dynamically register the interface with the API workflow of the API interface as the execution logic, register the API interface in the request mapping processor of the spring MVC framework, and bind it to the execute function; the interface address is used to expose the API interface externally.

[0024] Among them, the orchestration engine in the embodiment of the present invention is the core component for implementing API orchestration, which is responsible for parsing the orchestration rules and aggregating the data streams of multiple API interfaces together. The orchestration engine supports the definition of data streams, format conversion and output rules, and can process different types of API calls and integrate the results. The embodiment of the present invention uses multiple script engines to configure the orchestration engine, which can support groovy, javascript, Python, lua, java, and Aviator scripts, and each script is correspondingly provided with a corresponding script engine.

[0025] Among them, groovy, javascript, Python, and lua are scripting languages ​​in themselves, which can be dynamically loaded after being stored in a database. Java is compiled in real time, and the compiled class files are stored in the database, so that the API orchestration gateway has dynamic characteristics. The orchestration engine of the present invention also has the ability of hot loading. The groovy, javascript, Python, lua, java, and Aviator script engines support hot loading functions, so that the modified script can take effect immediately without restarting the system. This is achieved by dynamically loading and updating scripts through the ScriptEngineManager of the script engine. For example, for java scripts, hot updates are achieved by using real-time editing and real-time loading.

[0026] Specifically, the data format conversion unit of the embodiment of the present invention supports conversion and formatting of received data to meet the specific needs of users, can process data formats such as JSON and XML, and perform customized formatting operations through script rules.

[0027] For example, the following two resp1 and resp2 are data in JSON format returned by two API interfaces. The results can be arranged through groovy scripts.

[0028] def resp1=https.post("http: / / xxx",request1) def resp2=https.post("http: / / xxx2",request2) def response={“name”:resp1.resp1,”value”:resp1.value*resp1.weight} reponse In this way, the response processing operation will be returned in the format required by the user.

[0029] Furthermore, the script writing unit of the embodiment of the present invention is also used to obtain the script requirement description input by the user, and call the big model to write the groovy script corresponding to the script requirement description, and call the big model to verify and correct the groovy script customized by the user.

[0030] Specifically, in order to improve the efficiency of script writing, the present invention also supports users to describe their own needs in text in the script writing interface, and then call the big model to return the script to the page, and at the same time, the big model can be used to verify and correct their own scripts. Among them, the big model can use qianwen2. When writing scripts in the interface, select the script type and describe your own script requirements in text form, then send it to the big model, and the big model returns the script to the interface. The user can modify the script according to the big model. Secondly, the user can submit the script written by himself to the model for verification and correction of the script, which greatly improves the efficiency and accuracy of script writing.

[0031] Specifically, in the embodiment of the present invention, the component configuration unit can be used to configure a visual workflow interface, in which API orchestration can be performed by dragging and dropping based on the Lite Flow visual component, and users can also import open source Lite Flow components and custom components. Finally, a JSON file of the API orchestration workflow is formed through Lite Flow, and the workflow is executed when the API is called.

[0032] The present invention customizes two components: an IP gateway blacklist and whitelist and a groovy script component. The groovy script component can be scripted by itself or with the assistance of AI.

[0033] Furthermore, in an embodiment of the present invention, the API orchestration module further includes a script hot backup unit, which is used to hot backup the groovy script submitted and modified by the user to GitHub. The user can choose whether to hot backup the script when writing an orchestration file or script. When the user submits and modifies the script, the script will be saved on GitHub, and the user can also select a script file from GitHub to load into the interface.

[0034] The API orchestration module of the embodiment of the present invention supports the orchestration of multiple API interfaces, can aggregate the data of multiple interfaces together, and generate output in a specified format according to user requirements. The module also allows users to define complex data flows and processing logic to meet diverse business needs.

[0035] Specifically, the API arrangement module of the present invention can derive multiple different interfaces from a basic interface. For example, a wide table interface containing detailed data can generate multiple interfaces in different formats by writing different groovy scripts according to different set algorithms to meet different needs.

[0036] The present invention has the characteristics of hot loading, based on a variety of dynamic scripting technologies, to achieve instant effectiveness of the script, without the need for compilation and system restart. After the script is modified, the system can load and apply the changes instantly, improving the flexibility and real-time response capability of the system.

[0037] The present invention supports interface visualization operation and provides a drag-and-drop workflow interface. Users can generate and store orchestration scripts through graphical operations, simplifying the orchestration process and script management. The interface design is intuitive, reducing the complexity of users creating and maintaining orchestration scripts.

[0038] The present invention also supports multiple custom function extensions. Multiple custom java functions are built into the script, and other functions can also be extended: such as time processing function, static code table value function, API interface calling function. Other functions can also be extended. These functions can be called in groovy. The static code table function is called as follows: def weight=dicutil.get('DECAL_WEIGHT','1').

[0039] Embodiment 2: In the embodiment of the present invention, the request cache loading module includes: The script preloading unit is used to preload the groovy script corresponding to the API interface from the database to the Redis cache when the interface service is started; The request response unit is used to determine whether there is a groovy script corresponding to the API interface in the Redis cache when receiving an API call request. If so, the corresponding groovy script is called from the Redis cache to respond to the API call request. If not, the corresponding groovy script is queried from the database and loaded into the Redis cache to respond to the API call request. The cache clearing unit is used to clear the corresponding loaded groovy script in the Redis cache when the orchestration process of the API interface is modified.

[0040] The embodiment of the present invention adopts redis goovy script and static code table for performance reasons, and loads data from the database when an API request is required, thereby improving the request efficiency. Figure 2 As shown, the script loading process of the embodiment of the present invention is as follows: (1) Preload script cache when the service starts: The purpose of preloading data into the cache when the service starts is to avoid the pressure on the database caused by cache avalanche when API requests are made.

[0041] (2) Cache loading during API request: When an API request is made, first determine whether the Groovy script of the interface already exists in the cache. If it does, use it directly. If it does not, query the database and load it into the redis cache.

[0042] (3) Cache clearing when the API orchestration process changes: If the API programming process is modified, redis will be invalidated. The purpose is to query the latest orchestration script from the database and load it into the cache when the API is called.

[0043] Specifically, in an embodiment of the present invention, after the user completes script writing, it is necessary to proceed to the next step 1. Orchestration workflow addition. After dragging the "API Orchestration Component" component on the interface. There are some input boxes on the component, specifically: API target address: the address of the called API. Script type: groovy, js, luna, etc. Pre-processing: Request parameter processing script before API request, which can be empty. If empty, the request parameters of the upstream interface are fully passed in. Request script: The request script is the processing of the API call, and the free orchestration of the interface and the processing of input and output parameters can be realized through functions. Post-processing: The return result in the request script can be further processed.

[0044] Of course, you can also configure multiple API orchestration components to orchestrate by pulling wires. Figure 3 The API orchestration component pulls the line to associate the orchestration process shown. After authorization, api1 serially calls api2, and then api2 calls api3. Then, a "combination component" is used to combine the results of api2 and api3 for output.

[0045] Submission process: When submitting the process, you need to enter an interface address, which is the interface address that is ultimately exposed to the outside world.

[0046] Dynamic binding of interface: After successful submission, the API interface entity will be assembled. The interface address entered above will be used as the key, and the workflow script will be arranged as the execution logic to dynamically register the interface. The interface registration uses spring's RequestMappingHandlerMapping (request mapping processor) to register an execute function, and the execute function will call the script.

[0047] Reference Figure 4 As shown, the dynamic registration process of the API interface in the embodiment of the present invention is specifically as follows: (1) Convert the API workflow submitted by the visualization page into json data; (2) Assemble API interface entities; (3) Register the interface using Spring’s RequestMappingHandlerMapping (request mapping processor) and bind it to an execute function.

[0048] (4) Determine whether the interface registration is successful. If the registration is successful, cache the json script containing groovy to Redis. If the registration fails, end the interface registration.

[0049] Furthermore, in the embodiment of the present invention, the API orchestration module also includes a workflow orchestration modification function, and the workflow orchestration modification is the same as the workflow orchestration addition. It just cancels the registration of the original API and then registers the new interface. Figure 5 As shown, the workflow orchestration modification business logic is as follows: 1. Submit basic process information to the database, including basic API information, process scripts, etc.

[0050] 2. Remove the original API registration and delete the cache.

[0051] 3. Submit a new API registration and add it to the new cache.

[0052] Furthermore, in an embodiment of the present invention, the API orchestration module also includes a workflow deletion function. When deleting a workflow, the workflow information, cache, and API registration will be deleted.

[0053] Embodiment 3: In the embodiment of the present invention, the API calling module includes: An interface calling unit, used to initiate an API calling request to a corresponding API interface according to the exposed interface address; The script execution unit is used to obtain the response groovy script and store it in the local temporary file of the server. At the same time, the groovy script is loaded through the Lite Flow visual component to instantiate the FlowExecutor and execute the workflow of the groovy script. After the workflow is executed, the local temporary file is deleted.

[0054] Specifically, after the interface is successfully added, the user can call the interface according to the filled-in address. When calling the interface, first query the basic configuration of the interface such as the file content of the interface orchestration according to the interface address. When querying the interface information, first query from the cache, and if there is no cache, load from the database. After obtaining the interface orchestration configuration file, use liteflow to execute the orchestration file. When executing the orchestration file, you need to first store the orchestration script in a local temporary file on the server. The file is named interfaceid_flow_yearmonthday_uuidrandomnumber.json format. Such as 123456789_flow_20240521_18573663199494.json, and then lite flow loads the script file and executes the script workflow, and deletes the local temporary file after execution.

[0055] Reference Figure 6As shown, the process of loading a script file through an API call in an embodiment of the present invention is: (1) Obtain the API interface orchestration script; (2) Store the script in a local temporary file on the server; (3) Use lite flowConfig to load the orchestration script file and set basic parameters; (4) Instantiate FlowExecutor; (5) FlowExecutor executes the script; (6) After the script is executed, delete the local temporary files.

[0056] The present invention provides an API orchestration gateway based on multiple scripts, which aims to solve the limitations of traditional API gateways and break through upstream and downstream data barriers. It provides multi-API orchestration, AI assistance, and draggable workflow interface operations, while realizing hot backup of the orchestration process to GitHub. It realizes the backup and loading of the process. The present invention realizes the dynamic processing of API requests and responses, and enhances the flexibility and scalability of the system. The gateway supports instant applications of static configuration, which simplifies the system management and maintenance process. Through the present invention, users can efficiently manage and process complex API requests and improve the ability and efficiency of data processing.

[0057] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. An API orchestration gateway based on multiple scripting languages, characterized in that: include: The API orchestration module is used to configure multiple API orchestration components, orchestrate the groovy scripts of multiple API interfaces through the API orchestration components, and aggregate the groovy scripts of multiple API interfaces and store them in the database according to a preset data format; The request cache loading module is used to preload the groovy script corresponding to the API interface from the database to the Redis cache, and when an API call request is received, the corresponding groovy script is called from the Redis cache to respond to the API call request; The API call module is used to initiate an API call request based on the interface address of the API interface, store the response groovy script in a local temporary file of the server, and load and execute the groovy script through the Lite Flow visualization component.

2. The API orchestration gateway based on multiple scripting languages ​​according to claim 1, characterized in that: The API orchestration module includes: A component configuration unit is used to configure an orchestration engine that can dynamically load and update scripts, and import API orchestration components in a visual workflow interface; the scripts include groovy scripts, javascript scripts, Python scripts, lua scripts, java scripts, and Aviator scripts; the API orchestration components include lite flow components and custom components, and the custom components include ip gateway blacklists and whitelists and groovy script components; The script writing unit is used to obtain the groovy scripts of multiple API interfaces custom-written by the user through the API orchestration component, and aggregate the groovy scripts of multiple API interfaces into an API workflow; A data format conversion unit, used to convert the API workflow into a workflow file in a preset data format and store it in a database; The interface registration unit is used to use the interface address input by the user as the key, and dynamically register the interface with the API workflow of the API interface as the execution logic, register the API interface in the request mapping processor of the spring MVC framework, and bind it to the execute function; the interface address is used to expose the API interface externally.

3. The API orchestration gateway based on multiple scripting languages ​​according to claim 2, characterized in that: The script writing unit is also used to obtain the script requirement description input by the user, and call the big model to write the groovy script corresponding to the script requirement description, and call the big model to verify and correct the groovy script customized by the user.

4. The API orchestration gateway based on multiple scripting languages ​​according to claim 2, characterized in that: The API orchestration module also includes a script hot backup unit, which is used to hot backup the groovy scripts submitted and modified by users to GitHub.

5. The API orchestration gateway based on multiple scripting languages ​​according to claim 1, characterized in that: The request cache loading module includes: The script preloading unit is used to preload the groovy script corresponding to the API interface from the database to the Redis cache when the interface service is started; The request response unit is used to determine whether there is a groovy script corresponding to the API interface in the Redis cache when receiving an API call request. If so, the corresponding groovy script is called from the Redis cache to respond to the API call request. If not, the corresponding groovy script is queried from the database and loaded into the Redis cache to respond to the API call request. The cache clearing unit is used to clear the corresponding loaded groovy script in the Redis cache when the orchestration process of the API interface is modified.

6. The API orchestration gateway based on multiple scripting languages ​​according to claim 1, characterized in that: The API calling module includes: An interface calling unit, used to initiate an API calling request to a corresponding API interface according to the exposed interface address; The script execution unit is used to obtain the response groovy script and store it in the local temporary file of the server. At the same time, the groovy script is loaded through the Lite Flow visual component to instantiate the FlowExecutor and execute the workflow of the groovy script. After the workflow is executed, the local temporary file is deleted.