How are Sanity API requests counted when querying multiple documents?
API requests in Sanity are counted per HTTP request, not per document returned. So if you query 10 items with *[_type == "post"], that counts as 1 API request, regardless of how many documents match the query or how much data is returned.
How API requests are counted
Each time you make an HTTP call to Sanity's API endpoints, it counts as one API request. This includes:
- GROQ queries (via
/data/query) - GraphQL queries
- Document mutations
- Asset uploads
- Any other HTTP request to the API
The number of documents returned, the size of the response, and the complexity of your query don't change this — it's still one request per HTTP call.
Why your requests might seem high
If your API request count seems unexpectedly high, here are common causes:
1. API vs API CDN usage
- The API CDN (
apicdn.sanity.io) caches responses and can significantly reduce request counts - The uncached API (
api.sanity.io) counts every single request - Make sure you're using
useCdn: truein your client configuration for front-end queries
2. Studio requests
- Sanity Studio makes many API requests as you work (loading documents, previews, etc.)
- These all count toward your usage
3. Real-time listeners
- If you're using real-time features or listeners, these create ongoing connections
4. Multiple queries in your application
- Each separate GROQ/GraphQL query is a separate HTTP request
- If your page makes 5 different queries, that's 5 API requests
5. Build-time requests
- Static site builds that fetch all your content can generate many requests
- For example, fetching data for 100 pages = 100+ requests during build
Monitoring and optimizing
To understand your usage better:
- Check your project usage dashboard to see request patterns
- If you're on an Enterprise plan, you can enable request logs for detailed analysis
- Consider using request tags to categorize and track different types of requests
For your specific query, that's just 1 API request — but if you're running it frequently (like on every page load without caching), those single requests add up quickly!
Show original thread2 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.