Tool Template

Firecrawl Search

by Webble Templates

Use Template
/**
 * @param {object} args
 * @param {string} args.apiKey The base URL to start crawling from
 * @param {string} args.query The search query
 * @param {number} args.limit The max number of results from the search
 * @param {string} args.location Location parameter for search results
 * @param {string} args.timeout Timeout in milliseconds


 * @param {boolean} args.ignoreInvalidURLs
 * @param {string} args.tbs Time-based search parameter
 */
async function main(args) {
  let { apiKey, ...payload } = args;
  
  if(!args.limit) args.limit = 5;
  if(!args.timeout) args.limit = 60000;

  const headers = {
    "Authorization": `Bearer ${apiKey}`,
    "Content-Type": "application/json"
  }

  const scrapeOptions = {
    formats: ["markdown"]
  }

  const result = await fetch(`https://api.firecrawl.dev/v1/search`, {
    headers,
    method: "POST",
    body: JSON.stringify({ ...payload, scrapeOptions })
  })
    .then(response => response.json())
    .catch(err => console.error(err));

  return { output: result };
}

Want to see more chatbot templates and resources?

View more templates