Designer API v2 – Variable Methods Not Working

We want to use variables on the Designer API, but they are not working. In the official documentation, there are three functions to get all variable collections: by name or by ID. However, none of them are working and throw a ‘is not a function’ error. Additionally, one of the methods only retrieves the default collection, but this is not sufficient for our needs.

Here is the link to the methods that aren’t working: https://developers.webflow.com/designer/reference/variable-collections-overview#selecting-a-collection. Also, here is a screenshot of it:

Here I am calling the methods in the app, but they are not resolving:

Hi @az_benjamin - can you confirm if you have apiVersion: "2" set in webflow.json?

Additionally, in order to use the Designer APIs in the console, your console must be focused on the Designer Extension.

Here’s a quick way to focus the console on the DE - https://youtu.be/rfEkIB0_ZDA?feature=shared&t=1125

Yes, I do have the v2 version in the webflow.json file:

{
  "name": "name",
  "publicDir": ".name",
  "size": "default",
  "apiVersion": "2"
}

Yes, I do focus on the iframe, and when I call other methods, they work fine.

@zachplata, @victoriaplummer, the documentation does not mention the modes. In addition to collections, can we include the modes? The current API shows the first mode’s variable references.

Hey @az_benjamin it’s possible the script that Webflow injects into your Designer Extension App is still not injecting a v2 API script for some odd reason. This is rare, but has happened in some cases. By chance are you using Vite for your App? If you feel comfortable, feel free to also DM the bundle and we can try to run it locally to see if we can repro. I can confirm that these APIs should still be functional in production today, so happy to take a look if needed.

@zachplata Yes, we are using Vite, but I found the issue. For some reason, the Webflow package locally in the project was outdated, and I upgraded the global package, which didn’t reflect because the local one was still old.

Besides that, regarding the methods on the variables side, we are able to fetch the collections and variables inside but not the modes. Are you guys working on this? Is there a way to access them in the current version?

@az_benjamin - this is being worked on :eyes:

We post our updates here regularly:
https://developers.webflow.com/data/changelog

1 Like