Skip to Main Content
Builder.io Ideas
Created by Ersin
Created on Oct 10, 2022

Return modelName with content API response

There are many cases where you might want to know the model name for a given Builder content item JSON. For example, if you have a function that takes some kind of Builder content item as input, then formats links one way or another based on whether it's a `page` or a `blog-post`. You’re not always handling content API response data right after making an API call, so you don’t always know which model you’re currently working with.

It would be nice for that reason if the content API responses included the model name.

Content API responses currently include the model ID, but not the model name. Problems with this:

- You can use the model id to look up the model name, but it involves an additional network request to the admin API.

- To boot, the admin API is GraphQL, which arguably is harder to work with for such a simple use case.

- Working with the model name is much more convenient and the norm anyway when using the various SDKs.

  • Attach files