figmagic: Unable to connect to Figma API
Describe the bug Based on figmagic-example-master example. token and url variables read from .env, .figmaicrc or CLI --token or --url command parameters but errors out with “Error: Error: Error: Missing one or more of required arguments: “figmaToken”, “figmaUrl” when attempting to get data from Figma API!”. No issue connecting via Postman.
To Reproduce Scenario 1 - Using .env file :: Steps to reproduce the behavior:
- Navigate project folder where local version of figmagic was installed as dev dependency and add script to package.json
- create .env file with ‘FIGMA_URL’ and ‘FIGMA_TOKEN’ entries:
FIGMA_URL=XYX
FIGMA_TOKEN=XYZ
- run ’ npm run figmagic – --debug’
- see error “Attempting to fetch data from Figma API… Error: Error: Error: Missing one or more of required arguments: “figmaToken”, “figmaUrl” when attempting to get data from Figma API!”:
DEBUG:
_SYSTEM: Final user configuration that will be used..._
{...
token: 'XYZ',
unitlessPrecision: 2,
url: 'XYZ',
usePostscriptFontNames: false
}
Scenario 2 - Using .figmagicrc file (and no .env)
- Navigate project folder where local version of figmagic was installed as dev dependency and add script to package.json
- Run npm run figmagic init which creates the .figmagicrc file. Update file with ‘url’ and ‘token’ entries:
{
"templates": {
"templatePathGraphic": "./node_modules/figmagic/templates/graphic",
"templatePathReact": "./node_modules/figmagic/templates/react",
"templatePathStorybook": "./node_modules/figmagic/templates/story",
"templatePathStyled": "./node_modules/figmagic/templates/styled"
},
"token": "XYZ,
"url": "XYZ"
}
- run ’ npm run figmagic – --debug’
- see error “Attempting to fetch data from Figma API… Error: Error: Error: Missing one or more of required arguments: “figmaToken”, “figmaUrl” when attempting to get data from Figma API!”:
DEBUG:
_SYSTEM: Final user configuration that will be used..._
{
...
token: 'XYZ',
unitlessPrecision: 2,
url: 'XYZ',
usePostscriptFontNames: false
}
Attempting to fetch data from Figma API… Error: Error: Error: Missing one or more of required arguments: “figmaToken”, “figmaUrl” when attempting to get data from Figma API!
Expected behavior Connects successfully to the FIGMA API
Screenshots

Desktop (please complete the following information):
- OS: macOS 11.2.1
- Browser N/A
- Version [e.g. 22]
Additional context https://github.com/mikaelvesavuori/figmagic/issues/88#issuecomment-770176151 mentions “Your attempt at running npm run figmagic --token {token} --url {url} will not work since you use a local install. You should try node ./node_modules/figmagic/build/index.js --token {token} --url {url} which will work just fine (this is also documented in the Figmagic example repo’s package.json; obscure but true).”.
The above does not seem to be clearly documented. With no .env or .figmagicrc and simply running node ./node_modules/figmagic/build/index.js --token XYZ --url XYZ – --debug gives the same results.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 27 (15 by maintainers)
Perfect. I will look at releasing an update of some sort tomorrow.
That worked perfectly! Could you publish that version?
Thanks a bunch for looking into this!
I tried with node v14 and got the same error.
Note (same results as with 12): Removing the config file and just using the .env file with the token and url set, I get the following: Error: Error: Error: Missing one or more of required arguments: “figmaToken”, “figmaUrl” when attempting to get data from Figma API!
If I use the generated config file with the token and url added I get: Error: Error: Could not retrieve any data. Are you missing a valid API key?
Thanks Mikael - I’ve gone through the initiation as per your instructions and can’t fault it this time. I appreciate you taking the time to respond what I thought was an issue, however it was obviously something I’d done! I’ll compare branches tomorrow and work out where I went wrong.