npm.io
0.5.0 • Published 32m ago

@postfetch/core

Licence
MIT
Version
0.5.0
Deps
0
Size
211 kB
Vulns
0
Weekly
0

@postfetch/core

Zero-dependency typed core that turns Instagram, TikTok and YouTube post URLs into media files. Part of postfetch.

import { postfetch, download, archive, toResponse, PostfetchError } from "@postfetch/core";

const result = await postfetch("https://vt.tiktok.com/ZSxpHvCUM/");
for (const item of result.items) {
  console.log(item.kind, item.mime, item.url);
}

postfetch(url, options?) detects the platform and resolves its media into a typed PostfetchResult (URLs plus the headers needed to fetch them). It performs no side effects beyond the lookup — download, archive and toResponse turn the result into bytes or an HTTP Response.

  • PostfetchOptions{ fetch?: typeof fetch; preferredWidth?: number }. Inject fetch to unit-test resolvers offline.
  • Every request rotates a consistent browser/app fingerprint, so a fixed user-agent never gets the whole fleet blocked.
  • No runtime dependencies, no ffmpeg / yt-dlp, no cookies.

See the root README for the full API table, supported inputs and the fingerprint design.

Keywords