Method and system for processing API request, storage medium and electronic equipment
By monitoring the time, parameter uniqueness, and frequency of API requests, and combining caching and rate limiting mechanisms, the contradiction between API request compliance and high-frequency data demand in the power trading market was resolved. This enabled efficient and stable API processing, meeting the standards of the power trading center and the real-time data needs of third-party platforms.
Patent Information
- Application Number
- CN202511677519.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-17
- Publication Date
- 2025-12-16
AI Technical Summary
In the power trading market, there is a contradiction between the strict restrictions on API calls imposed by power trading centers and the increasing demand for high-frequency data from third-party trading platforms. Existing solutions suffer from problems such as API request delays, redundant calls, and insufficient data real-time performance.
By obtaining the trading time period and API requests from the power trading center, we can determine the request time, parameter uniqueness, and call frequency to carry out compliance processing, identify duplicate requests and delay excessive requests, and combine cache management and rate limiting mechanisms to ensure that API requests comply with specifications and optimize response efficiency.
It has improved the compliance and response efficiency of API requests, reduced redundant calls and resource consumption, ensured the real-time performance and stability of data, met the real-time needs of transaction decision-making and analysis, and reduced system operating costs.
Smart Images

Figure CN121144064A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of power industry data processing, and relates to a method and system for processing API requests, a storage medium and an electronic device. BACKGROUND
[0002] An application programming interface (API) is a standardized interface for realizing data interaction and function calling between different systems. In the power trading scenario, the API is mainly used for transmitting key data such as quotes, market information and transaction results between a third-party trading platform and a power trading center.
[0003] In the power trading market, a third-party trading platform needs to support multiple functional modules such as a trading decision engine, a market display platform and quantitative analysis services, and needs to initiate high-frequency and large-volume API requests to the power trading center. However, with the rapid development of the power trading market, the contradiction between the strict restrictions of the power trading center on API calling and the increasing demand of the third-party trading platform for high-frequency data is becoming increasingly prominent. However, the existing solutions for processing API calling requirements of the third-party trading platform all have obvious defects. SUMMARY
[0004] The application provides a method and system for processing API requests, a storage medium and an electronic device, which are used to solve the contradiction between the strict restrictions of the power trading center on API calling and the increasing demand of the third-party trading platform for high-frequency data in the current power trading market.
[0005] In a first aspect, the application provides a method for processing API requests, which is applied to a processing system that is in communication with a power trading center and a third-party trading platform, and includes the following steps: acquiring a trading time period of the power trading center and API requests of the third-party trading platform; performing first processing on the API requests, the first processing including judging whether the API requests are in the trading time period; performing second processing on the API requests based on a result of the first processing, the second processing including judging whether a unique identifier corresponding to the API requests exists in all stored unique identifiers; performing third processing on the API requests based on a result of the second processing, the third processing including judging whether the API requests exceed a calling frequency limit specified by the power trading center within a current time window; and returning a processing result of the API requests to the third-party trading platform according to results of the first processing, the second processing and the third processing.
[0006] In the present application, the first processing ensures that the API request is initiated within the time specified by the power trading center, ensuring the compliance of the API request; the second processing identifies API requests with the same parameters, avoiding redundant and repeated API request calls, and improving the overall throughput and response efficiency of the system; the third processing monitors the call frequency of the API request, further ensuring the compliance of the API request.
[0007] In an implementation form of the first aspect, the first processing further comprises: if the API request is within the trading time period, triggering the second processing corresponding to the API request; if the API request is not within the trading time period, performing fourth processing on the API request, the fourth processing comprising judging the call data type corresponding to the API request.
[0008] In an implementation form of the first aspect, the fourth processing further comprises: if the call data type corresponding to the API request is business data, rejecting the API request; if the call data type corresponding to the API request is non-business data, triggering the second processing corresponding to the API request.
[0009] In an implementation form of the first aspect, the second processing further comprises: if there is a unique identifier corresponding to the API request, feeding back the call data of the API request corresponding to the unique identifier to the third-party trading platform; if there is no unique identifier corresponding to the API request, triggering the third processing corresponding to the API request.
[0010] In an implementation form of the first aspect, the third processing further comprises: if the API request exceeds the call frequency limit specified by the power trading center within the current time window, calculating the delay time corresponding to the API request, and obtaining the call data corresponding to the API request from the power trading center after the delay time; if the API request does not exceed the call frequency limit specified by the power trading center within the current time window, obtaining the call data corresponding to the API request from the power trading center.
[0011] In an implementation form of the first aspect, the method further comprises: storing the call data corresponding to all API requests within the current time window and the unique identifier corresponding to each API request.
[0012] In an implementation form of the first aspect, the method further comprises: during a non-trading time period, sending an API request for calling non-business data to the power trading center; and / or, after the current time window expires, automatically cleaning up the stored data within the current time window.
[0013] In the present embodiment, the connection activity between the third-party transaction platform and the power transaction center is maintained through "low-frequency, lightweight API requests", avoiding session invalidation due to long-time no requests, and ensuring that the third-party transaction platform can directly initiate API requests without repeated login.
[0014] In a second aspect, the present application provides a system for processing API requests, which is used to execute the method for processing API requests in any of the implementation manners of the first aspect, and includes: a time management module configured to obtain a transaction time period of the power transaction center and perform the first processing on API requests of the third-party transaction platform; a cache management module configured to store calling data corresponding to all API requests in a current time window and a unique identifier corresponding to each API request, and perform the second processing on API requests of the third-party transaction platform; and a flow limiting management module configured to perform the third processing on API requests of the third-party transaction platform.
[0015] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement the method for processing API requests in any of the implementation manners of the first aspect.
[0016] In a fourth aspect, the present application provides an electronic device, which includes: a memory having a computer program stored thereon; and a processor connected in communication with the memory, and the processor implements the method for processing API requests according to any of the implementation manners of the first aspect when executing the computer program.
[0017] As described above, the method, system and storage medium for processing API requests have the following beneficial effects:
[0018] 1. In the present application, the first processing and the third processing can monitor the initiation time and calling frequency of API requests, ensure that each API request meets the calling specification of the power transaction center, and guarantee the compliance of API requests.
[0019] 2. In the second processing of the present application, API requests with the same parameters are identified according to the unique identifier of the API requests, and the calling data corresponding to the API requests in the cache is directly returned to the third-party transaction platform, which reduces the calling pressure, avoids the calling of redundant and repeated API requests, and improves the overall throughput and response efficiency of the system.
[0020] 3. The application only stores the call data of the API request with successful response and its corresponding unique identifier, which avoids the repeated storage of the same parameter API request and does not need to store the full amount of data, thereby reducing the occupation of network bandwidth and computing resources and reducing the system operation cost. At the same time, the application automatically cleans up the stored data within the expired time window, which can ensure that the stored data is always the latest valid data, guarantees the real-time of the data, effectively avoids the interference of old data on transaction decision, and makes the data stream output more stable, thereby meeting the real-time data needs of multiple modules such as transaction decision engine, market display, quantitative analysis, and further optimizing the service quality. BRIEF DESCRIPTION OF DRAWINGS
[0021] Figure 1 A schematic diagram of an application scenario of the method for processing API requests described in the embodiments of the application is shown.
[0022] Figure 2 A general flowchart of the method for processing API requests described in the embodiments of the application is shown.
[0023] Figure 3 A detailed flowchart of the method for processing API requests described in the embodiments of the application is shown.
[0024] Figure 4 An architecture diagram of the API request system described in the embodiments of the application is shown.
[0025] Figure 5 A processing flowchart of the API request system described in the embodiments of the application processing multiple API requests is shown.
[0026] Figure 6 A structural schematic diagram of an electronic device according to an embodiment of the disclosure is shown. DETAILED DESCRIPTION
[0027] The embodiments of the application are described below through specific and concrete examples, and those skilled in the art can easily understand other advantages and effects of the application from the content disclosed in the specification. The application can also be implemented or applied through other different specific embodiments, and each detail in the specification can be modified or changed based on different views and applications without departing from the spirit of the application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0028] It is to be understood that the terms "first", "second", and the like in the description and in the claims, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of data "or" herein includes that a selection maybe made from the group of items that are conjunctively described. Furthermore, as used herein, the conjunction "and" does not mean an exclusive "and" unless specifically stated as such.
[0029] It is to be understood that the above-mentioned embodiments serve the purpose of illustration only. The drawings are not necessarily to scale, the emphasis instead being placed upon illustrating the basic principles of the application. In the drawings, like reference numerals refer to like parts throughout the various views thereof, and the illustrations are schematic and for the purpose of an easier understanding it is to be noted that the shapes and the relative sizes of the different elements in the drawings are not to scale, and that the layout of the elements in the drawings can be more complex than what is shown.
[0030] There are mainly two solutions in the prior art to solve the contradiction between the strict restrictions on API calls of the power trading center and the growing high-frequency data needs of the third-party trading platform.
[0031] One solution is called a simple queuing mechanism, which queues a large number of API requests that exceed the frequency limit of the power trading center through a message queue, and sends the API call requests in turn according to the queuing order after waiting for the next time window. However, the rapidly growing queue length will increase the delay of API requests, resulting in serious lag of the data obtained by the API. In addition, repeated parameters of API requests cannot be identified, which will also cause redundant calls.
[0032] Another solution is called a full cache mechanism, in which the third-party trading platform pre-fetches and stores full data from the power trading center at a preset fixed time interval for internal direct use. However, this solution not only consumes excessive network resources due to large data size, but also causes data update to be not timely due to fixed time intervals, which cannot meet the real-time needs of API requests.
[0033] Therefore, it is urgent to build a technical architecture that not only meets the calling specifications of the power trading center, but also efficiently manages and controls API requests.
[0034] It should be noted that in the power trading market, the power trading center imposes three core restrictions on API requests: First, there are time restrictions on API request initiation, with the power trading center having designated trading and non-trading time periods; second, there are restrictions on the data types of API requests during non-trading time periods, with the power trading center only allowing calls to non-business data during non-trading time periods; and third, there are restrictions on the frequency of API requests, specifically meaning that the number of API requests cannot exceed a specified limit within a preset single time window.
[0035] It should be noted that the API requests from third-party trading platforms include both non-business data and business data. Non-business data refers to data unrelated to trading operations, such as requests for the power trading center's server system time, verification of user session validity, user information queries, and checks on the connection status between the platform and the power trading center. Business data refers to data related to trading operations, such as requests to query electricity price quotes and trading volumes, submit trading orders, and retrieve historical trading records.
[0036] To address the aforementioned issues, this application provides a method, system, and storage medium for processing API requests, applied to a processing system that is communicatively connected to a power trading center and a third-party trading platform. The technical solutions in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0037] Figure 1 This illustration shows a possible scenario in which the API request processing method of this application is applicable. The method is applied to a processing system that communicates with a power trading center and a third-party trading platform. Specifically, user terminals initiate operations such as market data inquiries, order submissions, and account information inquiries to the third-party trading platform via a website interface or other means. The API requests corresponding to these operations are first processed by this processing system before being forwarded to the power trading center. After the power trading center successfully responds, the response result is forwarded to the third-party trading platform via the processing system.
[0038] like Figure 2 As shown, this embodiment provides a method for processing API requests, which can be applied to... Figure 1 The system shown for handling API requests specifically includes:
[0039] S1: This processing system obtains the trading time period of the power trading center and API requests from third-party trading platforms.
[0040] For example, when the processing system starts, it actively obtains the trading time period of the day from the power trading center and stores the time period information in the cache management module of the processing system, such as storing it in the browser's local storage, for use in subsequent processing of API requests from third-party trading platforms (such as the first processing).
[0041] In this embodiment, before the API request from the third-party trading platform is sent to the power trading center, it is pre-processed by the processing system to ensure that the API request does not violate the power trading center's calling specifications.
[0042] S2: The processing system performs the first processing on the API request, which includes determining whether the API request is within a transaction period.
[0043] For example, the first process includes: the processing system determining whether the API request is within a transaction period.
[0044] If the processing system determines that the API request is within a transaction period, the first processing also includes triggering the second processing corresponding to the API request.
[0045] If the system determines that the API request is outside of a transaction period, the first processing also includes: the system performs a fourth processing on the API request, which includes determining the data type of the API request.
[0046] For example, the fourth process includes: the processing system determining the data type of the API request.
[0047] If the processing system determines that the data type of the API request is business data, the fourth step also includes rejecting the API request.
[0048] If the processing system determines that the data type of the API request is non-business data, the fourth processing also includes: triggering the second processing corresponding to the API request.
[0049] S3: The processing system performs a second processing on the API request based on the result of the first processing. The second processing includes determining whether a unique identifier corresponding to the API request exists among all the unique identifiers stored by the processing system.
[0050] For example, the second process includes: the processing system determining whether a unique identifier corresponding to the API request exists among all the stored unique identifiers.
[0051] If the processing system determines that a unique identifier exists corresponding to the API request, the second process also includes: returning the API request call data corresponding to the unique identifier to the third-party trading platform.
[0052] If the processing system determines that there is no unique identifier corresponding to the API request, the second process also includes: triggering the third process corresponding to the API request.
[0053] In this embodiment, the processing system stores unique identifiers of all successfully responded API requests from power trading centers within a time window, along with their corresponding call data. Specifically, when a third-party trading platform successfully obtains call data from a power trading center through the API request processing system of this application, the system stores the unique identifier corresponding to the API request, as well as the call data returned by the power trading center. If the unique identifier of a subsequent API request matches the stored unique identifier, and the corresponding data has not expired (i.e., is still within the current time window), the system can directly return the corresponding stored data to the third-party trading platform without repeatedly initiating API requests to the power trading center, thus improving response efficiency and avoiding waste of network resources.
[0054] It should be noted that, in this embodiment, the processing system generates a corresponding unique identifier (e.g., a hash value calculated by a hash algorithm) based on the parameters of each API request, thereby ensuring that within the same time window, API requests with the same parameters have the same unique identifier, and API requests with different parameters have different unique identifiers.
[0055] For example, this processing system can transform complex request parameter calculations into short and unique identifiers by standardizing API request parameter strings and hash algorithms, thus associating the API request, hash value, and call data for subsequent calls. Specifically, the standardized API request parameter strings can be converted into standardized JSON format strings, for example, using the built-in stringify method of the JavaScript JSON (JavaScript Object Notation) object.
[0056] It's important to note that JSON is a lightweight data-interchange format with cross-platform and cross-language compatibility, widely used in data transmission and storage scenarios. In JavaScript, `stringify` is a core static method of the global object `JSON`, its main function being to serialize JavaScript values into strings conforming to the JSON format specification.
[0057] Preferably, the processing system only stores data for the current time window. After the current time window expires, the system automatically cleans up the stored data within that time window, such as stored transaction time period data, unique identifiers of each requested API within the current time window, and their corresponding call data. This not only ensures the real-time nature and accuracy of the data and avoids the risk of expired and invalid old data interfering with decision-making, but also significantly reduces the consumption of invalid memory resources, lowers system maintenance costs, and improves system response efficiency.
[0058] S4: The processing system performs a third processing on the API request based on the result of the second processing. The third processing includes determining whether the API request exceeds the call limit stipulated by the power trading center within the current time window.
[0059] For example, the third process includes: the processing system determining whether the API request exceeds the call limit stipulated by the power trading center within the current time window.
[0060] If the processing system determines that the API request exceeds the limit on the number of calls specified by the power trading center within the current time window, the third process also includes: the processing system calculates the delay time corresponding to the API request, and obtains the call data corresponding to the API request from the power trading center after the delay time has elapsed.
[0061] If the processing system determines that the API request does not exceed the call limit stipulated by the power trading center within the current time window, the third process also includes: the processing system directly obtains the call data corresponding to the API request from the power trading center, that is, the processing system immediately forwards the API request to the power trading center.
[0062] For example, the processing system can monitor and count the number of API calls within a preset time window using a counter, which serves as the basis for subsequent systems to determine whether the API request exceeds the call limit stipulated by the power trading center within the current time window (third processing).
[0063] For example, regarding the third processing of API requests exceeding limits, this processing system can use an "asynchronous chained scheduling mechanism (Promise)" to ensure the sequential execution of API requests within the delay queue. Only after the current API request completes (e.g., the API request call successfully returns a response or the delay time expires and execution is completed) will the next API request be scheduled. This processing system can use "precise delay scheduling with a timer (set Timeout)" to calculate the delay time, and only send the API request to the power trading center after the corresponding delay time has elapsed, ensuring that API requests are initiated only at compliant times. In the power trading scenario, the above scheduling mechanism can satisfy the frequency limits of the trading center while ensuring the sequential and real-time processing of API requests, avoiding concurrency chaos and illegal calls, and further resolving the contradiction between compliance and high-frequency calls.
[0064] S5: The processing system returns the processing result of the API request to the third-party trading platform based on the results of the first, second, and third processing.
[0065] Optionally, the above method also includes sending API requests for non-business data to the power trading center during non-trading periods. By using "low-frequency, lightweight API requests," the connection between the third-party trading platform and the power trading center is maintained, preventing session invalidation due to prolonged periods without requests and ensuring that the third-party trading platform can directly initiate API requests without repeated logins. Optionally, the processing system can periodically send the aforementioned API requests to the power trading center at preset times to maintain session activity.
[0066] In some specific embodiments, the above-described method for handling API requests can be encapsulated as a browser plugin deployed on the front end. This plugin contains the aforementioned processing system. When a user terminal initiates operations such as market data inquiries, order submissions, and account information inquiries to a third-party trading platform through a website interface, the corresponding API requests will first be processed by this plugin before being forwarded to the power trading center. By embedding the above-described API request processing method into the user's browser through a browser plugin, lightweight deployment and low-latency processing are achieved, precisely adapting to power trading scenarios.
[0067] For example, Figure 3 The detailed flowchart of the above-mentioned method for processing API requests is shown, demonstrating the compliance and efficiency control logic of this application for the entire process of API requests from acquisition to final response. It realizes multi-dimensional collaboration of compliance control during trading hours, optimization of duplicate request caching, and delay scheduling of over-limit requests, ensuring that API requests, while complying with the power trading center's specifications, also take into account response efficiency and resource conservation.
[0068] The scope of protection of the method for processing API requests described in this application is not limited to the execution order of the steps listed in this embodiment. Any solution implemented by adding, deleting, or replacing steps in the prior art based on the principles of this application is included within the scope of protection of this application.
[0069] This application also provides a system for processing API requests, which is a possible specific implementation of the processing system described in the above-described method for processing API requests. It can implement the method for processing API requests described in this application. However, the implementation apparatus for the method for processing API requests described in this application includes, but is not limited to, the structure of the system for processing API requests listed in this embodiment. All structural modifications and substitutions of the prior art made based on the principles of this application are included within the protection scope of this application.
[0070] like Figure 4 As shown, this embodiment provides a system for processing API requests, used to execute the above-described method for processing API requests. The system specifically includes: a time management module for obtaining the trading time period of a power trading center and performing a first processing of API requests from third-party trading platforms; a cache management module for storing call data corresponding to all API requests within the current time window and a unique identifier corresponding to each API request, and performing a second processing of API requests from third-party trading platforms; and a rate limiting management module for performing a third processing of API requests from third-party trading platforms.
[0071] Optionally, the time management module is also used to perform a fourth process on API requests that are not within the transaction period to further determine the business data type corresponding to the API.
[0072] Optionally, the rate limiting management module is also used to calculate the delay time that the API request should wait for when the API request is rate-limited, wait in sequence, and after the previous API request is completed and the delay time has elapsed to the time window when the API request is not rate-limited, forward the API request to the power trading center again.
[0073] It should be noted that the cache management module stores API request call data successfully obtained from the power exchange center within the current time window, along with the unique identifier of each API request. It also stores key data such as the power exchange center's trading time periods and the frequency of API request calls. Preferably, the system can preset an update time and periodically request updates to the trading time period data from the power exchange center, thereby further ensuring the real-time performance and accuracy of the data, as well as the compliance of the API requests.
[0074] Preferably, the cache management module only stores data for the current time window. After the current time window expires, the system automatically cleans up the stored data within that time window. This not only ensures the real-time performance and accuracy of the data and avoids the risk of expired and invalid old data interfering with decision-making, but also significantly reduces the use of invalid memory resources, lowers system maintenance costs, and improves system response efficiency.
[0075] It should be noted that, Figure 4 The system's time management module corresponds to methods S1, S2, and S5 in the aforementioned API processing methods. The cache management module corresponds to methods S3 and S5 in the aforementioned API processing methods. The rate limiting management module corresponds to methods S4 and S5 in the aforementioned API processing methods. Figure 4 The document also illustrates a possible third-party trading platform, the three management modules in the aforementioned API request processing system, and a detailed information interaction flowchart between the power trading center. This flowchart corresponds to the API request processing method described above, demonstrating the compliance and efficiency control process of this application for the entire process of API request acquisition to final response.
[0076] For example, taking the power trading center's rule that a maximum of two API requests can be initiated within a one-second time window, Figure 5 The diagram illustrates the processing sequence of the system when multiple API requests are received. For API requests that are not rate-limited, the system can directly forward them to the power trading center (e.g., API requests #A1 and #A2). For each rate-limited API request (e.g., API requests #A3 and #A4), the system accurately calculates its corresponding delay time and waits in sequence according to the initiation time. The system only initiates the API request to the power trading center after the previous API request has completed and the rate-limiting delay time has expired. This ensures the sequential and real-time processing of API requests, avoids concurrency chaos and illegal calls, and further resolves the contradiction between compliance and high-frequency calls.
[0077] This application also provides a computer-readable storage medium. Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing a processor. The program can be stored in a computer-readable storage medium, which is a non-transitory medium, such as random access memory, read-only memory, flash memory, hard disk, solid-state drive, magnetic tape, floppy disk, optical disk, and any combination thereof. The storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state drive (SSD)).
[0078] Figure 6 The diagram shown is a structural schematic of an electronic device according to an embodiment of this disclosure. Figure 6 As shown, the electronic device provided in this embodiment includes a processor and a memory. The memory is configured to store an executable program. The processor is configured to execute the program to cause the electronic device to perform a method for processing API requests according to any of the preceding claims.
[0079] Preferably, the processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0080] This embodiment also includes one or more of the following: multimedia components, input / output (I / O) interfaces, and communication components.
[0081] The multimedia component may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is configured to output and / or input audio signals. For example, the audio component may include a microphone configured to receive external audio signals. The received audio signals may be further stored in memory or transmitted via a communication component. The audio component also includes at least one speaker configured to output audio signals. The I / O interface provides an interface between the processor and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. The communication component is configured to enable wired or wireless communication between the timer and other devices. Wireless communication may include Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination thereof; therefore, the corresponding communication component may include a Wi-Fi module, a Bluetooth module, or an NFC module.
[0082] This application provides a method, system, storage medium, and electronic device for processing API requests, which have the following advantages:
[0083] 1. By monitoring the initiation time and data type of API requests through the time period management module or the first processing module of the system, and by monitoring the calling frequency of API requests through the rate limiting management module or the third processing module, and by delaying API requests that exceed the limit, it is ensured that each API request complies with the calling specifications of the power trading center, thus guaranteeing compliance.
[0084] 2. The cache management module or the second processing unit identifies API requests with the same parameters based on the unique identifier of the API request, and directly returns the call data corresponding to the API request in the cache to the third-party trading platform, avoiding redundant and duplicate API request calls and improving the overall throughput and response efficiency of the system.
[0085] 3. The cache management module only stores the call data of successfully responded API requests and their corresponding unique identifiers. This avoids duplicate storage of API requests with the same parameters and eliminates the need to store the entire dataset, thereby reducing the consumption of network bandwidth and computing resources and lowering system operating costs. Simultaneously, the cache management module automatically cleans up stored data within the expiration time window, ensuring that the stored data is always the latest and most valid. This not only effectively prevents old data from interfering with trading decisions but also makes the output data stream more stable, thus meeting the real-time data needs of multiple modules such as the trading decision engine, market data display, and quantitative analysis, further optimizing service quality.
[0086] 4. Significantly enhanced system stability: The lightweight deployment of the front-end browser plugin eliminates the need for back-end server cluster support; at the same time, the cache management module stores only the necessary data within the current time window (such as the unique identifier of the API request and the corresponding call data, transaction time period, call count statistics, etc.), avoiding the accumulation of invalid data and reducing the risk of plugin lag and crashes.
[0087] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, or methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules / units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of apparatuses or modules or units may be electrical, mechanical, or other forms.
[0088] The modules / units described as separate components may or may not be physically separate. The components shown as modules / units may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules / units can be selected to achieve the objectives of the embodiments of this application, depending on actual needs. For example, the functional modules / units in the various embodiments of this application may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.
[0089] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0090] This application embodiment may also provide a computer program product comprising one or more computer instructions. When the computer instructions are loaded and executed on a computing device, all or part of the processes or functions described in this application embodiment are generated. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0091] When the computer program product is executed by a computer, the computer performs the method described in the foregoing method embodiments. The computer program product can be a software installation package; when the foregoing method is required, the computer program product can be downloaded and executed on the computer.
[0092] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.
[0093] The above embodiments are merely illustrative of the principles and effects of this application and are not intended to limit this application. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of this application. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in this application should still be covered by the claims of this application.
Claims
1. A method for processing API requests, characterized in that, The method is applied to a processing system that is communicatively connected to a power trading center and a third-party trading platform. Obtain the trading time period of the power trading center and the API requests of the third-party trading platform; The API request is processed in a first manner, the first processing including determining whether the API request is within the transaction time period; Based on the result of the first processing, the API request is processed in a second process, which includes determining whether there is a unique identifier corresponding to the API request among all the stored unique identifiers. Based on the result of the second processing, the API request is processed in a third process, which includes determining whether the API request exceeds the call limit specified by the power trading center within the current time window. Based on the results of the first, second, and third processes, the processing result of the API request is returned to the third-party trading platform.
2. The method for processing API requests according to claim 1, characterized in that, The first process further includes: If the API request occurs during the transaction time period, the second processing corresponding to the API request is triggered. If the API request is not within the transaction time period, the API request is processed in a fourth manner, which includes determining the data type of the API request.
3. The method for processing API requests according to claim 2, characterized in that, The fourth process also includes: If the data type corresponding to the API request is business data, the API request is rejected. If the data type corresponding to the API request is non-business data, the second processing corresponding to the API request is triggered.
4. The method for processing API requests according to claim 1, characterized in that, The second process also includes: If a unique identifier exists corresponding to the API request, the API request call data corresponding to the unique identifier is fed back to the third-party trading platform; If no unique identifier exists for the API request, the third processing step corresponding to the API request is triggered.
5. The method for processing API requests according to claim 1, characterized in that, The third process also includes: If the API request exceeds the number of calls specified by the power trading center within the current time window, calculate the delay time corresponding to the API request, and obtain the call data corresponding to the API request from the power trading center after the delay time has elapsed; If the API request within the current time window does not exceed the call limit specified by the power trading center, obtain the call data corresponding to the API request from the power trading center.
6. The method for processing API requests according to claim 1, characterized in that, The method further includes: Store the call data corresponding to all API requests within the current time window, as well as the unique identifier corresponding to each API request.
7. The method for processing API requests according to claim 1, characterized in that, The method further includes: During non-trading periods, send API requests to the power trading center to access non-business data; and / or After the current time window expires, the stored data within the current time window will be automatically cleared.
8. A system for processing API requests, characterized in that, A method for performing API request processing as described in any one of claims 1 to 7, comprising: The time management module is used to obtain the trading time period of the power trading center and to perform the first processing on the API requests to the third-party trading platform; The cache management module is used to store the call data corresponding to all API requests within the current time window and the unique identifier corresponding to each API request, and to perform the second processing on the API requests of the third-party trading platform. The rate limiting management module is used to perform the third-party processing on API requests from the third-party trading platform.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the method for processing API requests according to any one of claims 1 to 7.
10. An electronic device, characterized in that, The electronic device includes: A memory on which computer programs are stored; The processor, communicatively connected to the memory, executes the computer program to implement the method for processing API requests according to any one of claims 1 to 7.
Citation Information
Patent Citations
Access control method and device, processor and storage medium
CN112311782A
Interface data caching method, system and equipment based on Redis and medium
CN117668027A
Request processing method and device, computer equipment and storage medium
CN119226638A
Interface access control system and method
CN119670121A
Transaction request processing method and apparatus, and transaction transfer system
WO2022135158A1