Streaming live at 10am (PST)

API - Querying Reference Field

Hi All! So I am trying to use the API to query items in a collection. However I know that the items that I would need are only a subset of the entire items in the collection. So in order for me to get all the items I am querying for, I need to get back ALL items and filter them out on my end. The API seems like it only provides methods for querying a single item from a collection or querying ALL items in a collection. Is there a way to query a subset of items in a collection based upon some sort of reference ID?

For example if I had 2 collections: users, favorite_songs. The favorite songs collection would contain all the favorite songs from each user. But if I had thousands of users and each had about 10 favorite songs, that means I would have to loop through 10,000 items just to retrieve the 10 I really needed. I should be able to query the favorite_songs collection by the user_id referenced in the users collection.

Is this scenario possible via the API? I can’t imagine that Webflow would be able to scale their customers sites without doing this in their own backend, so why is this not available via the API?

Thanks!

Nope. First of all there is no “User” entity or management. As for the data, you could suck all the CMS content, store it in a noSQL data store, then wire up GraphQL and you would be set. Consuming what you need in Webflow from your own system. Problem is if you ever did a restore you would loose the relationship between items across systems. There are rate limits that seriously impede workflows as well. The API needs some love that it may never get. I’m not holding my breath on that.

IMHO, I think you would be much better of just using Webflow as a design tool and relying on a more robust CMS that does not have these limitations. Just leave the WF animations out of the design and add them back (if you needed them) with GSAP or your fav toolbox. It is much more maintainable that way.

Other then that Webflow is way cool and perfect for many site types.

1 Like

Thanks for the feedback, and I understand your workaround solution. So just to be clear, WebFlow does NOT allow to query within a collection based on reference IDs? But I would be very surprised if they did not do this within their own site.

We already have a pretty tied in to WebFlow so exporting all that data out and how everything is designed would be like starting all from scratch. So not something that we want to do. The frontend facing webpages that we have, would still be shown via the webflow system, URLs, etc. However we are wanting to build a backend where people can manage their own data. And in the example I gave, in order for them to manage their ‘favorite_songs’, I would have to call WebFlows API 100s of times just to possibly get the 10 items I want. Where if WF allowed to query within a collection I’d have to call their API just once.

This just makes no sense that WF does not have this capability. With just that small example I gave, if all their clients were doing something like this, it would provide massive benefit to just WF alone.

Why do they not have this capability?

This is correct. The API is quite terrible to be honest. I have to do 70 calls to the API just to list all my blog posts, then fetch what I need from it.

@gabegunlock - Gabe I would point you directly to the API docs. You have two choices… Get all, or get single. When you do a get all you are limited to 100 and then you can offset another call to get another 100. Problem is the rate limit kicks in too so you have to throttle your calls. (there are topics in the forums).

https://developers.webflow.com/#get-all-items-for-a-collection

https://developers.webflow.com/#get-single-item

Don’t know. It’s lame. I suspect it is easier to serve the nocoders.

Yeah, thanks for the feedback. I understand the workarounds for this. This is just weird, because this actually puts a lot of load on the WebFlow backend that is unnecessary. They would be able to scale out so much more if they allowed querying into a collection.

So I guess my next question is that, using their frontend ‘flow’, my pages are displaying items in a collection that belong to one user. So is WF actually looping through their collections unnecessarily, or are THEY allowed to query into a collection?

Thanks guys for all the feedback!

Webflow only queries a collection to build the page and its children on publish. Everything is static cached.