A method and device for managing API gateway request paths
By hierarchically displaying and tree structure selection of API gateway request paths, the problem of error-prone API gateway manually configuring external API request paths is solved, and the efficiency of API management and operation and maintenance is improved.
Patent Information
- Application Number
- CN202211347306.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-31
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2042-10-31
AI Technical Summary
When configuring the external API request path, existing API gateways need to be filled in manually, which is prone to errors and inefficient.
By hierarchically displaying the request path, the API gateway can obtain the full picture of the business, and users can select the request path through a tree structure to avoid manual filling.
It improves the efficiency of API management, improves operation and maintenance efficiency, and solves the problem of manually configuring external API request paths that are prone to errors.
Smart Images

Figure CN115695285B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention generally relate to the field of network communication technology, and more particularly to a method and device for managing an API gateway request path. Background Art
[0002] API (Application Programming Interface) is the development interface of an application. If any application system needs to be called by other systems, it needs to expose API. API is highly favored by enterprises around the world, and API is experiencing explosive growth.
[0003] The API gateway is a unified entry point for service access, and all API requests will go through the API gateway. When using the API gateway, users can add internal APIs to the API gateway manually or by importing files; the added internal APIs are used as internal interfaces of the service to be called by the API gateway; users need to continue to configure external API interfaces on the API gateway.
[0004] For example, the patent: "A method and system for detecting abnormal API interface call paths (application number: CN202210015417.X)" includes step 1, continuously extracting API call relationships from a large number of normal users' access paths, and continuously expanding the call relationship set; step 2, using anomaly detection methods to find abnormal call paths. This method can detect the call path, but when obtaining the access path, it relies on the access path of normal users, that is, manual input. Therefore, this invention fails to solve the problem of not needing to rely on manual filling of the path. Summary of the invention
[0005] To solve the above problems, the present invention displays the request path in a hierarchical manner, so that the API gateway can obtain the overall picture of the business and improve the efficiency of API management; when the user configures the external API request path, there is no need to manually fill in the request path, but only needs to select the request path through the tree structure, which improves the operation and maintenance efficiency; and solves the problem that the API gateway manually configures the external API request path, which is prone to errors.
[0006] According to an embodiment of the present invention, a method and device for managing an API gateway request path are provided.
[0007] In a first aspect of the present invention, a method for managing an API gateway request path is provided. The method comprises:
[0008] S01: Batch import all API interfaces of the upstream server on the API gateway, and save the imported internal API to the database in the API gateway;
[0009] S02: extracting the request paths of all internal APIs and creating a request path root directory table, that is, the API gateway extracts the request paths of the internal APIs and creates a request path root directory table, wherein the root directory table stores the request paths of the root directories;
[0010] S03: dynamically creating a request path sub-directory table according to the directory level of the acquired request path, that is, dynamically creating a request path sub-directory table, and storing the request path information in the request path sub-directory table;
[0011] S04: Display the request path in the database in a hierarchical manner. The specific steps are as follows:
[0012] S041: extract the request path of the root directory table;
[0013] S042: extracting request paths in subordinate directories in sequence;
[0014] S043: Display the request path as a tree structure;
[0015] S05: The user configures the request path of the external API on the API gateway, and the request path is selected according to the level of the request path.
[0016] Furthermore, the S01 imports the internal API defined by the openAPI or swagger specification into the API gateway.
[0017] Furthermore, the request path information is stored in the request path sub-directory table in S03, and the path information includes: a primary key, a request path, an upper-level request path, a corresponding API, and whether a lower-level request path is included.
[0018] Furthermore, if the external API described in S05 corresponds to an internal API, the request path of the external API can be consistent with the internal API. If an external API corresponds to multiple internal APIs of the same business, the request path of the external API uses the parent request path of the internal API.
[0019] In a second aspect of the present invention, a device for managing an API gateway request path is provided. The device comprises:
[0020] Import module: used to batch import all API interfaces of the upstream server on the API gateway, and save the imported internal API to the database in the API gateway;
[0021] Extraction module: used to extract the request paths of all internal APIs and create a request path root directory table, that is, the API gateway extracts the request paths of the internal APIs and creates a request path root directory table, which stores the request paths of the root directories;
[0022] Creation module: used to dynamically create a request path sub-directory table according to the directory level and hierarchy of the obtained request path, that is, dynamically create a request path sub-directory table and store the request path information in the request path sub-directory table;
[0023] Hierarchical display module: used to hierarchically display the request path in the database, and the hierarchical display module also includes:
[0024] The first extraction module: used to extract the request path of the root directory table;
[0025] The second extraction module is used to extract the request path in the subordinate directory in sequence;
[0026] Tree structure display: used to display the above request path as a tree structure;
[0027] Configuration module: used for users to configure the request path of the external API on the API gateway. The request path is selected according to the level of the request path.
[0028] Furthermore, the import module imports the internal API defined by the openAPI or swagger specification into the API gateway.
[0029] Furthermore, the creation module stores the request path information in the request path sub-directory table, and the path information includes: primary key, request path, upper request path, primary key, request path, upper request path, corresponding API and whether it contains lower request path.
[0030] Furthermore, if the external API described in the configuration module corresponds to an internal API, the request path of the external API can be consistent with the internal API. If an external API corresponds to multiple internal APIs of the same business, the request path of the external API uses the parent request path of the internal API.
[0031] The meanings of the above mentioned English abbreviations:
[0032] API: Application Programming Interface, application development interface
[0033] openAPI: Open API
[0034] Swagger: A specification and complete framework for generating, describing, calling, and visualizing RESTful-style Web services
[0035] By displaying the request path in a hierarchical manner, the API gateway can obtain a full picture of the business, thereby improving the efficiency of API management; when configuring the external API request path, the user does not need to manually fill in the request path, but only needs to select the request path through a tree structure, thereby improving operation and maintenance efficiency; and solves the problem that the API gateway manually configures the external API request path, which is prone to errors.
[0036] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above and other features, advantages and aspects of the embodiments of the present invention will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings.
[0038] Figure 1 A flow chart of a method for managing an API gateway request path according to an embodiment of the present invention is shown;
[0039] Figure 2 A block diagram of a management device for an API gateway request path according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] According to the implementation mode of the present invention, a method and device for managing API gateway request paths are proposed. By displaying the request paths in a hierarchical manner, the API gateway can obtain a comprehensive picture of the business, thereby improving the efficiency of API management. When configuring an external API request path, the user does not need to manually fill in the request path, but only needs to select the request path through a tree structure, thereby improving operation and maintenance efficiency. The problem of manual configuration of the external API request path by the API gateway, which is prone to errors, is solved.
[0042] The principle and spirit of the present invention are explained in detail below with reference to several representative embodiments of the present invention.
[0043] Figure 1 This is a flow chart of a method for managing an API gateway request path according to an embodiment of the present invention. The method includes:
[0044] S01: Batch import all API interfaces of the upstream server on the API gateway, and save the imported internal API to the database in the API gateway;
[0045] S02: Extract the request paths of all internal APIs and create a request path root directory table;
[0046] S03: According to the directory level of the request path, a hierarchical dynamic creation of a request path sub-directory table;
[0047] S04: Display the request path in the database in a hierarchical manner;
[0048] S05: The user configures the request path of the external API on the API gateway, and the request path is selected according to the level of the request path.
[0049] It should be noted that, although the operations of the method of the present invention are described in a specific order in the above embodiments and the accompanying drawings, this does not require or imply that the operations must be performed in the specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0050] In order to explain the above-mentioned API gateway request path management method more clearly, a specific embodiment is described below. However, it is worth noting that this embodiment is only for better illustrating the present invention and does not constitute an improper limitation on the present invention.
[0051] The following is a specific example to further explain the management method of API gateway request path in more detail:
[0052] Assume that the user needs to use API gateway to manage APIs. The request paths corresponding to the user APIs are: / a / c, / a / d / insert, / a / d / delete, / a / d / update, / a / d / get, / b / e and / b / f.
[0053] First, import the user's API into the API gateway and store them in the database respectively.
[0054] Then the API gateway extracts the request path corresponding to the API and creates a request path root directory table to store the request path of the root directory: / ;
[0055] Then dynamically create a sub-directory table and store the request path information in the sub-directory table: the request paths stored in the first-level directory table are: / a and / b, the request paths stored in the second-level directory table are: / d, / e and / f, and the request paths stored in the third-level directory table are: / insert, / delete, / update and / get.
[0056] If the request path does not have a corresponding API, the corresponding API field in the request path information is empty; for example, if / a does not have a corresponding API, the corresponding API field in the / a data is empty. Extract the request path from the database and display it hierarchically. The effect is as follows:
[0057] /
[0058] --- / a
[0059] ------ / c
[0060] ------ / d
[0061] --------- / insert
[0062] --------- / delete
[0063] --------- / update
[0064] --------- / get
[0065] --- / b
[0066] ------ / e
[0067] ------ / f
[0068] Users configure external APIs on the API gateway. One external API can correspond to one or more internal APIs: configure an external API with a request path of / a / d, which corresponds to four internal APIs: / a / d / insert, / a / d / delete, / a / d / update, and / a / d / get; / a / d is used as a prefix to match the request path, which will match all request paths starting with / a / d.
[0069] Based on the same inventive concept, the present invention also proposes a management device for API gateway request paths. The implementation of the device can refer to the implementation of the above method, and the repeated parts will not be repeated. Figure 2 As shown, the device 100 includes:
[0070] Import module 101: used to batch import all API interfaces of the upstream server on the API gateway, and save the imported internal APIs to the database in the API gateway;
[0071] Extraction module 102: used to extract the request paths of all internal APIs and create a request path root directory table;
[0072] Creation module 103: used to dynamically create a request path sub-directory table according to the directory level of the acquired request path;
[0073] Hierarchical display module 104: used to display the request path in the database in a hierarchical manner;
[0074] Configuration module 105: used for the user to configure the request path of the external API on the API gateway, and the request path is selected according to the level of the request path.
[0075] The hierarchical display module 104 further includes:
[0076] The first extraction module 1041 is used to extract the request path of the root directory table;
[0077] The second extraction module 1042 is used to extract the request path in the lower directory in sequence;
[0078] Tree structure display 1043: used to display the above request path as a tree structure.
[0079] The present invention proposes a management device for API gateway request paths. By displaying the request paths in a hierarchical manner, the API gateway can obtain a comprehensive picture of the business, thereby improving the efficiency of API management. When configuring an external API request path, the user does not need to manually fill in the request path, but only needs to select the request path through a tree structure, thereby improving operation and maintenance efficiency. The invention solves the problem that the API gateway manually configures the external API request path, which is prone to errors.
[0080] Although the spirit and principle of the present invention have been described with reference to several specific embodiments, it should be understood that the present invention is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present invention is intended to cover various modifications and equivalent arrangements contained in the spirit and scope of the attached claims.
[0081] Regarding the limitation of the protection scope of the present invention, those skilled in the art should understand that, based on the technical solution of the present invention, various modifications or variations that can be made by those skilled in the art without creative work are still within the protection scope of the present invention.
Claims
1. A method for managing an API gateway request path, characterized in that: The method includes: S01: Batch import all openAPIs of the upstream server and APIs defined by the swagger specification on the API gateway, and save the imported APIs as internal APIs to the database in the API gateway; S02: extracting the request paths of all internal APIs and creating a request path root directory table, wherein the root directory table stores the request paths of the root directories; S03: dynamically creating a request path sub-directory table according to the directory level of the acquired request path, and storing the request path information in the request path sub-directory table; S04: Display the request path in the database in a hierarchical manner. The specific steps are as follows: S041: extract the request path of the root directory table; S042: extracting request paths in subordinate directories in sequence; S043: Display the request path as a tree structure; S05: The user configures the request path of the external API on the API gateway. The request path is selected according to the hierarchy of the request path. If the external API corresponds to an internal API, the request path of the external API is consistent with the internal API. If an external API corresponds to multiple internal APIs of the same business, the request path of the external API uses the parent request path of the internal API.
2. According to the method for managing an API gateway request path according to claim 1, it is characterized in that: The request path information described in S03 is stored in the request path sub-directory table, and the path information includes: primary key, request path, upper request path, corresponding API and whether it contains lower request path.
3. A management device for an API gateway request path, characterized in that: The device includes: Import module: used to batch import all openAPIs of the upstream server and APIs defined by the swagger specification on the API gateway, and save the imported APIs as internal APIs to the database in the API gateway; Extraction module: used to extract the request paths of all internal APIs and create a request path root directory table, which stores the request paths of the root directories; Creation module: according to the directory level of the acquired request path, dynamically create a request path sub-directory table, and store the request path information in the request path sub-directory table; Hierarchical display module: used to hierarchically display the request path in the database, and the hierarchical display module also includes: The first extraction module: used to extract the request path of the root directory table; The second extraction module is used to extract the request path in the subordinate directory in sequence; Tree structure display module: used to display the above request path as a tree structure; Configuration module: used for users to configure the request path of the external API on the API gateway. The request path is selected according to the hierarchy of the request path. If the external API corresponds to an internal API, the request path of the external API is consistent with the internal API. If an external API corresponds to multiple internal APIs of the same business, the request path of the external API uses the parent request path of the internal API.
4. The management device for API gateway request path according to claim 3, characterized in that: The creation module stores the request path information in the request path sub-directory table, wherein the path information includes: primary key, request path, upper-level request path, corresponding API, and whether the lower-level request path is included.
Citation Information
Patent Citations
Method and system for detecting abnormity of API (Application Program Interface) calling path
CN114371955A
Metadata-based OpenAPI implementing method and OpenAPI implementing device
CN106445562A
API (Application Programming Interface) gateway interface configuration updating method and device
CN108965007A