Streaming live at 10am (PST)

API Not exposing NULL fields, this is freaking terrible

As webflow have so many limitations, I’ve started to use the API. It recently came to my attention, that you can’t even trust the API, what is the reason of not exposing null fields from the CMS, that will result in the developer creating a model that can’t handle the entire call?

You cant create a model from the API response if there is one field that is not set in the API, why not expose that through the API as FieldName : NULL

On top of that, why is there no sorting by parameter supported in the API? ex. “api.com/collection/items?FIELDNAME=2

And why are you exposing the fields with Hypen “-”?

These are common things that are either a miss or in my opinion, should be fixed ASAP…

Also, Why do you only expose a MASTER KEY, that requires you to build a wrapper to not expose your key to the end user if doing a frontend API call solution, cause you are exposing the user to a key that they can use maliciously to destroy your entire site, just by deleting EVERYTHING.

Would it not be a good idea, to put rights to the key, so you can have a read only key? so you dont have to wrap entire instances.


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

@Brando Could you shed some lights on this, the frustration is shining through and I’m sorry for that.

I know you can get the model from /collections/collectionID, however you still cant depend on a null value if its not exposed.

Thanks for looking into our API and providing feedback :slight_smile: I think I can help clarify some design choices we made when building the API and what we are considering changing in the future.

You cant create a model from the API response if there is one field that is not set in the API, why not expose that through the API as FieldName : NULL

null is an explicit value which is different from undefined. If the data does not exist, it is undefined, not null. Changing the API to include the fields as null when they explicitly are not would end up breaking downstream apps in how they use the API. One of the goals of the API, is when you get data back from the server, you should be able to save that same data back without it modifying anything on the backend. If we were to rewrite the API response to include fields as null when they are really undefined, it would break this property of the API.

This really is a problem with JSON, as it does not provide a way to pass an undefined value - despite many languages (javascript included) having a distinction between undefined and null

Looking at the model structure as you mentioned is the best way to get the full structure of an item to determine which fields are not present on an individual item.

doing a frontend API call solution

The webflow API is not built for being called by the frontend, which is why, for example, it does not support CORS headers. Having said that, there has been a small amount of demand for a more flexible API that can be used on the frontend like this, with more granular permissions, and it is something we are thinking about.

And why are you exposing the fields with Hypen “-”?

Do you have an example? I’m not sure exactly what you mean by this?

Hope that helps clarify things!

2 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.