Search Brazilian tenders in Google Sheets with EditalMD
A sheet function lists the open tenders for a term, with deadline, agency and link.
Updated
1Open Apps Script
In the sheet, open Extensions, Apps Script, and delete the sample code.
2Paste 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,
]);
}3Use it in the sheet
Type =EDITALMD_BUSCA("computador"; "SP") in a cell. The first time, allow internet access.