0.2.3 • Published 5 months ago

@victr/suggestions v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

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 /
ParameterRoleRequirement
qSearch queryrequired
lLocalizationoptional
withSearch provideroptional

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
0.2.3

5 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago