Integration guides

Pagination and filters

Retrieve all pages of links and combine search with per-person filters.

Use pagination in List links to retrieve large collections without requesting every link in a single response. Each request returns one page and the total number of matching results.

Choose a page size

Set pagina to a page number starting at 1 and por_pagina to a value between 1 and 100. The default is 20 items. For batch retrieval, 100 items per page reduces the number of requests.

Retrieve all results

  1. Request page 1.
  2. Read the links in dados.itens.
  3. Request the next page while pagina × por_pagina is less than dados.total.
  4. Also stop if itens is empty.

This example runs on your server in Node.js with fetch available and reads the token from PQNO_TOKEN:

const links = new Map();
for (let pagina = 1; ; pagina++) {
  const url = new URL('https://pqno.app/admin/api/encurtar-link/meuslinks');
  url.search = new URLSearchParams({ pagina: String(pagina), por_pagina: '100' });
  const resposta = await fetch(url, {
    headers: { Authorization: `Bearer ${process.env.PQNO_TOKEN}` }
  });
  const json = await resposta.json();
  if (!resposta.ok || json.status !== 'ok') throw new Error(json.mensagem);
  const { itens, total, por_pagina } = json.dados;
  for (const link of itens) links.set(link.id, link);
  if (itens.length === 0 || pagina * por_pagina >= total) break;
}
console.log([...links.values()]);

Combine search and person filters

Use busca to search the title, destination, and code. On Business, a company token also supports usuario, using the ID returned in criado_por.id or Account summary.

Keep the same filters on every page. Use URLSearchParams or your language's equivalent to encode spaces, accented characters, and other search text.

Handle changes during retrieval

New links are added to the beginning of the list and can move items between pages. The example uses each link's ID as a key to avoid duplicates. For ongoing synchronization, retrieve the list periodically and update records by ID.

Each page counts as one request. Monitor the headers in Usage limits and follow Retry-After if you receive HTTP 429.