Counting CDA API calls

Hello,

I’m hoping someone can help me to get a handle on how the CDA API calls are calculated. For starters, we are using GraphQL to fetch our content so this should count towards CDA API calls?

As an example scenario, I have a blog article that has some fields like title, slug, etc that are part of the Blog model as well as an image. There is also Social content associated with the Blog article. This model also has 4 modular blocks of content, each of which are used in this Blog article. In addition, there is an Author model and one of the Author records is associated with the Blog article. Finally, there is a Tag model and 2 tags are associated with the Blog article.

Below is an example of the GraphQL call:

fragment AuthorDetail on AuthorRecord {
  name
  title
  description
  email
  photograph {
    url
  }
}

fragment TagsDetail on BlogArticleTagRecord {
  title
  secondaryNavigation
}

fragment Social on SeoField {
  title
  description
  image {
  	url
  }
}

fragment Body on BlogArticleModelBodyField {
  ...on RichTextRecord {
    id
    _modelApiKey
  	richText
  }
  ... on WistiaIdRecord {
    id
    wistiaId
    _modelApiKey
  }
  ... on BlockquoteRecord {
    id
    blockquote
    _modelApiKey
  }
  ... on AppButtonRecord {
    id
    appButton
    _modelApiKey
  }
}

fragment BlogArticle on BlogArticleRecord {
	id
  author {
    ...AuthorDetail
  }
  tags {
    ...TagsDetail
  }
  social {
    ...Social
  }
  title
  slug
  description
  body {
    ... Body
  }
  date
  doNotShowOnIndexPage
}

{
  allBlogArticles(orderBy: date_DESC, first: "1") {
    ...BlogArticle
  }
}

Would the count of CDA calls be as follows:
Blog - 1 call
Modular content - 4 calls
Author - 1 call
Tags - 1 call
Social - 1 call

Total 8 calls as I assume this doesn’t all get lumped together as 1 call? Is this correct and also do images count as an additional part of the calls? Is there a way in the API Explorer to display how many calls you are using?

Also, for fetching content, will it almost always be hitting the CDN cache as I see the docs mention that an unlimited number of calls can be made. When would we not be hitting the cache? Only once for new records or once for updated content. Is everything on the preview GraphQL endpoint also hitting the cache or is that never cached so always counts towards the API call limit?

Thanks,
Jeff

@jeff.knox your example counts as one API call.

One API call is a single POST request to our graphql.datocms.com endpoint. Hope this clarifies!

1 Like

Thanks for the quick reply @mat_jack1, that’s much simpler than I thought! I’d seen other headless CMSs that split up one call into multiple depending on how many other resources are being requested.

With regards to CDN caching, if I make that call 3 times does that count as 3 calls or is that hitting the CDN cache on subsequent calls and therefore only counts as 1? Just wanted to double check after reading this documentation. Thanks

We don’t enforce limits on the cache hits, but we count them as API calls.

So 3 cached calls will count as 3 API calls.