Skip to content
mirere-tsPublic

About

Fully typed TypeScript SDK for the 4get search engine API

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

4get SDK

Fully typed TypeScript SDK for the 4get search engine API. Zero runtime dependencies — uses native fetch.

Install

npm install 4get-sdk

Requires Node 18+ (or any runtime with fetch).

Usage

import { FgetClient } from "4get-sdk";

const client = new FgetClient("https://4get.ca");

const results = await client.web({ s: "higurashi", extendedsearch: true });
for (const hit of results.web) {
  console.log(hit.title, hit.url);
}

// Next page — npt alone suffices, do not resend `s`
const page2 = await client.web({ npt: results.npt! });

const pics = await client.images({ s: "higurashi", nsfw: "no" });
const clips = await client.videos({ s: "higurashi", sort: "upload_date" });
const headlines = await client.news({ s: "higurashi" });
const tunes = await client.music({ s: "higurashi", type: "track" });
const suggestions = await client.autocomplete("higurashi");

const meta = await client.ami4get(); // instance info, version, instance list

Pass tokens

Instances with bot protection require a pass cookie (from solving the captcha):

const client = new FgetClient("https://4get.ca", "your-token");

URL helpers

client.favicon("https://lolcat.ca");                        // /favicon?s=...
client.proxy("https://example.com/pic.png", "square");      // /proxy?i=...&s=square
client.audioUrl("sc", "https://api-v2.soundcloud.com/..."); // /audio/sc?s=...

For audio proxying, honor SongResult.stream.endpoint: "linear" (or null) means a plain HTTP stream; anything else must be proxied via audioUrl.

API

All search responses are typed (WebResponse, ImagesResponse, VideosResponse, NewsResponse, MusicResponse). Every response carries status (throws FgetError unless "ok") and npt (pagination token, null when no more pages). Most fields can be null — the types reflect that.

Test

npm test   # runs against $FGET_INSTANCE (default http://localhost:8888)

Terms of use

Respect the 4get API terms — cache responses, don't scrape intensively, and don't use it for SERP SEO.

About

Fully typed TypeScript SDK for the 4get search engine API

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages