Optimizing API usage
API rate limits are designed to reduce the load on the API and help maintain optimal performance. By following the tips outlined below, you can monitor and optimize your usage to avoid hitting those limits.
Monitor your usage
Analytics dashboard
The API analytics dashboard monitors your API usage and tracks your account's daily usage, trends, and top contributors.
You can use this data to:
- Detect sudden spikes: Spikes can be one indicator of a bug in an application. Bugs can cause the app to consume a disproportionate amount of the API budget.
- Evaluate app usage: Sometimes, apps are no longer used but continue to run and use your API budget. This is often the cause of high API usage in companies with many applications. You can use these insights to evaluate which apps are consuming your API budget and determine whether or not they're still required.
The analytics dashboard is only available for Enterprise accounts.
Maintain logs
Maintaining detailed logs of your API calls allows you to understand the cost of each and track your remaining budget. This data helps with resource allocation and ensuring you don't reach the limits.
Here are some key points to log:
- Complexity cost of the query
- Remaining budget for API calls
- Structure of the query (e.g., the fields requested, filters applied)
- Instances when your app hits the per-minute limit
Evaluate your use case
Consider evaluating whether the monday.com platform API is the right tool for your use case. Keep in mind that monday.com excels as a work management tool, not as a high-frequency database.
Optimize your calls
Implement pagination
Pagination divides your results into smaller sets of data called pages, instead of returning everything at once. You can then utilize cursor-based pagination or the page
argument to return data from subsequent pages. Doing so helps you avoid consuming a disproportionate amount of your API budget while reducing the load on the API and improving response time.
Example: Instead of returning 10,000 items in your call, use cursor-based pagination to return 200 items over 50 calls.
Please note that some queries don't support cursor-based pagination or the page
argument. Consult our API reference documentation to read more about each query and what it supports.
Use the change_multiple_column_values
mutation
change_multiple_column_values
mutationIf you need to modify more than one column value, use change_multiple_column_values
mutation instead of multiple change_simple_column_value
mutations. This reduces the number of calls and improves efficiency.
Simplify your calls
Each call has an associated "cost" that correlates to the load put on the API, also known as the complexity cost. By simplifying your queries, you can reduce their complexity to avoid hitting the complexity limit.
- Requesting only the data you need
- Reducing nested queries
- Utilizing the
page
andlimit
arguments - Filtering your results
You can also calculate the complexity of each query in advance to avoid hitting the limit. The simplest way to do so is by adding the complexity field to your queries to return the remaining complexity before and after the query, the complexity of the query itself, and when the limit resets.
mutation {
complexity {
query
before
after
}
create_item(board_id:1234567890, item_name: "test item") {
id
}
}
Avoid unnecessary calls
Errors, rate limit responses, and unsuccessful calls all contribute to your daily call limit. You can avoid wasting these calls by retrying your calls only after the required amount of time and properly handling errors.
Example: If you hit the minute limit, utilize the
Retry-After
header to determine how long you need to wait before retrying your call.
Employ fragments
GraphQL is a flexible query language that allows you to only request the information you need in your query. This is done through components like arguments, fields, and fragments.
Example: Certain objects, like
column_values
, utilize fragments to return column-specific data, ultimately making your query more efficient.
Improve your app's efficiency
Utilize webhooks
If your app needs to respond to changes in monday, use webhooks to receive live alerts. Webhooks are more efficient than periodically polling the API since you will only make API calls as needed.
Please note that webhooks have their own limits (e.g., integration action limits), so it's crucial to strike a balance between webhooks and API usage.
Implement caching
Consider implementing caching for repeated reads of the same data where live updates aren't critical. This reduces the number of API calls, improves performance, and optimizes your usage.
Updated 3 days ago