How are Sanity API requests counted when querying multiple documents?

2 replies
Last updated: Jul 12, 2023
How do API Requests work? If I query 10 items, is that classed at 1 API Request or 10? Or is is more about how much data is returned? My sanity API Requests seem very high for what I am doing.
For example this query:

*[_type == "post"]
{ 
    title,
    description,
    colour,
    mainImage{
      asset,
      alt,
      "lqip": asset->metadata.lqip,
    },
  },
}
AI Update

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: true in 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:

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 thread
2 replies
Each query is a request, no matter what it includes, so your query of 10 items would be one API request (as would the example you posted).
That's great to hear, thanks!

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.

Was this answer helpful?