✨Discover storytelling in the AI age with Pixar's Matthew Luhn at Sanity Connect, May 8th—register now

High number of API requests during site migration, looking for help and guidance.

5 replies
Last updated: Feb 9, 2024
Hi all, I have been working on a site migration (around 150 pages) and it's almost ready to go live. I have noticed however that this month we've used 62,000 API requests while filling in the content and in development. I can't help but feel this is a lot considering the site is not getting any visitors yet? Can anyone help me out? I've checked all my useEffects and I don't have a rogue one anywhere. I also noticed that making a single change in the studio causes a request - I read that these don't count towards my monthly quota, but could this be the cause?
Jan 22, 2024, 11:13 AM
Can you share more details about your build?
Jan 22, 2024, 11:16 PM
it uses the next personal website starter, the project id is ibl2iujd if that helps!
Jan 23, 2024, 2:12 AM
user M
any ideas? I don't want to launch this site if it's going to run out of requests so quickly - it already gets some decent traffic on the old wordpress build.
Jan 24, 2024, 9:39 AM
Hello User!Sorry for the slow response here! I will share some more insights (about bandwidth etc.) with you later.
Indeed in-studio requests do not count against bandwidth, only request being done from outside the studio are counted.

My gut feeling tells me tho, that you have either or all of these things causing in-studio requests being counted:
• Maybe You are using the front-end configured client in the studio, not the client passed down in the contexts (like the configContext or in the structure) or through the useClient hook
Definite reasons I can see the logs:
• Images being requested in their original quality and not optimised
• On the 22nd of Jan you also downloaded a lot (if not all) images from Sanity in their original quality and size thats basically the most effective culprit…
You can have a look yourself. All request urls with sanity tags at the end do not count against your BW, So filter them out.
One day I added in particular is Jan 22 just to let you see how those things look in detail.

In general your ways forward:
Query optimisation , optimising Images (use the image-url package and use the amazing image pipeline we offer) and I would also implement some static sites and using the API CDN if you have a lot of traffic 🙂We have some
amazing guides and docs on our site and you can check your front-end frameworks docs for more as well … Hope that helps!
Feb 8, 2024, 2:05 PM
Hi User,
Thank you for your help, this is all really useful. Just to confirm the reason for the high number of requests (aside from the image requests) is that the in-studio requests were being counted? Even though they’re showing in the manage project area? Could you point me in the direction of how I could configure it to use the front-end client passed down?

I will work through the other things you mentioned as well - once again thank you for your help!
Feb 9, 2024, 6:53 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?