Visual API (Application Program Interface) construction method and system, terminal and medium

Through the visual API interface construction method, the configuration information is read and preprocessed, and the API code is analyzed and generated, which solves the problems of low efficiency, many errors and major security risks in the existing technology, and realizes an efficient, secure and simplified API interface development process.

CN119847483APending Publication Date: 2025-04-18SHENZHEN KONKA ELECTRONIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411928180.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

When developing API interfaces, the development efficiency of the existing technology is low, which is prone to programming errors, security risks, and communication costs and understanding deviations between front and back developers.

Method used

Provides a method for building a visual API interface. By reading configuration information and preprocessing, analyzing the API interface request, generating API code based on the request, and deploying it to realize the construction of the visual API interface.

Benefits of technology

It simplifies the development process of API interfaces, reduces the need to write duplicate boilerplate code, automatically generates standardized API code, avoids programming errors and security risks, reduces communication costs and understanding deviations between front and back developers, and improves API code generation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847483A_ABST
    Figure CN119847483A_ABST
Patent Text Reader

Abstract

The invention discloses a visual AP I interface construction method and system, a terminal and a medium, and the method comprises the steps: reading configuration information, and preprocessing the configuration information to obtain preprocessed configuration information, the configuration information being configured based on a front-end visual configuration interface; analyzing the preprocessed configuration information to obtain an AP I interface request; and generating an AP I code based on the AP I interface request, and deploying the AP I code to realize construction of a visual AP I interface. According to the method, the development process of the AP I interface is simplified, repeated template codes do not need to be written, the standardized AP I code can be automatically generated only by configuring related information through the visual configuration interface, common programming errors and potential safety hazards can be effectively avoided, and the generation efficiency of the AP I code is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of interface design, and in particular to a method, system, terminal and medium for constructing a visual API interface. Background Art

[0002] In modern web development, API interface development is a common and repetitive task. When developing some API interfaces, back-end developers usually need to manually write a lot of code to handle HTTP requests, which is inefficient and prone to programming errors, security risks, and communication costs and misunderstandings between front-end and back-end developers.

[0003] Therefore, the prior art still needs to be improved and enhanced. Summary of the invention

[0004] The technical problem to be solved by the present invention is that, in view of the above-mentioned defects of the prior art, a method, system, terminal and medium for constructing a visual API interface are provided, aiming to solve the problems of low development efficiency, easy programming errors, security risks, communication costs and understanding deviations between front-end and back-end developers in the prior art when developing API interfaces.

[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0006] In a first aspect, the present invention provides a method for constructing a visual API interface, wherein the method comprises:

[0007] Reading configuration information and preprocessing the configuration information to obtain preprocessed configuration information, wherein the configuration information is configured based on a visual configuration interface of a front end;

[0008] Parse the preprocessed configuration information to obtain the API interface request;

[0009] Generate API code based on the API interface request, and deploy the API code to achieve the construction of a visual API interface.

[0010] In one implementation, before reading the configuration information, the process includes:

[0011] A development request from a developer is received, and based on the development request, basic interface information, data model design information, and authority rule information are configured on the visual configuration interface of the front end to obtain the configuration information.

[0012] In one implementation, before reading the configuration information, the method further includes:

[0013] After the configuration information is obtained, the configuration information is stored in a preset database at the back end, and a data encryption mechanism and an access permission mechanism are set for the preset database.

[0014] In one implementation, preprocessing the configuration information to obtain preprocessed configuration information includes:

[0015] Performing input correctness verification processing on the configuration information to obtain configuration information with correct input;

[0016] The correctly input configuration information is processed with the default value completion to obtain the preprocessed configuration information.

[0017] In one implementation, parsing the preprocessed configuration information to obtain an API interface request includes:

[0018] Get the preset template parsing engine;

[0019] The preprocessed configuration information is parsed based on the template definition in the template parsing engine to obtain the API interface request.

[0020] In one implementation, the generating the API code based on the API interface request includes:

[0021] Get the preset code generator;

[0022] Based on the API interface request, the API code is generated by the code generator.

[0023] In one implementation, the method further includes:

[0024] When the API code is run, the running process of the API code is monitored and recorded to obtain log information.

[0025] In a second aspect, an embodiment of the present invention further provides a system for constructing a visual API interface, wherein the system includes:

[0026] A configuration information processing module, used to read the configuration information and preprocess the configuration information to obtain the preprocessed configuration information, wherein the configuration information is configured based on a visual configuration interface of the front end;

[0027] The configuration information parsing module is used to parse the preprocessed configuration information to obtain the API interface request;

[0028] The API code generation module is used to generate API code based on the API interface request and deploy the API code to realize the construction of a visual API interface.

[0029] In a third aspect, an embodiment of the present invention further provides a terminal, wherein the terminal includes a memory, a processor, and a visualization API interface construction program stored in the memory and executable on the processor, and when the processor executes the visualization API interface construction program, the steps of the visualization API interface construction method of any one of the above-mentioned schemes are implemented.

[0030] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein a construction program for a visualization API interface is stored on the computer-readable storage medium, and when the construction program for the visualization API interface is executed by a processor, the steps of the method for constructing a visualization API interface described in any one of the above-mentioned schemes are implemented.

[0031] Beneficial effects: Compared with the prior art, the present invention provides a method for constructing a visual API interface. The present invention first reads the configuration information and preprocesses the configuration information to obtain the preprocessed configuration information, wherein the configuration information is configured based on the visual configuration interface of the front end. Then, the preprocessed configuration information is parsed to obtain an API interface request. Finally, an API code is generated based on the API interface request, and the API code is deployed to realize the construction of a visual API interface. The present invention simplifies the development process of the API interface. There is no need to write repetitive boilerplate code. Only relevant information needs to be configured through the visual configuration interface to automatically generate standardized API code. This can effectively avoid common programming errors and safety hazards, reduce communication costs and understanding deviations between front-end and back-end developers, and improve the efficiency of API code generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A flowchart of a preferred embodiment of a method for constructing a visual API interface provided in an embodiment of the present invention.

[0033] Figure 2 A flowchart of a specific application of the method for constructing a visual API interface provided by an embodiment of the present invention.

[0034] Figure 3 A schematic diagram of setting field configuration information in a method for constructing a visual API interface provided in an embodiment of the present invention.

[0035] Figure 4 A schematic diagram of the architecture of a system for building a visual API interface provided by an embodiment of the present invention.

[0036] Figure 5 A functional block diagram of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and effect of the present invention clearer and more specific, the present invention is further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0038] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations or steps, nor must they be executed in the order described. For example, some operations or steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0039] It should be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0040] It should be understood that, in order to clearly describe the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, words such as "first" and "second" are used to distinguish between identical or similar items with substantially identical functions and effects. For example, the first control information and the second control information are only used to distinguish different control information, and their order is not limited.

[0041] Those skilled in the art can understand that the words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not necessarily limit the differences.

[0042] It should be further understood that the term “and / or” used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0043] In order to solve the problems of the prior art, the present embodiment provides a method for constructing a visual API interface, which can simplify the development process of the API interface. There is no need to write repetitive boilerplate code. Only relevant information needs to be configured through a visual configuration interface to automatically generate standardized API code. This can effectively avoid common programming errors and potential safety hazards, reduce the communication costs and understanding deviations between front-end and back-end developers, and improve the efficiency of API code generation. In specific applications, the present embodiment first reads the configuration information, and preprocesses the configuration information to obtain the preprocessed configuration information, wherein the configuration information is configured based on the visual configuration interface of the front end. Then, the preprocessed configuration information is parsed to obtain an API interface request. Finally, an API code is generated based on the API interface request, and the API code is deployed to realize the construction of a visual API interface.

[0044] The method for constructing a visual API interface of this embodiment can be applied to a terminal, which can be a computer, a smart TV, a mobile phone or other intelligent product terminal. Figure 1 As shown in , the method for constructing the visualization API interface includes the following steps:

[0045] Step S100: read configuration information, and preprocess the configuration information to obtain preprocessed configuration information, wherein the configuration information is configured based on a front-end visual configuration interface.

[0046] In this embodiment, the configuration information is information configured in advance by the developer based on the visual configuration interface of the front end, and the configuration information is used to build the API interface. When building the API interface, the terminal of this embodiment first reads the configuration information, and then preprocesses the read configuration information to obtain the preprocessed configuration information.

[0047] Specifically, combined Figure 2 As shown, the terminal of this embodiment first receives the development request of the developer, and configures the basic interface information, data model design information and permission rule information on the visual configuration interface based on the development request to obtain the configuration information. The visual configuration interface of this embodiment is set at the front end to facilitate the front-end developers to set the configuration information. In specific applications, the front-end framework of this embodiment adopts Vue3+ElementPlus, the back-end framework adopts NodeJS+Koa2, and the development language adopts JavaScript. Through the visual configuration interface of the front end of this embodiment, developers can configure various aspects of the API interface in a form. The configured basic interface information includes the interface name, request path, HTTP method, etc.; the configured data model design information includes field definitions, such as Figure 3As shown in , for example, some keyword fields are set; the configured permission rule information includes verification rules, etc., thereby obtaining configuration information. The configuration information of this embodiment can be as follows:

[0048]

[0049]

[0050] After obtaining the configuration information, this embodiment also stores the configuration information persistently in a preset database at the back end, such as a SQLite database. It can be seen that the configuration information set by the visual configuration interface of the front end in this embodiment can be used to build an API interface at the back end, which is convenient for front-end developers without back-end experience to develop simple interfaces by themselves, reducing the communication costs and misunderstandings between front-end and back-end personnel. In addition, the development language of the interface code of this embodiment adopts JavaScript. Since JavaScript is the most familiar programming language for front-end developers, using JavaScript to generate interface code enables front-end developers to directly understand and modify the interface logic, reducing the communication costs and misunderstandings between front-end and back-end developers.

[0051] In one implementation, this embodiment can set a data encryption mechanism and an access permission mechanism for the preset database. Specifically, the preset database of this embodiment may include multiple key tables: an api_configs table for storing basic interface configurations, which includes information such as interface identification, name, path, etc.; an api_fields table for storing field configurations, which includes field names, types, validation rules, etc.; and an api_permissions table for storing permission configurations, which includes information such as access permission rules and role definitions. Encryption and access restrictions on content in the database are implemented based on the above key tables. The specific implementation may include measures such as parameter verification, XSS protection, and CSRF protection, and supports multiple authentication methods such as Token authentication and Session management, which is conducive to the implementation of role-based fine-grained permission control.

[0052] Furthermore, after the developer configures the configuration information and stores the configuration information in the back-end preset database, the terminal can read the above configuration information from the preset database, and then build an API interface based on the read configuration information. This embodiment first needs to preprocess the read configuration information. Specifically, the configuration information is first input correctness verified to obtain the correctly input configuration information. Then, the correctly input configuration information is processed to complete the default value to obtain the preprocessed configuration information. The preprocessing of the configuration information in this embodiment can be as follows:

[0053]

[0054]

[0055] It should be noted that the preprocessing process of the configuration information in this embodiment not only includes the above-mentioned input correctness verification processing and default value completion processing, but may also include other preprocessing contents, which are not limited in this embodiment.

[0056] Step S200: parse the preprocessed configuration information to obtain an API interface request.

[0057] After preprocessing the configuration information, this embodiment can parse the preprocessed configuration information. Since the configuration information sets various aspects of the API interface, the API interface request can be obtained by parsing the preprocessed configuration information, and the API interface can be constructed based on the API interface request.

[0058] Specifically, combined Figure 2 As shown in , the EJS template engine is used to define the code generator in this embodiment. The EJS template engine may include variable definitions, conditional rendering logic, and loop structures to meet different code generation requirements. Based on this, the present embodiment may obtain a preset template parsing engine, and the preprocessed configuration information is passed to the template parsing engine, and the template parsing engine parses the preprocessed configuration information according to the template definition to obtain the API interface request.

[0059] Step S300: Generate API code based on the API interface request, and deploy the API code to achieve construction of a visual API interface.

[0060] After obtaining the API interface request, the present embodiment can use the code generator defined in the template engine to automatically generate API code. Specifically, the present embodiment can obtain a preset code generator. Then, through the execution logic in the code generator, such as conditional judgment and loop, the API code is automatically generated based on the API interface request. The generated API code can be deployed to the API service, thereby realizing the construction of the visual API interface in the present embodiment. The present embodiment adopts a templated code generation scheme, and the automatically generated API code has a high degree of consistency and standardized characteristics. This unified code style and structure greatly improves the maintainability of the API code. The preset code generator has been fully tested and optimized, and can effectively avoid common programming errors and safety hazards. Further, after the API code is released and run, the local interface address can be accessed through the access tool to obtain data. The present embodiment can monitor and record the running process of the API code to obtain log information, so that the operation and maintenance personnel can grasp the system operation status in real time, quickly locate and solve problems. The present embodiment simplifies the deployment and upgrade of the system through the automated deployment process and version management function, and reduces the workload of operation and maintenance.

[0061] In addition, the API code generated by this embodiment can be written to the disk through the file system of Node.js. The generated API code can be directly integrated into the front-end project without the need for additional language conversion or adaptation layers. Front-end developers can easily reuse and expand existing JavaScript tool libraries and components. This embodiment can also organize the API code into a modular structure to ensure the maintainability and extensibility of the API code. Furthermore, this embodiment allows developers to customize the code generator as needed. The customized code generator can define new template variables, modify conditional rendering logic, or add new API code generation logic. In addition, the generated API code adopts a modular organizational structure, such as using ES6 module syntax, which helps to improve the maintainability and extensibility of the API code. The functional expansion of the API code in this embodiment can be shown as follows:

[0062]

[0063]

[0064] This embodiment adopts a flexible extension mechanism. Through the middleware extension mechanism, functions such as request preprocessing, response postprocessing, and error handling can be implemented. Business logic extension points allow developers to add custom data processing logic, validation rules, etc. This flexible extension mechanism ensures that the system can adapt to various complex business needs.

[0065] In summary, this embodiment first reads the configuration information, and preprocesses the configuration information to obtain the preprocessed configuration information, wherein the configuration information is configured based on the visual configuration interface of the front end. Then, the preprocessed configuration information is parsed to obtain an API interface request. Finally, an API code is generated based on the API interface request, and the API code is deployed to realize the construction of a visual API interface. The present invention simplifies the development process of the API interface, and there is no need to write repetitive boilerplate code. It only needs to configure the relevant information through the visual configuration interface to automatically generate standardized API code, which can effectively avoid common programming errors and safety hazards, reduce the communication costs and understanding deviations between front-end and back-end developers, and improve the efficiency of API code generation.

[0066] Based on the above embodiments, the present invention also provides a system for constructing a visual API interface, such as Figure 4 As shown, the system includes: a configuration information processing module 10, a configuration information parsing module 20 and an API code generation module 30. Specifically, the configuration information processing module 10 is used to read the configuration information and preprocess the configuration information to obtain the preprocessed configuration information, wherein the configuration information is configured based on the visual configuration interface of the front end. The configuration information parsing module 20 is used to parse the preprocessed configuration information to obtain an API interface request. The API code generation module 30 is used to generate an API code based on the API interface request and deploy the API code to realize the construction of a visual API interface.

[0067] In one implementation, the system further includes:

[0068] The information front-end configuration module is used to receive development requests from developers, and configure basic interface information, data model design information and authority rule information on the visual configuration interface of the front end based on the development request to obtain the configuration information.

[0069] In one implementation, the system further includes:

[0070] The configuration information storage module is used to store the configuration information in a preset database at the back end after obtaining the configuration information, and to set a data encryption mechanism and an access permission mechanism for the preset database.

[0071] In one implementation, the configuration information processing module 10 includes:

[0072] A correctness verification unit, used to perform input correctness verification processing on the configuration information to obtain configuration information with correct input;

[0073] The default value completion unit is used to perform default value completion processing on the correctly input configuration information to obtain the pre-processed configuration information.

[0074] In one implementation, the configuration information parsing module 20 includes:

[0075] A template acquisition unit, used to acquire a preset template parsing engine;

[0076] The information parsing unit is used to parse the preprocessed configuration information based on the template definition in the template parsing engine to obtain the API interface request.

[0077] In one implementation, the API code generation module 30 includes:

[0078] A code generator acquisition unit, used to acquire a preset code generator;

[0079] The API code generating unit is used to generate the API code through the code generator based on the API interface request.

[0080] In one implementation, the system further includes:

[0081] The monitoring and recording unit is used to monitor and record the running process of the API code when the API code is running, so as to obtain log information.

[0082] The working principles of each module in the construction system of the visual API interface of this embodiment are the same as the principles of each step in the above method embodiment, and will not be repeated here.

[0083] Each module in the construction system of the above-mentioned visualization API interface can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the terminal in the form of hardware, or can be stored in the memory in the terminal in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0084] Based on the above embodiment, the present invention further provides a terminal, the principle block diagram of the terminal can be as follows: Figure 5 The terminal may include one or more processors 100 ( Figure 5 Only one is shown), a memory 101 and a computer program 102 stored in the memory 101 and executable on one or more processors 100.

[0085] In one embodiment, the processor 100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0086] In one embodiment, the memory 101 may be an internal storage unit of an electronic device, such as a hard disk or memory of the electronic device. The memory 101 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 101 may also include both an internal storage unit of the electronic device and an external storage device. The memory 101 is used to store computer programs and other programs and data required by the terminal. The memory 101 may also be used to temporarily store data that has been output or is to be output.

[0087] Those skilled in the art will understand that Figure 5 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal to which the scheme of the present invention is applied. The specific terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0088] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, operating database or other media used in the embodiments provided by the present invention may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double operational data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0089] 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 make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for constructing a visual API interface, characterized in that: The method comprises: Reading configuration information and preprocessing the configuration information to obtain preprocessed configuration information, wherein the configuration information is configured based on a visual configuration interface of a front end; Parse the preprocessed configuration information to obtain the API interface request; Generate API code based on the API interface request, and deploy the API code to achieve the construction of a visual API interface.

2. The method for constructing a visual API interface according to claim 1, characterized in that: Before reading the configuration information, the following steps are included: A development request from a developer is received, and based on the development request, basic interface information, data model design information, and authority rule information are configured on the visual configuration interface of the front end to obtain the configuration information.

3. The method for constructing a visual API interface according to claim 2, characterized in that: Before reading the configuration information, the method further includes: After the configuration information is obtained, the configuration information is stored in a preset database at the back end, and a data encryption mechanism and an access permission mechanism are set for the preset database.

4. The method for constructing a visual API interface according to claim 1, characterized in that: The preprocessing of the configuration information to obtain the preprocessed configuration information includes: Performing input correctness verification processing on the configuration information to obtain configuration information with correct input; The correctly input configuration information is processed with the default value completion to obtain the preprocessed configuration information.

5. The method for constructing a visual API interface according to claim 1, characterized in that: The preprocessed configuration information is parsed to obtain an API interface request, including: Get the preset template parsing engine; The preprocessed configuration information is parsed based on the template definition in the template parsing engine to obtain the API interface request.

6. The method for constructing a visual API interface according to claim 1, characterized in that: The generating the API code based on the API interface request includes: Get the preset code generator; Based on the API interface request, the API code is generated by the code generator.

7. The method for constructing a visual API interface according to claim 1, characterized in that: The method further comprises: When the API code is run, the running process of the API code is monitored and recorded to obtain log information.

8. A visual API interface construction system, characterized in that: The system comprises: A configuration information processing module, used to read the configuration information and preprocess the configuration information to obtain the preprocessed configuration information, wherein the configuration information is configured based on a visual configuration interface of the front end; The configuration information parsing module is used to parse the preprocessed configuration information to obtain the API interface request; The API code generation module is used to generate API code based on the API interface request and deploy the API code to realize the construction of a visual API interface.

9. A terminal, characterized in that: The terminal includes a memory, a processor, and a visualization API interface construction program stored in the memory and executable on the processor. When the processor executes the visualization API interface construction program, the steps of the visualization API interface construction method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a visualization API interface construction program, and when the visualization API interface construction program is executed by a processor, the steps of the visualization API interface construction method according to any one of claims 1 to 7 are implemented.