Integration guides
Save a QR code image
Decode the base64 response to save the PNG or SVG file and display the image.
Generate a QR code returns the image in dados.imagem_base64. Check that the request succeeded, then decode this field to use the image.
Generate and save the file
This example runs on your server in Node.js with fetch available. Save it as gerar-qr.mjs, set PQNO_TOKEN, and run node gerar-qr.mjs:
import { writeFile } from 'node:fs/promises';
const resposta = await fetch('https://pqno.app/admin/api/encurtar-link/gerarqrcode', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PQNO_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ conteudo: 'https://pqno.app', formato: 'png', tamanho: 1024 })
});
const json = await resposta.json();
if (!resposta.ok || json.status !== 'ok') throw new Error(json.mensagem);
const imagem = Buffer.from(json.dados.imagem_base64, 'base64');
await writeFile(`qrcode.${json.dados.formato}`, imagem);
The file is saved as qrcode.png in the current directory. To generate SVG, set formato to svg; the same decoding step saves qrcode.svg.
Display the image on a page
You can serve the saved file using the media type in dados.mime, or build a data URL on your server:
const src = `data:${json.dados.mime};base64,${json.dados.imagem_base64}`;
Use src as an image's src attribute. Keep the authenticated API request on your server to protect the token.
Use a short link for editable destinations
When you generate an image using link_id or a short URL in conteudo, the QR code uses the link's redirect. You can then change the destination with Update a link while keeping the link code.
If conteudo contains the destination URL directly, that URL is embedded in the image. Generate a new image to change its content.
Test scanning
Open the generated file, scan it with a phone camera, and check the destination before printing or sharing. Handle errors and limits as described in Responses and errors.

