Skip to main content
Credits

Allocate API and WebSocket credits wisely with the right plan and flexible pricing.

Team avatar
Written by Team
Updated over 2 weeks ago

Credits are the core metric used to access data on our platform. They can be of two types API credits and WebSocket credits.

API

Each API endpoint has a defined data weight indicating the credits consumed. Our flexible credit system ensures efficient and timely access to Twelve Data. API credits reset every minute, with no hidden data weights unless explicitly stated in the documentation.

For instance, if you access /time_series data for AAPL, MSFT, and TSLA - you would consume a total of (1 credit) * (3 symbols) = 3 credits. If you want to retrieve /income_statement for the above three stocks, you will consume (100 credits) * (3 symbols) = 300 credits.

WebSocket

WebSocket shares the same idea about weights as the API, however, in a slightly different manner. Each WebSocket method has its subscription weight, consumed when subscribing to the symbols data stream.

For example, we take /quotes/price endpoint, which returns real-time tick price. It has a data weight of 1 WebSocket credit per successfully subscribed symbol. By subscribing to the AAPL,INFY,TRP,QQQ,IXIC,EUR/USD,USD/JPY,BTC/USD,ETH/BTC - only 9 WS credits are consumed.

Which plan is right for me?

First, determine if your application will require the API, WebSocket, or both. Next, review the documentation to identify the necessary endpoints.

Certain endpoints and features are available only with specific plans. For example, /profile data is accessible with the Grow plan, /balance_sheet with the Pro plan, and /institutional_holders with the Enterprise plan. Select the plan that best aligns with your specific needs.

API consumption can be calculated using the following formula:

Data Weight × Number of Symbols = Credits Used per Endpoint per Minute

Apply this formula to each endpoint you plan to use, then sum the total credits to estimate the maximum API consumption. This approach helps you anticipate your credit usage effectively.

Running out of credits

API

If you run out of API credits, a 429 error code will notify you that the API credits limit has been reached. Your full API credit quota is restored at the start of each new minute. For example, on the Pro 610 plan, if you use 555 API credits by 16:59:58, your quota of 610 API credits per minute will reset at 17:00:00.

The same principle applies to daily limits on the Basic plan, where the quota resets to 800 at midnight UTC (00:00:00). However, paid plans have no daily limits.

WebSocket

When you run out of WebSocket credits, you won't be able to subscribe to new events until you either reset all subscriptions or partially unsubscribe from existing ones. There are two possible statuses in such cases:

  1. Warning: Indicates partial success, where some symbols were successfully subscribed within the remaining limit, while others failed due to exceeding it.

  2. Failed: Occurs when no symbol tickers can be successfully subscribed.

Lastly, if you attempt to open more connections than the default limit of 3, the system will automatically close the earliest connections to accommodate new ones. For example, opening a 4th connection will close the 1st, and opening a 4th and 5th will close the 1st and 2nd connections, respectively.

Best practices

  • Each API request returns api-credits-used and api-credits-left in response headers. There are also other ways to control your API usage; check them in this article.

  • Anticipate the number of credit usage and choose the right plan.

  • Store data for less frequently updated endpoints, such as /stocks on the client side.

Check out documentation before getting started to see the weights of each endpoint. If you need more credits or access to premium endpoints, you may upgrade your plan here.

Pricing credo

Twelve Data's mission is to organize the world's financial data and make it universally accessible. Our goal is to become the go-to platform where everyone—from individual traders to major institutions—can find all their financial data needs. However, the value of data varies; for instance, accessing a company's logo is far simpler than obtaining details about its fund holders.

The API credit system, with minute-based quota allocations, ensures the highest level of transparency and ease of use across all endpoints—all within a single subscription. Data weighting reflects the cost of maintaining the data and the frequency of updates. Some datasets are readily available in convenient formats, while others require extensive effort to standardize. Similarly, certain endpoints update every minute, while others refresh hourly. These factors collectively determine data weighting.

Thank you for supporting our mission!

Did this answer your question?