Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Figma API — Get an svg node (via /images endpoint)
const ACCESS_TOKEN = "token";
const FILE_ID = "fileId";
const NODE_ID = "Check the url for something like => 3%3A2";
const container = document.getElementById("figma-container")
function apiRequest(url) {
return fetch(url, {
method: 'GET',
headers: { "x-figma-token": ACCESS_TOKEN }
}).then(function(response) {
return response.json();
}).catch(function (error) {
return { err: error };
.then(({ imagesMap }) => {
// returns an object with node id as key
// and value of an s3 link to the svg file
const svgUrl = imagesMap[decodeURIComponent(NODE_ID)][0];
fetch(svgUrl).then(res => {
return res.text();
}).then(svg => {
container.innerHTML = svg;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.