aboutsummaryrefslogtreecommitdiff
path: root/src/utils/get-youtube-suggestions-for.ts
blob: 11977e45e1b99386055b9e1992cd068484f2f47a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import got from 'got';

const getYouTubeSuggestionsFor = async (query: string): Promise<string[]> => {
  const [_, suggestions] = await got('https://suggestqueries.google.com/complete/search?client=firefox&ds=yt&q=', {
    searchParams: {
      client: 'firefox',
      ds: 'yt',
      q: query,
    },
  }).json<[string, string[]]>();

  return suggestions;
};

export default getYouTubeSuggestionsFor;