@victr/suggestions

0.2.3 • Public • Published

Search Suggestions API

An API that parses search suggestions from a number of search providers. Might not live very long depending on the volatility of their APIs. Here's the list of available search providers:

  • Google ( w/ presentations )
  • Yahoo ( w/ presentations )
  • Bing ( w/ presentations )
  • Duckduckgo
  • Qwant

Try it here: https://suggestions.deno.dev/

How to use

Endpoint

GET /
Parameter Role Requirement
q Search query required
l Localization optional
with Search provider optional

Response

type Response = {
  text: string
  desc?: string // when presentation is available
  image?: string // when presentation is available
}[]

Websockets

Using Clouflare workers, you can also get results using websockets.

const socket = new WebSocket('ws://localhost:8787')

socket.onmessage = function (event: MessageEvent) {
  console.log(JSON.parse(event.data))
}

socket.send(JSON.stringify({ q, with, lang }))

Examples

GET /?q=can%20we%20go%20to
[
  { "text": "can we go to heaven with tattoos" },
  { "text": "can we go to mars" },
  { "text": "can we go to saturn" },
  { "text": "can we go to your room now" }
]

GET /?with=google&q=vercel&l=fr
[
  {
    "text": "vercel"
  },
  {
    "text": "vercelli",
    "desc": "Verceil — Ville en Italie",
    "image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQID9TX_tSffwg1RLvecGtuPHMZWbbEOSx0d6_poXT6bqChYkEazWYz6G1ilQ&s=10"
  },
  {
    "text": "vercel villedieu le camp",
    "desc": "Commune en France",
    "image": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQGB1DiSdJxQgJfHphVKCfENgDCeGWobdbBpErowNFfDEExoFTuRmmPfEVJuQ&s=10"
  },
  {
    "text": "vercel pricing"
  },
  {
    "text": "vercel deploy"
  }
]

Install

First clone this repository.

Netlify

npm install netlify-cli -g

# On port 8888
netlify dev

Cloudflare Workers

npm install wrangler -g

# On port 8787
wrangler dev

wrangler deploy

Readme

Keywords

none

Package Sidebar

Install

npm i @victr/suggestions

Weekly Downloads

2

Version

0.2.3

License

MIT

Unpacked Size

8.71 kB

Total Files

4

Last publish

Collaborators

  • victr