# Search Brazilian tenders in Google Sheets with EditalMD

A sheet function lists the open tenders for a term, with deadline, agency and link.

EditalMD · Updated 2026-10-14

## Step 1. Open Apps Script

In the sheet, open Extensions, Apps Script, and delete the sample code.

## Step 2. Paste the function

Paste the function and save.

```
/**
 * Licitações abertas por termo, do EditalMD. Uso: =EDITALMD_BUSCA("computador"; "SP")
 * @customfunction
 */
function EDITALMD_BUSCA(termo, uf) {
  let consulta = "q=" + encodeURIComponent(termo) + "&abertas=1&limite=20";
  if (uf) consulta += "&uf=" + encodeURIComponent(uf);
  const resposta = UrlFetchApp.fetch('https://editalmd.com/api/busca?' + consulta, { muteHttpExceptions: true });
  if (resposta.getResponseCode() !== 200) return "HTTP " + resposta.getResponseCode();
  return JSON.parse(resposta.getContentText()).itens.map((c) => [
    c.encerramento_proposta, c.orgao, c.objeto, c.compra_url,
  ]);
}
```

## Step 3. Use it in the sheet

Type =EDITALMD_BUSCA("computador"; "SP") in a cell. The first time, allow internet access.

[Open the search](https://editalmd.com/en/?q=computador&abertas=1)

[Search Brazilian tenders in Google Sheets with EditalMD](https://editalmd.com/en/guias/google-sheets)
