Method and device for calling application programming interface, equipment, medium and program product
By generating target models and using a visual interface, the problem of developers needing to master API code logic is solved, enabling a low-barrier and efficient API call process.
Patent Information
- Application Number
- CN202510947490.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-10-28
AI Technical Summary
In existing technologies, developers need to master the API's code logic and request methods when calling APIs, resulting in high technical barriers and low processing efficiency.
By analyzing the user's natural language description and API code through target model analysis, a call request that matches the user's input is generated. A visual interface and multiple interactive components are provided, allowing users to easily generate, adjust, and send call requests.
It lowers the technical barrier for users to understand API code logic, improves the processing efficiency and user experience of calling APIs, and enables one-click generation and visual display of call requests.
Smart Images

Figure CN120848988A_ABST
Abstract
Description
Technical Field
[0001] This disclosure generally relates to the field of computers, and more specifically to methods, apparatus, devices, computer-readable storage media, and computer program products for invoking application programming interfaces. Background Technology
[0002] Application Programming Interfaces (APIs) are commonly used tools in the work of developers. They define a set of rules and protocols that enable one application to call the functions or data of another application without knowing the internal implementation details. Their role and impact are present in every stage of the software development lifecycle, profoundly changing development patterns and efficiency.
[0003] APIs achieve system decoupling (callers don't need to worry about the internal logic of the server) and promote ecosystem collaboration (different systems can interconnect through APIs). For example, calling a map API can quickly implement location functionality, which directly reduces the amount of code and development cycle, allowing teams to focus on core business innovation. APIs lower the barrier to entry for highly complex technologies. Small and medium-sized teams do not need to master the underlying algorithms; they can access cutting-edge technological capabilities by calling the APIs of AI open platforms (such as speech recognition and image generation). Summary of the Invention
[0004] According to exemplary embodiments of this disclosure, a method, apparatus, device, computer storage medium, and computer program product for invoking an API are provided.
[0005] In a first aspect of this disclosure, a method for invoking an API is provided, the method comprising obtaining user input for a call request to the API. The method further comprises displaying the call request in an interface, the call request being generated by a target model based on the user input and the API's code. The method further comprises sending the call request to the API in response to receiving user confirmation.
[0006] In a second aspect of this disclosure, an apparatus for invoking an API is provided. The apparatus includes an acquisition module configured to acquire user input for an API invocation request. The apparatus also includes a display module configured to display the invocation request in an interface, the invocation request being generated by a target model based on the user input and the API code. The apparatus further includes a sending module configured to send the invocation request to the API in response to receiving user confirmation.
[0007] In a third aspect of this disclosure, an electronic device is provided, comprising: at least one processing unit; and at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions causing the electronic device to perform the method described in the first aspect of this disclosure when executed by the at least one processing unit.
[0008] In a fourth aspect of this disclosure, a computer-readable storage medium is provided having machine-executable instructions stored thereon, which, when executed by a device, cause the device to perform the method described in the first aspect of this disclosure.
[0009] In a fifth aspect of this disclosure, a computer program product is provided, including computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the method described in the first aspect of this disclosure.
[0010] The summary section is provided to introduce a series of concepts in a simplified form, which will be further described in the detailed description below. The summary section is not intended to identify key or essential features of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0011] Figure 1 A schematic diagram of an example environment in which embodiments of the present disclosure can be implemented is shown;
[0012] Figure 2 A flowchart illustrating a method for invoking an application programming interface according to an embodiment of the present disclosure is shown;
[0013] Figure 3 A schematic diagram illustrating the generation of a call request according to a disclosed embodiment is shown;
[0014] Figures 4A-4B A schematic diagram of an interactive component according to an embodiment of the present disclosure is shown;
[0015] Figure 5A A schematic diagram of stored log data according to an embodiment of the present disclosure is shown;
[0016] Figure 5B A schematic diagram of response information according to an embodiment of the present disclosure is shown;
[0017] Figure 5C A schematic diagram illustrating the generation of repair suggestions according to embodiments of the present disclosure is shown;
[0018] Figure 6 An architecture diagram of a system for invoking an API according to an embodiment of the present disclosure is shown;
[0019] Figure 7 A schematic block diagram of an example apparatus according to some embodiments of the present disclosure is shown;
[0020] Figure 8 A block diagram of an example device that can be used to implement embodiments of the present disclosure is shown.
[0021] In all the accompanying figures, the same or similar reference numerals denote the same or similar elements. Detailed Implementation
[0022] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of these messages or information. It is understood that before using the technical solutions disclosed in the embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0023] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message. As an optional but non-limiting implementation, the prompt message can be sent to the user in the form of a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0024] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0025] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0026] In the description of embodiments of this disclosure, the term "comprising" and similar terms should be understood as open-ended inclusion, i.e., "including but not limited to". The term "based on" should be understood as "at least partially based on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc., may refer to different or the same objects unless explicitly stated. Other explicit and implicit definitions may also be included below.
[0027] In related technologies, developers need to test APIs after development, which requires creating numerous calls and sending them to the API to view its responses. Effective testing necessitates developers having a thorough understanding of the API's code logic, permitted request methods, required parameters, and so on. This presents a high technical barrier for users and requires them to be familiar with the comprehensive business logic and scenarios associated with the API, resulting in relatively low processing efficiency.
[0028] To address this issue, this disclosure proposes a method for invoking an API. This method utilizes a target model to analyze the user's natural language description and the API's code, generating an API call request that matches the user's input. It also provides an interface to visualize the specific content of the call request and to execute the call operation using that request. This method can generate a call request specifically for that API, visualize the call request, and send the request with a single click. This offers high processing efficiency, lowers the technical barrier for users, and improves the user experience, without requiring users to understand the API's code logic.
[0029] The embodiments of this disclosure will now be described in further detail with reference to the accompanying drawings, wherein... Figure 1 A schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented is shown. Example environment 100 includes an application 110 on a user device and a server 120. Server 120 may be deployed with models 124 (e.g., multimodal models), which are trained models capable of generating content in response to user requests. In some embodiments, the user device and server 120 communicate via a network. The network may include a wired network, a wireless network, or a combination thereof for providing communication between the user device and server 120. In some embodiments, the user device may be connected to server 120 via a data cable; the present disclosure does not limit the connection method between the user device and server 120. In this embodiment, the methods of embodiments of the present disclosure are performed by application 110.
[0030] like Figure 1As shown, the application 110 can be, for example, an application provided in a browser, which can provide a visual interface to support full-process visual operation. In some embodiments, the application 110 can provide an interface 112, which provides multiple components for generating and adjusting call requests. In this embodiment, the interface 112 includes a component 114 for generating call requests, a first interaction component 118, a second interaction component 140, a third interaction component 142, and a sending component 116. The component 114 for generating call requests is the starting point for user-initiated operations; the first interaction component 118 is used to adjust the request method; the second interaction component 140 is used to adjust the request header; the third interaction component 142 is used to handle request body-related operations; and the sending component 116, as the final execution stage, is responsible for sending the call request to the target API. These components, through carefully designed interaction logic and a user-friendly interface layout, enable users to easily complete complex API call request generation and adjustment tasks.
[0031] If the user clicks component 114 to generate a request, application 110 can provide card 130, which includes input field 132 and confirmation component 134. For the API corresponding to API code 122, the user can enter the type of request they want to generate in input field 132. Through confirmation component 134, the user can communicate with model 124 deployed on server 120. For ease of description, assume the API to be called is one that exposes a suggestion database, and the user wants to upload a suggestion by calling this API. In some embodiments, the user can enter "Upload a new suggestion" in the input field and click confirmation component 134.
[0032] After receiving the user input, application 110 transmits it to server 120. Upon receiving the request, server 120's internally deployed model 124 initiates its workflow. Based on its own algorithms and training results, it performs intent recognition on the user input and generates a code file for a call request that conforms to the user's intent, according to the user's intent and the logic of API code 122. This code file records the complete content of the call request, covering information such as request parameters, request body, request headers, and request method required to realize the user's intent. In some embodiments, the call request is displayed in the interactive components of the interface. The call request is generated by model 124 based on the user input and API code. The various elements of the generated call request can be displayed separately through various interactive components for easy user understanding and perception.
[0033] In some embodiments, if an adjustment operation is received based on an interactive component, the call request is modified according to the adjustment operation. When an interactive component (i.e., any one of the first interactive component 118, the second interactive component 140, and the third interactive component 142) receives an adjustment operation from the user, the application 110 executes the corresponding adjustment operation. Taking the first interactive component 118 as an example, in some embodiments, its dropdown list can display request methods (such as POST, GET, PUT, DELETE, etc.). In some embodiments, its dropdown list can also receive information from model 124, which indicates the request methods permitted by the API, to generate a call request that conforms to the API requirements, and provides a brief description of each request method to help the user make the correct choice. When the user clicks on the second interactive component 140 to modify the request header, the format and content of the request header can be detected, and non-compliant parts can be highlighted and modification suggestions can be provided. When the third interactive component 142 displays the request body content 144 (such as JSON code data), it performs highlighting on key code to facilitate the user to quickly locate and modify the data.
[0034] In some embodiments, if a user clicks the send component 116 to send a call request to the API, after the user has completed generating or adjusting the call request, clicking the send component 116 allows the application 110 to perform a final check and encapsulation of the call request. During the check, the application 110 can re-verify the integrity and validity of the request parameters, ensuring the correct format of the request header and request body. If the call request has not been adjusted, the application 110 can directly encapsulate the original generated call request according to the Hypertext Transfer Protocol specification and send it to the target API via a network connection according to the Uniform Resource Locator (URL) recorded by the API. If the call request has been adjusted by the user, the application 110 can first manage and record the adjusted request before encapsulating and sending it. During the sending process, the application 110 can display the sending progress and status information in real time, such as the number of bytes sent and the remaining time, allowing the user to understand the sending status of the request at any time. After the API returns response information, the application 110 can parse and display the response information in an intuitive way, making it easier for the user to determine whether the API call was successful and to perform subsequent operations based on the response result.
[0035] The API calling method proposed in this disclosure provides a visual interface and multiple functional components. Users input natural language descriptions in input boxes. After confirmation, the component communicates with the model. The model generates a code file containing complete request information based on the user's intent and the API code logic, and displays it in the interactive components. Users can adjust the request method, request headers, and request body through different interactive components, each with corresponding auxiliary functions. Finally, clicking the send component allows the application to check and encapsulate the request. Regardless of adjustments, it can be sent to the API according to specifications, and the sending progress and parsed response information can be displayed in real time. This method can generate API call requests with a single click, reducing the technical threshold for users and improving processing efficiency and user experience.
[0036] As understood by those skilled in the art, an instance of server 120 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Servers can be connected directly or indirectly via wired or wireless communication, and this application does not impose any limitations on this.
[0037] The user device can be any type of mobile computing device, including mobile computers (e.g., personal digital assistants, laptops, notebooks, tablets, netbooks, etc.), mobile phones (e.g., cellular phones, smartphones, etc.), wearable computing devices (e.g., smartwatches, head-mounted devices, including smart glasses, etc.) or other types of mobile devices. In some embodiments, application 110 can also be a fixed computing device, such as a desktop computer, game console, smart TV, etc. It should be understood that, if application 110 has sufficient computing power, the user device can perform the above operations in place of server 120, or the user device and server 120 can jointly perform the above operations.
[0038] It should be understood that the architecture and functionality in example environment 100 are described for illustrative purposes only and do not imply any limitation on the scope of this disclosure. Embodiments of this disclosure can also be applied to other environments with different structures and / or functionalities.
[0039] The processes according to embodiments of this disclosure will be described in detail below with reference to other accompanying drawings. For ease of understanding, the specific data mentioned in the following description are exemplary and not intended to limit the scope of this disclosure. It will be understood that the embodiments described below may also include additional actions not shown and / or actions shown may be omitted, and the scope of this disclosure is not limited in this respect.
[0040] Figure 2 A flowchart of a method 200 for invoking an API according to certain embodiments of the present disclosure is shown. In this embodiment, the method can be executed by an application 110 on a user device. In block 202, user input for an API invocation request is obtained. An API is a set of rules and interfaces for interaction between different software modules. Developers can implement specific functions (such as data querying, information submission, etc.) by invoking APIs without needing to understand the underlying code logic. For example, a weather API can provide real-time weather data query services.
[0041] User input is the user's desired action described in natural language or other forms, which triggers the generation of a call request. If the target API is the "Suggestion Information Management API", the user input can be "Query the suggestion content with ID 101" or "Add a suggestion, the suggestion content is to add night mode".
[0042] In box 204, the call request is displayed in the interface. The call request is generated by the target model based on user input and API code. The interface is the application's display screen used to visualize the call request. The call request is an instruction conforming to the API specification, containing all the information needed to fulfill the user's requirements (such as request method, parameters, address, etc.), used to trigger the API to execute the corresponding operation.
[0043] In box 206, in response to receiving user confirmation, a call request is sent to the API. Sending a call request to the API means transmitting the generated or modified call request in the format required by the API (such as the HTTP protocol) to the API's specified address to execute the user's request.
[0044] The API invocation method disclosed herein utilizes a target model to analyze the user's natural language description and the API code, generates an API invocation request that matches the user's input, provides an interface to visualize the specific content of the invocation request, and executes the invocation operation using the request. This method can generate a dedicated invocation request for a specific API with a single click, visualize the request, and send it. This offers high processing efficiency, lowers the technical barrier for users, and improves the user experience, without requiring users to understand the API's code logic.
[0045] In some embodiments, the call request is generated by the target model based on API call method information and prompts input by the user. The call method information is determined by the target model based on the API code and includes the API address and the API-permitted request method. Figure 3A schematic diagram illustrating the generation of an invocation request according to a disclosed embodiment is shown. This operation can be performed on the server side. At 302, the user runs an application on their device and inputs their operation request in natural language through a specific interactive interface (such as input box 132), for example, "upload a new suggestion". The user device performs preliminary format validation and noise reduction on the raw input, removing extra spaces, special characters, etc., to ensure data standardization, and then transmits the input to the server via the network.
[0046] At position 304, the code of the server-side API is retrieved; this API is the one the user expects to call. The server is where the API code is stored, so it can be directly retrieved from the local machine. At position 306, the API code is identified as a prompt word and input into the multimodal model. The multimodal model analyzes the characteristics of the API code and determines the calling method information. In some embodiments, the server can convert the retrieved API code into a prompt word format that the multimodal model can understand. The server can use techniques such as syntax tree analysis and lexical analysis to deeply extract information such as function definitions and parameter type declarations from the API code. Taking a file upload API as an example, the uploadFile(filePath, fileType) function defined in its code, after server processing, will have a prompt word that includes detailed information such as the function name, parameter meaning (file path, file type), and parameter data type (string, enumeration value), and is accurately input into the multimodal model. In other embodiments, the API code can be directly used as the prompt word without extraction. The target module determines the invocation method by analyzing the business logic, interface specifications, security restrictions, and other characteristics contained in the API code.
[0047] At point 308, the multimodal model determines the URL address based on routing rules and domain name binding information configured in the API code. At point 310, the multimodal model determines the permitted request method for the API. This is achieved by analyzing annotations and function call logic within the API code. For example, if a data query function in the API code uses the `@GetMapping` annotation, the multimodal model can determine the corresponding request method as GET; if a data submission function uses the `@PostMapping` annotation, the request method is POST.
[0048] At point 312, the multimodal model determines the request parameters involved in the API. In some embodiments, the multimodal model parses the API code parameter definition portion to determine the request parameters involved in the API, including parameter name, type, and whether they are required. At point 314, user input and invocation method information are used as prompts and input into the multimodal model so that the multimodal model can generate an invocation request that matches the user input. For example, the server integrates the user input "upload a new suggestion" with the previously determined invocation method information and inputs it again as a prompt into the multimodal model. Based on its training results and reasoning capabilities, the multimodal model performs deep semantic matching and logical reasoning between the user intent and the API invocation specification on the server side to generate an invocation request that matches the user input. This embodiment provides multiple stages for generating invocation requests using a model, which can improve the accuracy of generating invocation requests that match user input for a specific API.
[0049] In the process of generating invocation requests using a model, language models typically have high code processing capabilities. If the model is a language model, in some embodiments, the code for the invocation request is obtained from the language model. This code may, for example, reside in a JSON file. In some embodiments, the application identifies the code of the invocation request to obtain the request method, request headers, request body, and request parameters for the invocation request. For example, keyword recognition can be used to distinguish which parts of the invocation request each code segment belongs to.
[0050] In some embodiments, the application can parse the file into a computer-understandable object structure according to the code's syntax rules. In other embodiments, the application can extract the request method, request headers, request body, and request parameters for the call request from the parsed object using predefined field mapping rules. For example, the application can obtain the request method "POST" from the `requestMethod` field, extract request header information from the `requestHeaders` object for authentication and data format declaration during subsequent API interactions, obtain the suggested upload content from the `requestBody` object and use it as the request body data, and extract request parameters such as the API's access URL and timeout from the `requestParameters` object. After extraction, in some embodiments, the request method, request headers, request body, and request parameters are displayed on the interface. For example, code content, such as the name of the request parameters and the type of the request method, can be directly extracted from the call request code (i.e., the JSON file) and displayed on the interface, which can improve the user experience. Simultaneously, this information also provides accurate data support for subsequent API call requests, ensuring that the request is executed smoothly according to user expectations and API specifications.
[0051] Figures 4A-4BA schematic diagram of interactive components according to embodiments of the present disclosure is shown. In some embodiments, interface 412 includes one or more interactive components selected from a first interactive component, a second interactive component, a third interactive component, and a fourth interactive component. Interactive components are visual elements (such as buttons, input boxes, drop-down lists, etc.) in an application's interface used to display and adjust request requests, supporting user interaction. For example, a text box for editing the request body. Figure 4A In this application, 410 provides an interface 412 to visualize the call request. The interface 412 may include a URL address 414, a request method interaction component (i.e., the first interaction component), a request header interaction component (i.e., the second interaction component) 416, a request body interaction component (i.e., the third interaction component), and a request parameter interaction component (i.e., the fourth interaction component).
[0052] In some embodiments, one or more of the following are displayed in one or more interactive components: the request method, request headers, request body, and request parameters of the invocation request. For example... Figure 4A The interface 412 provides a request header interaction component 416, a request body interaction component, a request parameter interaction component, and a local utility component. Figure 4A In the example, assume that the request header interaction component 416 is selected and the content of the request header is displayed below the interface 412.
[0053] In some embodiments, if the request method interaction component receives a first adjustment, the adjusted request method is displayed in the request method interaction component. For example, if the request method interaction component is triggered, a list of API-permitted request methods is displayed, and if a method in the list is selected, the selected method is displayed in the request method interaction component. For example, the user clicks a drop-down list in the request method interaction component and selects the "PUT" option to complete the adjustment. Subsequently, the request method interaction component refreshes in real time to display the adjusted request method as "PUT". In some embodiments, the application can check whether the adjustment will affect other parts such as the request body and request parameters. If a conflict exists, the user is prompted, such as "When using the PUT method, the request body parameter must include the suggestion ID".
[0054] In some embodiments, if a second adjustment is received based on the request header interaction component 416, the adjusted request headers are displayed in the request header interaction component 416. In some embodiments, if the request header interaction component is triggered, the request header data of the invoked request is displayed as key-value pairs. For example... Figure 4AThe generated request is shown with key 'a' and value 'b'. An add button 420 is also provided in the content 418 of the request header interaction component 416. In some embodiments, if the add button 420 is triggered, a request header data edit box is displayed in key-value pairs; and if user edits are received in the request header data edit box, the added request header data is displayed. That is, the user can enter custom request headers in key-value pairs and select the final request header to use via an enable / disable option.
[0055] In some embodiments, if the request body interaction component receives a third adjustment, the adjusted request body is displayed in the request body interaction component. For example, if the request body interaction component is triggered, the content of the request body is displayed in the text editing component, and if the text editing component receives user editing, the edited content is displayed. For example, if a user clicks the request body interaction component, this component displays the request body content in a JSON code visualization format, supporting user operations such as adding, deleting, and modifying. The user adds fields to the request body to complete the adjustment. The request body interaction component then displays the adjusted request body.
[0056] In some embodiments, if the request parameter interaction component receives a fourth adjustment, the adjusted request parameters are displayed in the request parameter interaction component. For example, the API supports specifying a suggested submission time via request parameters in certain situations, and the user wishes to add this information. The user clicks on the request parameter interaction component, which provides a parameter addition interface. The user enters the parameter name "submit_time" and the parameter value "2024-12-31 23:59:59" to complete the adjustment. The request parameter interaction component displays the adjusted request parameters: {"submit_time":"2024-12-31 23:59:59"}.
[0057] In some embodiments, the interface displays code for executing a call request using local tools. Figure 4B The interface 412 of application 410 shows a native tool component 430. Clicking this native tool component 430 displays the code used when sending a call request using the native tool. This code is generated by the multimodal model based on the call request code. For example, if the call request code is JavaScript code 432, the user can use a native tool (e.g., a browser) to execute this JavaScript code 432, thereby using the native tool to send the call request. In some embodiments, the native tool can be a command-line tool, and if the call request code is command-line code, the user can copy the code and execute it in the command-line tool to achieve the purpose of sending the call request. This helps users debug the API using other tools.
[0058] In some embodiments, this interface is a preview interface, and the application can receive response information from the API, including response headers and a response body, as well as the response headers and response body displayed in the preview interface. In other words, the application can visualize the API response information in the preview interface for easier user viewing, which can improve the user experience.
[0059] Figure 5A A schematic diagram illustrating the storage of log data according to an embodiment of this disclosure is shown. At 502, the server receives a call request from the user device. Taking the HTTP protocol as an example, the transport layer establishes a reliable connection using TCP, and the application layer parses the request message, verifying the request header and request body. At 504, the server generates an associated unique identifier for the call request, for example, a 128-bit identifier generated based on a UUID library. The generated unique identifier will be used throughout the request processing to associate data at each stage.
[0060] At position 506, the unique identifier is injected into the response header. When processing a request, the server-side API can generate the response header first, and then send the response body. This phased processing approach is very practical in many scenarios. Therefore, the identifier can be injected into the response header so that all log data generated during subsequent processing includes this unique identifier. At position 508, the request body is executed. For example, a "upload new suggestion" request needs to parse the data, verify its validity, and then store it in the database. The database operations and execution time information generated during this process are important log data. At position 510, log data containing this unique identifier is collected. When there is a request-related operation, the operation information, timestamp, and result are captured and bound to the unique identifier for logging. Successful or failed operations are recorded in detail, forming a complete request processing trail. At position 512, the log data is stored; for example, the collected log data is stored in dedicated storage.
[0061] In some embodiments, the user device receives log data from the server hosting the API. For example, the server retrieves the log data with the unique identifier from a dedicated storage device for storing log data and sends it to the application on the user device. In some embodiments, the log data is displayed in a preview interface. This allows developers to see the log data directly on the user device without having to transfer it to the server and retrieve the log data, which can improve work efficiency and enhance the user experience.
[0062] Figure 5BA schematic diagram of response information according to an embodiment of this disclosure is shown. After receiving the response information, application 514 can parse it and display its components, such as a response header and response body, on interface 516. Interface 516 shows a response body component 518, a response header component 520, and a service log 522. Users can click on each component to view the corresponding response content. For example, clicking on the response body component 518 will display the response body content at content 524. The content contains an injected unique identifier 526. Based on this unique identifier 526, the server can retrieve relevant log data and send it to application 514. Application 514 can then display the received log data in the content of service log 522 for user convenience.
[0063] In some embodiments, if the response information indicates an error, a repair component is displayed in the preview interface, wherein whether the response information indicates an error is determined by a multimodal model through analysis of the response information. The multimodal model can identify the presence of an error using the status code in the response information.
[0064] In some embodiments, if the repair component is triggered, an updated invocation request is generated, wherein the updated invocation request is generated by a multimodal model based on the invocation request, API, response information, and log data.
[0065] Figure 5C A schematic diagram illustrating the generation of repair suggestions according to embodiments of this disclosure is shown. At 530, response information is obtained by a multimodal model. At 532, the error category is analyzed using a multimodal model based on the status code or error code in the response information sent by the server. At 534, the code of the server's API is obtained. The API code helps in accurately analyzing the logical problems present in the error. At 536, error analysis is performed using a multimodal model. In some embodiments, the multimodal model performs in-depth mining of log data to find the root cause of the error from the entire process record of request reception, processing, and response. For example, by analyzing the logs, it is found that an error occurred when performing a database insert operation because the data type in the request body did not match the database field type. The multimodal model can correct the request body according to the data type requirements in the API interface specification, combined with the data content in the original call request. At 538, a repair suggestion is generated. At 540, the repair suggestion is displayed, for example, by displaying the repair suggestion in the interface and interactive components, or by displaying it separately in a text area, explaining the cause of the error. In this embodiment, users only need to click the confirmation button to complete the error repair and re-call process, which greatly improves the efficiency of problem solving and enhances the user experience.
[0066] Figure 6An architecture diagram of a system for invoking an API according to an embodiment of this disclosure is shown. The system includes a code analyzer 604, a request generator 606, a request workbench 608, a request executor 610, a response analyzer 612, a log collector 614, and a bug fixer 616. During operation, the user first inputs their request through the system interface. The input is presented in natural language, such as "Get detailed information about user ID 123". This user input received in the interface is directly transmitted to the request generator 606. Simultaneously, the code of the server-side API is provided to the code analyzer 604, which uses a multimodal model to analyze the API's calling method information.
[0067] In some embodiments, the code analyzer 604 sends the analyzed call method information to the request generator 606, which generates a call request conforming to the API specification based on the call method information and user input. In some embodiments, the request generator 606 sends the call request to the request workbench 608. In some embodiments, the request workbench 608 provides an interface and interactive components therein for users to view, edit, and send call requests. For example, in the interface, the request method, request parameters, request body, etc., are displayed in a clear and structured form, which users can easily browse; if an error is found in the request parameters, they can be directly modified in the corresponding interactive component. When the user confirms that the call request is correct and clicks the send component, the request workbench 608 sends the call request to the request executor 610.
[0068] In some embodiments, after a user clicks the send component, the request workbench 608 sends the call request to the request executor 610. During the sending process, the request executor 610 can strictly adhere to network communication protocols (such as HTTP / HTTPS), encapsulating and encrypting the request to ensure the security and integrity of the data during transmission. In some embodiments, the request executor 610 sends the call request to the server's API. In some embodiments, the response analyzer 612 can receive response information from the server and analyze its various components, then pass it to the request workbench 608 for display in the interactive components of the interface. In some embodiments, the server is equipped with a log collector 614, which retrieves log data from the log database based on a unique identifier. In some embodiments, the error repairer 616 can update the call request based on the log data, response information, and call request, and send the updated call request to the request workbench 608 for display. In some embodiments, if the user confirms the send, the error repairer 616 can send the updated call request to the request executor 610 for sending, and the aforementioned process can be repeated.
[0069] This system utilizes a collaborative approach involving multiple components such as a code analyzer and a request generator to transform user natural language input into API call requests. Users can visualize the process on the request dashboard, while the system automatically executes requests, analyzes responses, and uses a log collector and error corrector to adjust requests based on responses and logs, forming a closed-loop optimization. Ultimately, this achieves low-barrier, high-efficiency API call request generation, accurate response analysis, and rapid error correction, significantly improving API call efficiency and user experience while lowering the technical barrier to entry.
[0070] Figure 7 A schematic block diagram of an apparatus 700 for calling an API according to some embodiments of the present disclosure is shown. The apparatus 700 can be implemented in software, hardware, or a combination of both. Figure 7 As shown, the device 700 includes an acquisition module 710, a display module 720, and a transmission module 730.
[0071] The acquisition module 710 can be configured to acquire user input for an API call request. The display module 720 can be configured to display the call request on the interface; the call request is generated by the target model based on the user input and the API code. The sending module 730 can be configured to send the call request to the API in response to receiving user confirmation.
[0072] In some embodiments, the interface includes one or more interactive components selected from a first interactive component, a second interactive component, a third interactive component, and a fourth interactive component, and the display module 720 includes a component display module configured to display one or more of the following in the one or more interactive components: a request method, a request header, a request body, and request parameters of a call request; a second display module configured to display an adjusted request method in the first interactive component in response to receiving a first adjustment based on the first interactive component; a third display module configured to display an adjusted request header in the second interactive component in response to receiving a second adjustment based on the second interactive component; a request body display module configured to display an adjusted request body in the third interactive component in response to receiving a third adjustment based on the third interactive component; and a request parameter display module configured to display adjusted request parameters in the fourth interactive component in response to receiving a fourth adjustment based on the fourth interactive component.
[0073] In some embodiments, the second display module includes a list display module configured to display a list of API permission request methods in response to the first interactive component being triggered; and a method display module configured to display the selected method in the first interactive component in response to the selection of a method in the list.
[0074] In some embodiments, the second interactive component includes an add button, and the third display module includes a request header display module configured to display request header data of the call request in key-value pairs in response to the second interactive component being triggered; an edit box display module configured to display a request header data edit box in key-value pairs in response to the add button being triggered; and a request header data display module configured to display the added request header data in response to receiving user edits based on the request header data edit box.
[0075] In some embodiments, the fourth display module includes a content display module for the request body, configured to display the content of the request body in a text editing component in response to the third interactive component being triggered; and an edit content display module, configured to display the edited content in response to the text editing component receiving user edits.
[0076] In some embodiments, the apparatus 700 further includes a code display module configured to display on the interface code for executing a call request using local tools.
[0077] In some embodiments, the interface is a preview interface, and the device 700 further includes a first receiving module configured to receive response information from an API, wherein the response information includes a response header and a response body; and a response information display module configured to display the response header and response body of the response information on the preview interface.
[0078] In some embodiments, the device 700 further includes a second receiving module configured to receive log data from the server where the API is located, wherein the log data is associated with a unique identifier, the unique identifier is pre-recorded in the response header by the server, and the log data is obtained by the server based on the unique identifier; and a log display module configured to display the log data in a preview interface.
[0079] In some embodiments, the apparatus 700 further includes a repair component display module configured to display a repair component on a preview interface in response to an error indicated by a response message, wherein whether the response message indicates an error is determined by the target model by analyzing the response message; and a generation module configured to generate an updated call request in response to the repair component being triggered, wherein the updated call request is generated by the target model based on the call request, API, response message, and log data.
[0080] In some embodiments, the call request is generated by the target model based on API call method information and prompts input by the user. The call method information is determined by the target model based on the API code and includes the API address and the API-permitted request method.
[0081] In some embodiments, the display module 720 includes a third acquisition module configured to acquire the code of the call request; an identification module configured to identify the code of the call request to obtain the request method, request header, request body and request parameters for the call request; and a request display module configured to display the request method, request header, request body and request parameters in the interface.
[0082] The division of modules or units in the embodiments of this disclosure is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods. Furthermore, the functional units in the disclosed embodiments may be integrated into one unit, exist as separate physical entities, or two or more units may be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional unit.
[0083] Figure 8 A block diagram of an example device 800 that can be used to implement embodiments of the present disclosure is shown. It should be understood that... Figure 8 The device 800 shown is merely an example and should not be construed as limiting the functionality and scope of the implementation described herein. For example, device 800 may correspond to the implementation described herein. Figure 1 The user equipment described above can be used to perform the above-described... Figures 1 to 3 as well as Figure 5A , Figure 5C The process. For example, device 800 may correspond to the electronic device of the third aspect of the invention.
[0084] like Figure 8 As shown, device 800 is in the form of a general-purpose computing device. Components of device 800 may include, but are not limited to, one or more processors or processing units 810, memory 820, storage device 830, one or more communication units 840, one or more input devices 850, and one or more output devices 860. Processing unit 810 may be a physical or virtual processor and is capable of performing various processes according to programs stored in memory 820. In a multiprocessor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capability of device 800.
[0085] Device 800 typically includes multiple computer storage media. Such media can be any available media accessible to device 800, including but not limited to volatile and non-volatile media, removable and non-removable media. Memory 820 can be volatile memory (e.g., registers, cache, random access memory (RAM)), non-volatile memory (e.g., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof). Storage device 830 can be a removable or non-removable medium and may include machine-readable media, such as flash drives, disks, or any other media capable of storing information and / or data (e.g., training data for training) and accessible within device 800.
[0086] Device 800 may further include additional removable / non-removable, volatile / non-volatile storage media. Although not explicitly stated... Figure 8 As shown, disk drives for reading from or writing to removable, non-volatile disks (e.g., "floppy disks") and optical disk drives for reading from or writing to removable, non-volatile optical disks can be provided. In these cases, each drive can be connected to a bus (not shown) via one or more data media interfaces. Memory 820 may include computer program product 825 having one or more program modules configured to perform various methods or actions of various implementations of this disclosure.
[0087] The communication unit 840 enables communication with other computing devices via a communication medium. Additionally, the functionality of the components of device 800 can be implemented as a single computing cluster or multiple computing machines capable of communicating via communication connections. Therefore, device 800 can operate in a networked environment using logical connections to one or more other servers, network personal computers (PCs), or another network node.
[0088] Input device 850 can be one or more input devices, such as a mouse, keyboard, trackball, etc. Output device 860 can be one or more output devices, such as a monitor, speaker, printer, etc. Device 800 can also communicate with one or more external devices (not shown) via communication unit 840 as needed. These external devices include storage devices, display devices, etc., and can communicate with one or more devices that enable user interaction with device 800, or with any device that enables device 800 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication can be performed via an input / output (I / O) interface (not shown).
[0089] According to an exemplary implementation of this disclosure, a computer-readable storage medium is provided that stores computer-executable instructions thereon, wherein the computer-executable instructions are executed by a processor to implement the methods described above. According to an exemplary implementation of this disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, which are executed by a processor to implement the methods described above. According to an exemplary implementation of this disclosure, a computer program product is provided that stores a computer program thereon, which, when executed by a processor, implements the methods described above.
[0090] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, devices, and computer program products implemented according to this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0091] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0092] Computer-readable program instructions can be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions that execute on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0093] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0094] Various implementations of this disclosure have been described above. The foregoing description is exemplary and not exhaustive, nor is it limited to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is chosen to best explain the principles, practical applications, or improvements to technology in the market, or to enable others skilled in the art to understand the various implementations disclosed herein.
Claims
1. A method for calling an Application Programming Interface (API), comprising: Obtain user input for the API call request; as well as The call request is displayed in the interface; the call request is generated by the target model based on the user input and the code of the API. as well as In response to receiving user confirmation, the call request is sent to the API.
2. The method according to claim 1, wherein the interface includes one or more interactive components selected from a first interactive component, a second interactive component, a third interactive component, and a fourth interactive component, and displaying the call request on the interface includes: Display one or more of the request method, request headers, request body, and request parameters of the invocation request in one or more interactive components; In response to receiving a first adjustment based on the first interactive component, the adjusted request method is displayed in the first interactive component; In response to receiving a second adjustment based on the second interaction component, the adjusted request header is displayed in the second interaction component; In response to receiving a third adjustment based on the third interaction component, the adjusted request body is displayed in the third interaction component; or In response to receiving a fourth adjustment based on the fourth interaction component, the adjusted request parameters are displayed in the fourth interaction component.
3. The method of claim 2, wherein the method of displaying the adjusted request in the first interactive component in response to receiving the first adjustment based on the first interactive component comprises: In response to the first interactive component being triggered, a list of request methods permitted by the API is displayed; as well as In response to a method being selected in the list, the selected method is displayed in the first interactive component.
4. The method of claim 2, wherein the second interactive component includes an add button, and displaying the adjusted request header in the second interactive component in response to receiving a second adjustment based on the second interactive component includes: In response to the second interactive component being triggered, the request header data of the call request is displayed in key-value pairs; In response to the addition button being triggered, a request header data edit box is displayed in the form of key-value pairs; as well as In response to receiving user edits in the request header data edit box, the added request header data is displayed.
5. The method of claim 2, wherein displaying the adjusted request body in the third interaction component in response to receiving a third adjustment based on the third interaction component comprises: In response to the triggering of the third interactive component, the content of the request body is displayed in the text editing component; as well as In response to receiving user edits based on the text editing component, the edited content is displayed.
6. The method according to claim 1, further comprising: The interface displays the code used to execute the call request using local tools.
7. The method according to claim 1, wherein the interface is a preview interface, and the method further comprises: Receive response information from the API, wherein the response information includes a response header and a response body; as well as The response header and response body of the response information are displayed in the preview interface.
8. The method according to claim 7, further comprising: Log data is received from the server where the API is located, wherein the log data is associated with a unique identifier, the unique identifier is pre-recorded in the response header by the server, and the log data is obtained by the server based on the unique identifier; as well as The log data is displayed in the preview interface.
9. The method according to claim 8, further comprising: In response to the response information indicating an error, a repair component is displayed on the preview interface, wherein whether the response information indicates an error is determined by the target model through analysis of the response information; as well as In response to the triggering of the repair component, an updated invocation request is generated, wherein the updated invocation request is generated by the target model based on the invocation request, the API, the response information, and the log data.
10. The method of claim 1, wherein the call request is generated by the target model based on the API call method information and the prompt words input by the user, the call method information being determined by the target model based on the API code, and the call method information including the API address and the API permitted request method.
11. The method of claim 10, wherein displaying the call request on the interface comprises: The code for obtaining the call request; Identify the code of the call request to obtain the request method, request headers, request body, and request parameters for the call request; as well as The interface displays the request method, request headers, request body, and request parameters.
12. An apparatus for calling an application programming interface (API), comprising: The acquisition module is configured to acquire user input for the API call request; The display module is configured to display the call request in the interface, the call request being generated by the target model based on the user input and the code of the API; as well as The sending module is configured to send the call request to the API in response to receiving user confirmation.
13. An electronic device, comprising: At least one processing unit; At least one memory is coupled to at least one processing unit and stores instructions for execution by the at least one processing unit, the instructions causing the electronic device to perform the method according to any one of claims 1 to 11 when executed by the at least one processing unit.
14. A computer program product having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 11.