nb-scraper
Version:
Community scraper library by Newbie Scrape
1,975 lines (1,946 loc) • 68.9 kB
text/typescript
/**
* @fileoverview Type definitions for NB Scraper
* @author ErRickow
* @version 1.1.5
*/
/**
* Standard response structure for all scraper functions
* @template T - The type of the data property
*/
interface NBScraperResponse<T = unknown> {
/** The creator/author of this scraper */
creator: string;
/** Whether the operation was successful */
status: boolean;
/** The scraped data (only present when status is true) */
data?: T;
/** Error message (only present when status is false) */
error?: string;
}
/**
* Configuration options for HTTP requests
*/
interface RequestConfig {
timeout?: number | undefined;
headers?: Record<string, string> | undefined;
retries?: number | undefined;
retryDelay?: number | undefined;
}
interface AnyDownloadMedia {
url: string;
quality: string;
extension: string;
size: number;
formattedSize: string;
videoAvailable: boolean;
audioAvailable: boolean;
chunked: boolean;
cached: boolean;
}
interface AnyDownloadResult {
title: string;
duration: string | null;
thumbnail: string;
downloadUrls: AnyDownloadMedia[];
}
interface AnyDownloadResponse {
input_url: string;
source: string;
result: AnyDownloadResult;
error: string | null;
}
interface AnyDownloaderAPI {
(url: string): Promise<NBScraperResponse<AnyDownloadResponse>>;
}
interface YouTubeDownloadResult {
title: string;
downloadUrl: string;
thumbnail?: string;
quality?: string;
type: 'mp3' | 'mp4';
duration?: string;
}
interface YouTubeMP3Response {
link: string;
filename: string;
}
interface YouTubeVideoResponse {
progress_url: string;
info?: {
image: string;
title: string;
};
}
interface YouTubeProgressResponse {
progress: number;
download_url: string;
}
interface YouTubeDownloaderAPI {
youtubeMp3(url: string): Promise<NBScraperResponse<YouTubeDownloadResult>>;
ytdl(url: string, quality?: string): Promise<NBScraperResponse<YouTubeDownloadResult>>;
}
/**
* Error types that can occur during scraping
*/
declare enum ScraperErrorType {
/** Network-related errors (connection, timeout, etc.) */
NETWORK_ERROR = "NETWORK_ERROR",
/** Invalid or malformed input parameters */
INVALID_PARAMETER = "INVALID_PARAMETER",
INVALID_INPUT = "INVALID_INPUT",
/** API returned an unexpected response format */
INVALID_RESPONSE = "INVALID_RESPONSE",
/** Rate limiting or quota exceeded */
RATE_LIMITED = "RATE_LIMITED",
/** Service is temporarily unavailable */
SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
/** Authentication or authorization failed */
AUTH_ERROR = "AUTH_ERROR",
/** Error parsing response data */
PARSE_ERROR = "PARSE_ERROR",
/** Error during image generation */
IMAGE_GENERATION_ERROR = "IMAGE_GENERATION_ERROR",
/** Error calling external API */
API_ERROR = "API_ERROR",
DOWNLOAD_ERROR = "DOWNLOAD_ERROR",
NOT_FOUND = "NOT_FOUND",
QUALITY_NOT_AVAILABLE = "QUALITY_NOT_AVAILABLE",
/** Unknown or unexpected error */
UNKNOWN_ERROR = "UNKNOWN_ERROR"
}
/**
* Detailed error information
*/
interface ScraperError {
/** The type of error that occurred */
type: ScraperErrorType;
/** Human-readable error message */
message: string;
/** Original error object (if available) */
originalError?: Error;
/** Additional context about the error */
context?: Record<string, unknown>;
}
/**
* TranslateImage Scraper Types
*/
interface TranslateImageCredentials {
host: string;
dir: string;
accessId: string;
policy: string;
signature: string;
callback: string;
fileUrl: string;
}
interface TranslateImageOptions {
buffer: Buffer;
filename: string;
sourceLanguage?: string;
targetLanguage?: string;
}
interface TranslateMangaOptions extends TranslateImageOptions {
detectionMode?: 'default' | string;
textDirection?: 'auto' | 'vertical' | 'horizontal';
}
interface TranslateEcommerceOptions {
imageUrl: string;
sourceLanguage?: string;
targetLanguage?: string;
commodityProtection?: boolean;
detectionMode?: 'default' | string;
textDirection?: 'auto' | 'vertical' | 'horizontal';
}
interface TranslateImageResult {
request_id: string;
[key: string]: any;
}
interface TranslateImageAPI {
translateImage(options: TranslateImageOptions): Promise<NBScraperResponse<TranslateImageResult>>;
translateManga(options: TranslateMangaOptions): Promise<NBScraperResponse<TranslateImageResult>>;
translateEcommerceImageFromUrl(options: TranslateEcommerceOptions): Promise<NBScraperResponse<TranslateImageResult>>;
uploadImage(options: {
buffer: Buffer;
filename: string;
}): Promise<NBScraperResponse<{
imageUrl: string;
}>>;
}
/**
* Groupda WhatsApp Group Search Scraper Types
*/
interface GroupdaSearchResult {
name: string;
code: string;
link: string;
description: string;
keyword: string;
}
interface GroupdaSearchOptions {
keywords: string;
pageLimit?: number;
[key: string]: unknown;
}
interface GroupdaAPI {
(options: GroupdaSearchOptions): Promise<NBScraperResponse<GroupdaSearchResult[]>>;
}
/**
* Free Fire Stalk (ffstalk) Scraper Types
*/
interface FFStalkAccountInfo {
[key: string]: string;
}
interface FFStalkPetInfo {
[key: string]: string;
}
interface FFStalkGuildInfo {
[key: string]: string;
}
interface FFStalkEquippedItem {
name: string;
image: string;
}
interface FFStalkEquipped {
[category: string]: FFStalkEquippedItem[];
}
interface FFStalkData {
accountInfo: FFStalkAccountInfo;
petInfo: FFStalkPetInfo;
guildInfo: FFStalkGuildInfo;
equipped: FFStalkEquipped;
}
interface FFStalkAPI {
(uid: string): Promise<NBScraperResponse<FFStalkData>>;
}
/**
* SSYoutube Scraper Types
*/
interface SSYoutubeDownloadFormat {
url: string;
quality: string;
ext: string;
size: string;
hasAudio?: boolean;
}
interface SSYoutubeData {
title: string;
duration: string;
thumbnail: string;
downloads: {
video: SSYoutubeDownloadFormat[];
audio: SSYoutubeDownloadFormat[];
};
}
interface SSYoutubeAPI {
(url: string): Promise<NBScraperResponse<SSYoutubeData>>;
}
/**
* Unaimytext Scraper Types
*/
type UnaimytextLevel = 'standard' | 'enhanced' | 'aggressive';
interface UnaimytextSettings {
removeUnicode?: boolean;
dashesToCommas?: boolean;
removeDashes?: boolean;
transformQuotes?: boolean;
removeWhitespace?: boolean;
removeEmDash?: boolean;
keyboardOnly?: boolean;
}
interface UnaimytextOptions {
text: string;
level?: UnaimytextLevel;
settings?: UnaimytextSettings;
}
interface UnaimytextData {
humanizedText: string;
level: UnaimytextLevel;
originalLength: number;
transformedLength: number;
reductionPercentage: string;
}
interface UnaimytextAPI {
(options: UnaimytextOptions): Promise<NBScraperResponse<UnaimytextData>>;
}
/**
* BacaKomik Scraper Types
*/
interface BacaKomikSearchResult {
title: string;
url: string;
image: string;
type: string;
score: number;
genres: string[];
chapter: string;
}
interface BacaKomikLatestResult {
title: string;
url: string;
image: string;
type: string;
views: number;
score: number;
status: string;
colorized: boolean;
latestChapter: {
chapter: string;
url: string;
time: string;
};
}
interface BacaKomikRecommendationResult {
title: string;
url: string;
image: string;
type: string;
score: number;
status: string;
recommendedChapter: {
chapter: string;
url: string;
time: string;
};
}
interface BacaKomikFilterOptions {
type?: string;
status?: string;
genre?: string[];
content?: string[];
demographic?: string[];
theme?: string[];
}
interface BacaKomikDetailData {
id: string;
title: string;
synopsis: string;
score: number;
status: string;
cover: string;
thumbnail: string;
author: string[];
genre: string[];
theme: string[];
content: string[];
demographic: string[];
chapters: {
chapter: string;
url: string;
download: string;
}[];
}
interface BacaKomikChapterData {
id: string;
title: string;
chapter: string;
next: string;
thumbnail: string;
readerLink: string;
adsLink: string;
images: string[];
}
interface BacaKomikAPI {
searchComics(keyword: string, page?: number): Promise<NBScraperResponse<{
query: string;
paged: number;
total: number;
data: BacaKomikSearchResult[];
}>>;
getLatestComics(): Promise<NBScraperResponse<{
total: number;
data: BacaKomikLatestResult[];
}>>;
getRecommendedComics(): Promise<NBScraperResponse<{
total: number;
data: BacaKomikRecommendationResult[];
}>>;
filterComics(options: BacaKomikFilterOptions): Promise<NBScraperResponse<{
filters: BacaKomikFilterOptions;
total: number;
data: BacaKomikSearchResult[];
}>>;
getComicDetail(idOrUrl: string): Promise<NBScraperResponse<BacaKomikDetailData>>;
getChapter(idOrUrl: string): Promise<NBScraperResponse<BacaKomikChapterData>>;
}
/**
* Pollinations AI Image Generation Types
*/
interface PollinationsOptions {
prompt: string;
nologo?: boolean;
[key: string]: unknown;
}
interface PollinationsData {
/** URL of the generated image on Catbox.moe */
url: string;
/** Direct Pollinations image URL */
directUrl: string;
}
/**
* Pinterest Scraper Types
*/
interface PinterestData {
/** Array of image URLs */
result: string[];
}
interface FacebookDownloadLink {
quality: string;
format: 'mp4' | 'unknown';
link: string;
}
interface FacebookVideoData {
title: string;
duration: string;
thumbnail: string;
links: FacebookDownloadLink[];
}
interface FacebookDownloaderAPI {
(url: string): Promise<NBScraperResponse<FacebookVideoData>>;
}
/**
* SoundCloud Scraper Types
*/
interface SoundCloudTrack {
id: number;
title: string;
url: string;
duration: string;
thumbnail: string;
author: {
name: string;
url: string;
};
like_count: string;
download_count: string;
play_count: string;
release_date: string | null;
}
interface SoundCloudApiResponse {
collection: SoundCloudApiTrack[];
}
interface SoundCloudApiTrack {
id: number;
title: string;
permalink_url: string;
duration: number;
artwork_url: string;
user: {
username: string;
permalink_url: string;
};
likes_count: number;
download_count: number;
playback_count: number;
created_at: string;
release_date?: string;
}
interface SoundCloudSearchOptions {
query: string;
limit?: number;
[key: string]: unknown;
}
interface SoundCloudData {
tracks: SoundCloudTrack[];
}
interface SoundCloudCache {
version: string;
id: string;
}
/**
* ExomlAPI AI Text Completion Types
*/
interface ExomlAPIMessage {
role: "user" | "assistant" | "system";
content: string;
}
interface ExomlAPIOptions extends Record<string, unknown> {
messages: ExomlAPIMessage[];
systemPrompt?: string;
model?: string;
}
interface ExomlAPIData {
content: string;
}
interface ExomlAPIRandomData {
id: string;
chatId: string;
userId: string;
antiBotId: string;
}
interface CharSetOptions {
lowerCase?: boolean;
upperCase?: boolean;
symbol?: boolean;
number?: boolean;
}
/**
* DeepInfra AI Chat Types
*/
interface DeepInfraAIOptions extends Record<string, unknown> {
prompt: string;
model?: DeepInfraAIModel;
}
type DeepInfraAIModel = 'meta-llama/Llama-3.3-70B-Instruct-Turbo' | 'deepseek-ai/DeepSeek-R1' | 'Qwen/Qwen2.5-72B-Instruct' | string;
interface DeepInfraAIMessage {
role: 'user' | 'assistant' | 'system';
content: string;
parts: Array<{
type: 'text' | string;
text: string;
}>;
}
interface DeepInfraAIRequest {
id: string;
selectedModel: DeepInfraAIModel;
messages: DeepInfraAIMessage[];
}
interface DeepInfraAIResponse {
/** Generated text */
g?: string | string[];
/** Follow-up text */
f?: string | string[];
/** Primary response */
'0'?: string | string[];
[key: string]: unknown;
}
interface DeepInfraAIData {
response: string;
}
/**
* DreamAnalysis Types
*/
interface DreamAnalysisOptions {
text: string;
isPremium?: boolean;
[key: string]: unknown;
}
interface DreamAnalysisData {
analysis?: string;
interpretation?: string;
symbols?: {
name: string;
meaning: string;
relevance: number;
}[];
emotions?: string[];
themes?: string[];
/** Additional metadata from analysis */
metadata?: Record<string, unknown>;
}
/**
* BlackBox AI Types
*/
interface BlackBoxAIData {
/** The AI's response text */
response: string;
/** Array of sources used by the AI */
source: BlackBoxSource[];
}
interface BlackBoxSource {
/** URL of the source */
link: string;
/** Title of the source */
title: string;
/** Text snippet from the source */
snippet: string;
/** Position/ranking of the source */
position: number;
}
interface BlackBoxAIOptions extends RequestConfig {
/** Maximum number of tokens in the response */
maxTokens?: number;
/** Temperature for response generation (0-1) */
temperature?: number;
/** Whether to enable web search mode */
webSearchMode?: boolean;
/** Whether to enable memory/context */
memoryEnabled?: boolean;
[key: string]: unknown;
}
/**
* Threads Scraper Types
*/
interface ThreadsMediaData {
/** Array of image URLs */
image_urls: string[];
/** Array of video URLs */
video_urls: string[];
}
interface ThreadsOptions extends RequestConfig {
/** Whether to include only images */
imagesOnly?: boolean;
/** Whether to include only videos */
videosOnly?: boolean;
[key: string]: unknown;
}
/**
* Liputan 6 Scraper Types
*/
interface Liputan6NewsItem {
title: string;
link: string;
thumb?: string;
summary?: string;
}
interface Liputan6SearchResult {
title: string;
link: string;
}
interface Liputan6NewsDetail {
title: string;
description?: string;
image?: string;
published?: string;
author?: string;
content: string;
}
interface Liputan6API {
getHomeNews(): Promise<NBScraperResponse<Liputan6NewsItem[]>>;
searchNews(query: string): Promise<NBScraperResponse<Liputan6SearchResult[]>>;
getNewsDetail(url: string): Promise<NBScraperResponse<Liputan6NewsDetail>>;
}
interface FileUploadResult {
filename: string;
downloadUrl: string;
size: string;
mimeType: string;
extension: string;
uploadedAt: string;
}
interface FileInfoResult {
filename: string;
mimeType: string;
extension: string;
size: {
bytes: number;
kb: string;
mb: string;
};
isAllowed: boolean;
}
/**
* Savegram Scraper Types
*/
interface SavegramItem {
thumbnail: string;
quality: string;
downloadUrl: string;
}
interface SavegramResult {
items: SavegramItem[];
}
interface WeatherMasterOptions {
lat?: string;
lon?: string;
}
/**
* PeriksaData Scraper Types
*/
interface PeriksaDataBreach {
img: string;
title: string;
date: string;
breached_data: string;
total_breach: string;
}
interface PeriksaDataAPI {
(email: string): Promise<NBScraperResponse<PeriksaDataBreach[]>>;
}
/**
* APKPure Scraper Types
*/
interface ApkPureTag {
name: string;
type: string;
id: string;
}
interface ApkPureSearchResultItem {
key: string;
packageName: string;
title: string;
icon: string;
installTotal: string;
scoreTotal: string;
score: string;
tags: ApkPureTag[];
url: string;
fullUrl: string;
buttonText: string;
isInterveneUrl: boolean;
isConfigTag: boolean;
showDownloadBtn: boolean;
downloadTip: string;
downloadText: string;
downloadUrl: string;
fullDownloadUrl: string;
fileId: string;
fileSize: number;
version: string;
versionCode: number;
cornerTags: any[];
search_suggestion_id: string;
downloadUrlFile: string;
}
interface ApkPureSearchOptions {
keyword: string;
limit?: number;
[key: string]: unknown;
}
interface ApkPureAPI {
(options: ApkPureSearchOptions): Promise<NBScraperResponse<ApkPureSearchResultItem[]>>;
}
/**
* YouTube Post Scraper Types
*/
type YouTubePostType = 'voteImage' | 'voteText' | 'multipleImages' | 'singleImage' | 'videoShare' | 'text';
interface YouTubePostImage {
text: string | null;
url: string | null;
}
interface YouTubePostData {
author: string;
authorUrl: string;
publishTime: string;
text: string;
like: string | null;
images: YouTubePostImage[] | null;
videoShareUrl: string | null;
postType: YouTubePostType;
}
interface YouTubePostAPI {
(url: string): Promise<NBScraperResponse<YouTubePostData>>;
}
/**
* Ytmp3.mobi Scraper Types
*/
type Ytmp3mobiFormat = 'mp3' | 'mp4';
interface Ytmp3mobiOptions {
youtubeUrl: string;
format?: Ytmp3mobiFormat;
[key: string]: unknown;
}
interface Ytmp3mobiData {
title: string;
downloadUrl: string;
}
interface Ytmp3mobiAPI {
(options: Ytmp3mobiOptions): Promise<NBScraperResponse<Ytmp3mobiData>>;
}
/**
* Terabox Search Scraper Types
*/
interface TeraboxGroup {
id: number;
title: string;
username: string;
profile_picture: string;
members: number;
}
interface TeraboxContent {
id: number;
title: string;
description: string;
url: string;
}
type TeraboxSearchType = 'groups' | 'content' | 'both';
interface TeraboxSearchOptions {
query: string;
type?: TeraboxSearchType;
[key: string]: unknown;
}
interface TeraboxData {
groups?: TeraboxGroup[];
contents?: TeraboxContent[];
totalResults: number;
}
/**
* TextCraft Scraper Types
*/
interface TextcraftOptions {
text1: string;
text2?: string;
text3?: string;
[key: string]: unknown;
}
interface TextcraftData {
imageUrl: string;
}
interface TextcraftAPI {
(options: TextcraftOptions): Promise<NBScraperResponse<TextcraftData>>;
}
/**
* Tutwuri Shortlink Bypass Scraper Types
*/
interface TutwuriBypassOptions {
shortlink: string;
apikey: string;
[key: string]: unknown;
}
interface TutwuriBypassData {
status: string;
message: string;
url: string;
}
interface TeraboxAPI {
(options: TeraboxSearchOptions): Promise<NBScraperResponse<TeraboxData>>;
}
interface TutwuriBypassAPI {
(options: TutwuriBypassOptions): Promise<NBScraperResponse<TutwuriBypassData>>;
}
/**
* AI Lyrics Generator Types
*/
type LyricsGeneratorGenre = 'pop' | 'rock' | 'folk' | 'rap' | 'rnb' | 'jazz' | 'classical' | 'electronic' | 'country' | 'blues';
type LyricsGeneratorMood = 'happy' | 'sad' | 'romantic' | 'energetic' | 'peaceful' | 'melancholic' | 'angry' | 'hopeful' | 'nostalgic' | 'uplifting';
type LyricsGeneratorStructure = 'verse_chorus' | 'verse_chorus_bridge' | 'verse_prechorus_chorus' | 'verse_chorus_bridge_chorus' | 'verse_only' | 'chorus_only';
type LyricsGeneratorLanguage = 'en' | 'id';
interface LyricsGeneratorOptions {
topic: string;
genre?: LyricsGeneratorGenre;
mood?: LyricsGeneratorMood;
structure?: LyricsGeneratorStructure;
language?: LyricsGeneratorLanguage;
[key: string]: unknown;
}
interface LyricsGeneratorData {
title: string;
lyrics: string;
topic: string;
genre: string;
mood: string;
structure: string;
language: string;
}
interface LyricsGeneratorAPI {
(options: LyricsGeneratorOptions): Promise<NBScraperResponse<LyricsGeneratorData>>;
}
/**
* Detailed Weather Data Interfaces for WeatherMaster Scraper
* Based on TimeZoneDB, Open-Meteo, and WeatherAPI.com responses.
*/
interface TimezoneResponse {
status: string;
message: string;
countryCode: string;
countryName: string;
regionName: string;
cityName: string;
zoneName: string;
abbreviation: string;
gmtOffset: number;
dst: string;
zoneStart: number | null;
zoneEnd: number | null;
nextAbbreviation: string | null;
timestamp: number;
formatted: string;
}
interface CurrentWeatherUnits {
time: string;
interval: string;
temperature_2m: string;
is_day: string;
apparent_temperature: string;
pressure_msl: string;
relative_humidity_2m: string;
precipitation: string;
weather_code: string;
cloud_cover: string;
wind_speed_10m: string;
wind_direction_10m: string;
wind_gusts_10m: string;
}
interface CurrentWeather {
time: string;
interval: number;
temperature_2m: number;
is_day: number;
apparent_temperature: number;
pressure_msl: number;
relative_humidity_2m: number;
precipitation: number;
weather_code: number;
cloud_cover: number;
wind_speed_10m: number;
wind_direction_10m: number;
wind_gusts_10m: number;
}
interface HourlyUnits {
time: string;
wind_speed_10m?: string;
wind_direction_10m?: string;
relative_humidity_2m: string;
pressure_msl: string;
cloud_cover: string;
temperature_2m: string;
dew_point_2m: string;
apparent_temperature: string;
precipitation_probability: string;
precipitation: string;
weather_code: string;
visibility: string;
uv_index: string;
}
interface HourlyData {
time: string[];
wind_speed_10m?: number[];
wind_direction_10m?: number[];
relative_humidity_2m: number[];
pressure_msl: number[];
cloud_cover: number[];
temperature_2m: number[];
dew_point_2m: number[];
apparent_temperature: number[];
precipitation_probability: number[];
precipitation: number[];
weather_code: number[];
visibility: number[];
uv_index: number[];
}
interface DailyUnits {
time: string;
weather_code: string;
temperature_2m_max: string;
temperature_2m_min: string;
sunrise: string;
sunset: string;
daylight_duration: string;
uv_index_max: string;
precipitation_sum: string;
precipitation_probability_max: string;
precipitation_hours: string;
wind_speed_10m_max: string;
wind_gusts_10m_max: string;
}
interface DailyData {
time: string[];
weather_code: number[];
temperature_2m_max: number[];
temperature_2m_min: number[];
sunrise: string[];
sunset: string[];
daylight_duration: number[];
uv_index_max: number[];
precipitation_sum: number[];
precipitation_probability_max: number[];
precipitation_hours: number[];
wind_speed_10m_max: number[];
wind_gusts_10m_max: number[];
}
interface Location {
name: string;
region: string;
country: string;
lat: number;
lon: number;
tz_id: string;
localtime_epoch: number;
localtime: string;
}
interface Condition {
text: string;
icon: string;
code: number;
}
interface CurrentWeatherExtended {
last_updated_epoch: number;
last_updated: string;
temp_c: number;
temp_f: number;
is_day: number;
condition: Condition;
wind_mph: number;
wind_kph: number;
wind_degree: number;
wind_dir: string;
pressure_mb: number;
pressure_in: number;
precip_mm: number;
precip_in: number;
humidity: number;
cloud: number;
feelslike_c: number;
feelslike_f: number;
windchill_c: number;
windchill_f: number;
heatindex_c: number;
heatindex_f: number;
dewpoint_c: number;
dewpoint_f: number;
vis_km: number;
vis_miles: number;
uv: number;
gust_mph: number;
gust_kph: number;
}
interface DayForecast {
maxtemp_c: number;
maxtemp_f: number;
mintemp_c: number;
mintemp_f: number;
avgtemp_c: number;
avgtemp_f: number;
maxwind_mph: number;
maxwind_kph: number;
totalprecip_mm: number;
totalprecip_in: number;
totalsnow_cm: number;
avgvis_km: number;
avgvis_miles: number;
avghumidity: number;
daily_will_it_rain: number;
daily_chance_of_rain: number;
daily_will_it_snow: number;
daily_chance_of_snow: number;
condition: Condition;
uv: number;
}
interface Astro {
sunrise: string;
sunset: string;
moonrise: string;
moonset: string;
moon_phase: string;
moon_illumination: number;
is_moon_up: number;
is_sun_up: number;
}
interface HourForecast {
time_epoch: number;
time: string;
temp_c: number;
temp_f: number;
is_day: number;
condition: Condition;
wind_mph: number;
wind_kph: number;
wind_degree: number;
wind_dir: string;
pressure_mb: number;
pressure_in: number;
precip_mm: number;
precip_in: number;
snow_cm: number;
humidity: number;
cloud: number;
feelslike_c: number;
feelslike_f: number;
windchill_c: number;
windchill_f: number;
heatindex_c: number;
heatindex_f: number;
dewpoint_c: number;
dewpoint_f: number;
will_it_rain: number;
chance_of_rain: number;
will_it_snow: number;
chance_of_snow: number;
vis_km: number;
vis_miles: number;
gust_mph: number;
gust_kph: number;
uv: number;
}
interface ForecastDay {
date: string;
date_epoch: number;
day: DayForecast;
astro: Astro;
hour: HourForecast[];
}
interface Forecast {
forecastday: ForecastDay[];
}
interface Astronomy {
astro: Astro;
}
interface Alerts {
alert: any[];
}
interface WeatherData {
latitude: number;
longitude: number;
generationtime_ms: number;
utc_offset_seconds: number;
timezone: string;
timezone_abbreviation: string;
elevation: number;
current_units?: CurrentWeatherUnits;
current?: CurrentWeather;
hourly_units?: HourlyUnits;
hourly?: HourlyData;
daily_units?: DailyUnits;
daily?: DailyData;
}
interface WeatherAPIResponse {
location: Location;
current?: CurrentWeatherExtended;
forecast?: Forecast;
astronomy?: Astronomy;
alerts?: Alerts;
}
/**
* LaraTranslate Scraper Types
*/
type LaraTranslateMode = 'Faithful' | 'Fluid' | 'Creative' | 'Custom';
interface LaraTranslateOptions {
text: string;
targetLanguage: string;
sourceLanguage?: string;
mode?: LaraTranslateMode;
customInstructions?: string[];
}
interface LaraTranslateData {
mode: LaraTranslateMode;
originalText: string;
sourceLanguage: string;
targetLanguage: string;
translation: string;
quota: number;
}
interface LaraAPI {
(options: LaraTranslateOptions): Promise<NBScraperResponse<LaraTranslateData>>;
}
/**
* TikTok Scraper Types
*/
interface TikTokPhoto {
index: number;
imageUrl: string;
downloadUrl: string;
type: 'photo';
}
interface TikTokVideoLink {
type: 'video';
url: string;
quality: 'HD' | 'Normal' | string;
label: string;
}
interface TikTokRenderData {
hasRenderButton: boolean;
token?: string;
isAd?: boolean;
type?: 'render';
}
interface TikTokData {
originalUrl: string;
title: string;
author: string;
thumbnail: string;
contentType: 'slideshow' | 'video';
downloadLinks: TikTokVideoLink[];
photos: TikTokPhoto[];
renderData: TikTokRenderData;
}
interface TikTokAPI {
(url: string): Promise<NBScraperResponse<TikTokData>>;
}
interface AnimeIndoSearchResult {
title: string;
link: string;
image: string;
year: string;
description: string;
rating?: string;
status?: string;
}
interface AnimeIndoEpisode {
episode: string;
link: string;
date?: string;
downloadLinks?: {
server: string;
url: string;
}[];
}
interface AnimeIndoDetail {
title: string;
image: string;
genres: string[];
description: string;
episodes: AnimeIndoEpisode[];
rating?: string;
status?: string;
duration?: string;
studio?: string;
}
interface AnimeIndoDownloadInfo {
title: string;
description: string;
videoLinks: Array<{
label: string;
videoUrl: string;
quality?: string;
}>;
gdriveHdLink: string;
downloadUrl: string;
fileName: string;
fileSize: string;
mimetype: string;
thumbnail?: string;
duration?: string;
subtitles?: {
language: string;
url: string;
}[];
}
interface AnimeIndoAPI {
search(query: string): Promise<NBScraperResponse<AnimeIndoSearchResult[]>>;
detail(url: string): Promise<NBScraperResponse<AnimeIndoDetail>>;
download(episodeUrl: string): Promise<NBScraperResponse<AnimeIndoDownloadInfo>>;
}
/**
* Global configuration for the scraper library
*/
interface NBScraperConfig {
/** Default timeout for all requests */
defaultTimeout: number;
/** Default number of retries */
defaultRetries: number;
/** Default retry delay */
defaultRetryDelay: number;
/** Whether to log detailed error information */
verboseErrors: boolean;
/** Custom user agent string */
userAgent: string;
}
interface LemonWriteOptions {
font?: string;
color?: string;
size?: string;
}
interface LemonWriteResult {
imageBuffer: Buffer;
contentType: string;
}
/**
* Low-level response from the canvas writer.
*/
interface WriteCanvas {
/** HTTP-like status code (200 = OK) */
status: number;
/** Generated image data */
message: Buffer;
}
/**
* @fileoverview BlackBox AI scraper implementation
* @author From NB
* @version 1.0.0
*/
/**
* Scrapes BlackBox AI for responses to queries
*
* @example
* ```typescript
* import { blackboxAi } from 'nb-scraper';
*
* const result = await blackboxAi('What is TypeScript?');
* if (result.status) {
* console.log(result.data.response);
* console.log(result.data.source);
* }
* ```
*
* @param query - The query to send to BlackBox AI
* @param options - Optional configuration for the request
* @returns Promise resolving to the AI response with sources
*
* @throws Will not throw errors, returns error response instead
*
* @author Pratama
*/
declare function blackboxAi(query: string, options?: BlackBoxAIOptions): Promise<NBScraperResponse<BlackBoxAIData>>;
/**
* @fileoverview Threads media scraper implementation
* @author NB Team
* @version 1.0.0
*/
/**
* @alpha
* Scrapes media URLs from Threads posts
*
* @example
* ```typescript
* import { threads } from 'nb-scraper';
*
* const result = await threads('https://www.threads.net/@username/post/123456789');
* if (result.status) {
* console.log('Images:', result.data.image_urls);
* console.log('Videos:', result.data.video_urls);
* }
* ```
*
* @param url - The Threads post URL to scrape
* @param options - Optional configuration for the request
* @returns Promise resolving to media URLs from the post
*
* @throws Will not throw errors, returns error response instead
*
* @author Rian
*/
declare function threads(url: string, options?: ThreadsOptions): Promise<NBScraperResponse<ThreadsMediaData>>;
/**
* @fileoverview Pinterest Scraper
* @author Wolep
* @version 1.0.0
*/
/**
* @alpha
* Search Pinterest from the given query
*
* @example
* ```typescript
* import { Pinterest } from 'nb-scraper';
*
* const result = await Pinterest('jagung');
* if (result.status) {
* console.log(result.data.result);
* }
* ```
*
* @param query - The query to search content on Pinterest
* @param options - Optional request configuration
* @returns Promise resolving Array of image URLs
*
* @throws Returns error response
*
* @author Wolep
*/
declare function pinterest(query: string, options?: RequestConfig): Promise<NBScraperResponse<PinterestData>>;
/**
* @fileoverview ExomlAPI - AI Text Completion Service
* Base URL: https://exomlapi.com/
*
* Features:
* - AI text completion with conversation support
* - Multiple model support (GPT-4.1, GPT-4o, Llama, etc.)
* - Text-only responses
*
* Note: Some models may hang with slow fetch times
*
* @author wolep
* @version 1.0.0
* @lastUpdated 2025-06-07
*/
/**
* @alpha
* Create a conversation message
*
* @example
* ```typescript
* import { createExomlMessage } from 'nb-scraper';
*
* const message = createExomlMessage("user", "Hello, how are you?");
* ```
*
* @param role - Message role
* @param content - Message content
* @returns ExomlAPIMessage
* @author Wolep
*/
declare function createExomlMessage(role: "user" | "assistant" | "system", content: string): ExomlAPIMessage;
/**
* Generate AI response
*
* @example
* ```typescript
* import { generateExomlResponse } from 'nb-scraper';
*
* const result = await generateExomlResponse({
* messages: [
* createExomlMessage("user", "Hello, how are you?")
* ],
* model: "gpt-4.1"
* });
*
* if (result.status) {
* console.log(result.data.content);
* }
* ```
*
* @param options - Configuration for the AI request
* @returns Promise<NBScraperResponse<ExomlAPIData>>
* @author Wolep
*/
declare function generateExomlResponse(options: ExomlAPIOptions): Promise<NBScraperResponse<ExomlAPIData>>;
/**
* @fileoverview DreamAnalysis - Dream Interpretation Service
* Base URL: https://safe-coast-53976-cd772af9b056.herokuapp.com/
*
* Features:
* - Analyze and interpret dreams from text descriptions
* - Premium analysis features available
* - Returns detailed interpretation with symbols, emotions, and themes
*
* @author NB Team
* @version 1.0.0
*/
/**
* Analyze dream text and get interpretation
*
* @example
* ```typescript
* import { analyzeDream } from 'nb-scraper';
*
* const result = await analyzeDream({
* text: "I dreamed I was flying over mountains",
* isPremium: true
* });
*
* if (result.status) {
* console.log(result.data.interpretation);
* }
* ```
*
* @param options - Configuration for dream analysis
* @returns Promise<NBScraperResponse<DreamAnalysisData>>
* @author NajmyW
*/
declare function analyzeDream(options: DreamAnalysisOptions): Promise<NBScraperResponse<DreamAnalysisData>>;
/**
* Quick analysis with basic interpretation
*
* @example
* ```typescript
* import { quickDreamAnalysis } from 'nb-scraper';
*
* const result = await quickDreamAnalysis("I dreamed of being chased");
* if (result.status) {
* console.log(result.data);
* }
* ```
*
* @param text - Dream description text
* @returns Promise<NBScraperResponse<DreamAnalysisData>>
* @author NajmyW
*/
declare function quickDreamAnalysis(text: string): Promise<NBScraperResponse<DreamAnalysisData>>;
/**
* Premium analysis with detailed interpretation
*
* @example
* ```typescript
* import { premiumDreamAnalysis } from 'nb-scraper';
*
* const result = await premiumDreamAnalysis("I dreamed I could breathe underwater");
* if (result.status) {
* console.log(result.data.symbols);
* }
* ```
*
* @param text - Dream description text
* @returns Promise<NBScraperResponse<DreamAnalysisData>>
* @author NajmyW
*/
declare function premiumDreamAnalysis(text: string): Promise<NBScraperResponse<DreamAnalysisData>>;
/**
* @fileoverview Pollinations AI Image Generation Service
* Base URL: https://image.pollinations.ai/
*
* Features:
* - Generate images from text prompts
* - Upload generated images to Catbox.moe for permanent hosting
* - No logo option available
*
* @author NB Team
* @version 1.0.1
*/
/**
* @alpha
* Generate image from prompt and upload to Catbox
*
* @example
* ```typescript
* import { generatePollinationsImage } from 'nb-scraper';
*
* const result = await generatePollinationsImage({
* prompt: "a beautiful sunset over mountains",
* nologo: true
* });
*
* if (result.status) {
* console.log(result.data.url); // Catbox.moe URL
* }
* ```
*
* @param options - Configuration for image generation
* @returns Promise<NBScraperResponse<PollinationsData>>
* @author Jul
*/
declare function generatePollinationsImage(options: PollinationsOptions): Promise<NBScraperResponse<PollinationsData>>;
/**
* Get direct image URL (without upload to Catbox)
*
* @example
* ```typescript
* import { getPollinationsDirectUrl } from 'nb-scraper';
*
* const url = getPollinationsDirectUrl({
* prompt: "a beautiful sunset over mountains",
* nologo: true
* });
*
* console.log(url); // Direct Pollinations image URL
* ```
*
* @param options - Configuration for image generation
* @returns string - Direct image URL
* @author Jul
*/
declare function getPollinationsDirectUrl(options: PollinationsOptions): string;
/**
* @fileoverview SoundCloud Music Search and Track Information
* Base URL: https://soundcloud.com/
*
* Features:
* - Search tracks with detailed information
* - Auto client_id extraction and caching
* - Format duration, numbers, and dates
* - Track metadata including plays, likes, downloads
*
* @author NB Team
* @version 1.0.0
*/
/**
* Search SoundCloud tracks
*
* @example
* ```typescript
* import { searchSoundCloud } from 'nb-scraper';
*
* const result = await searchSoundCloud({
* query: "lofi chill",
* limit: 10
* });
*
* if (result.status) {
* console.log(result.data.tracks);
* }
* ```
*
* @param options - Search configuration
* @returns Promise<NBScraperResponse<SoundCloudData>>
* @author Rian
*/
declare function searchSoundCloud(options: SoundCloudSearchOptions): Promise<NBScraperResponse<SoundCloudData>>;
/**
* @alpha
* Get cached client ID and version info
*
* @example
* ```typescript
* import { getSoundCloudCacheInfo } from 'nb-scraper';
*
* const cacheInfo = getSoundCloudCacheInfo();
* console.log(cacheInfo);
* ```
*
* @returns Current cache state
* @author Rian
*/
declare function getSoundCloudCacheInfo(): SoundCloudCache;
/**
* @fileoverview DeepInfra AI Chat Service
* Base URL: https://ai-sdk-starter-deepinfra.vercel.app/api/chat
*
* Features:
* - AI text generation with multiple model support
* - Handles various response formats
* - Fallback for empty responses
*
* @author Woi
* @version 1.0.0
*/
/**
* Generate AI response using DeepInfra
*
* @example
* ```typescript
* import { generateDeepInfraResponse } from 'nb-scraper';
*
* const result = await generateDeepInfraResponse({
* prompt: "Explain JavaScript in simple terms",
* model: "deepseek-ai/DeepSeek-R1"
* });
*
* if (result.status) {
* console.log(result.data.response);
* }
* ```
*
* @param options - Configuration for the AI request
* @returns Promise<NBScraperResponse<DeepInfraAIData>>
* @author Woi
*/
declare function generateDeepInfraResponse(options: DeepInfraAIOptions): Promise<NBScraperResponse<DeepInfraAIData>>;
/**
* @fileoverview Anime Indo Scraper
* Base URL: https://anime-indo.lol
*
* Features:
* - Search anime
* - Get anime details
* - Download episodes
*
* @author Jul
* @version 1.0.1
*/
declare const animeIndo: {
/**
* Search anime
*
* @example
* ```typescript
* const result = await animeIndo.search("Naruto");
* if (result.status) {
* console.log(result.data);
* }
* ```
* @author Jul
*/
search(query: string): Promise<NBScraperResponse<AnimeIndoSearchResult[]>>;
/**
* Get anime details
*
* @example
* ```typescript
* const result = await animeIndo.detail("https://anime-indo.lol/anime/naruto");
* if (result.status) {
* console.log(result.data);
* }
* ```
* @author Jul
*/
detail(url: string): Promise<NBScraperResponse<AnimeIndoDetail>>;
/**
* Download episode
*
* @example
* ```typescript
* const result = await animeIndo.download("https://anime-indo.lol/episode/naruto-1");
* if (result.status) {
* console.log(result.data.downloadUrl);
* }
* ```
* @author Jul
*/
download(episodeUrl: string): Promise<NBScraperResponse<AnimeIndoDownloadInfo>>;
};
/**
* @alpha
* Facebook Video Downloader Service using
*
* @param url - Facebook video URL (must be in format: https://www.facebook.com/share/v/...)
* @returns Promise<NBScraperResponse<FacebookVideoData>>
* @example
* ```ts
* const { facebookDownloader } = require('nb-scraper')
*
* const res = await facebookDownloader('https://url.facebook.com/')
* console.log(res)
* ```
* @author Woiii
*/
declare function facebookDownloader(url: string): Promise<NBScraperResponse<FacebookVideoData>>;
/**
* @beta
* Download content from any source
* @param url - Xiaohongshu URL (e.g., http://xhslink.com/a/aTl9Mau0KNWeb)
* @example
* ```ts
* import { anyDownloader } from 'nb-scraper'
*
* const result = await anyDownloader("https://url.content.com") //eg. video facebook, ig etc
* console.log(result.data)
* ```
* @author Paxsenix0
*/
declare function anyDownloader(url: string): Promise<NBScraperResponse<AnyDownloadResponse>>;
declare const Ytdl: {
/**
* @beta
*
* Download YouTube video as MP3
* @param url - YouTube video URL
* @example
* ```ts
* import { Ytdl } from 'nb-scraper';
*
* const result = await Ytdl.mp3("https://youtube.com/.../");
* console.log(result)
* ```
* @author YogikId
*/
mp3: (url: string) => Promise<NBScraperResponse<YouTubeDownloadResult>>;
/**
* @beta
*
* Download YouTube video in specified quality
* @param url - YouTube video URL
* @param quality - Quality option (480, 720, 1080, 360, audio)
* @example
* ```ts
* import { Ytdl } from 'nb-scraper';
*
* const result = await Ytdl.mp4("https://youtube.com/.../");
* console.log(result)
* ```
* @author YogikId
*/
mp4: (url: string, quality?: string) => Promise<NBScraperResponse<YouTubeDownloadResult>>;
};
/**
* Downloads YouTube video or audio using ytmp3.cc.
* Supports MP3 and MP4 formats.
* @param youtubeUrl The YouTube video URL.
* @param format 'mp3' for audio, 'mp4' for video.
* @returns Promise<NBScraperResponse<YouTubeDownloadResult>>
* @example
* ```typescript
* import { ytmp3cc } from 'nb-scraper';
*
* (async () => {
* const result = await ytmp3cc.download("[https://www.youtube.com/watch?v=dQw4w9WgXcQ](https://www.youtube.com/watch?v=dQw4w9WgXcQ)", "mp3");
* if (result.status) {
* console.log(result.data.title);
* console.log(result.data.downloadUrl);
* } else {
* console.error(result.error);
* }
* })();
* ```
* @author wolep
* @beta
*/
declare const ytmp3cc: {
download: (youtubeUrl: string, format?: "mp3" | "mp4") => Promise<NBScraperResponse<YouTubeDownloadResult>>;
};
/**
* Get the updated news indonesian, from Liputan6 News
* @author saaoffc
*/
declare const liputan6: {
/**
* Get updated News
* @example
* ```ts
* import liputan6 from 'nb-scraper';
*
* const result = await liputan6.getNews()
* console.log(result)
* ```
* @beta
*/
getNews(): Promise<NBScraperResponse<Liputan6NewsItem[]>>;
/**
* Search news from the given query.
* @param query - (eg. free palestine)
* @example
* ```ts
* import liputan6 from 'nb-scraper';
*
* const result = await liputan6.searchNews("junkfood")
* console.log(result)
* ```
* @beta
*/
searchNews(query: string): Promise<NBScraperResponse<Liputan6SearchResult[]>>;
/**
* Get detailed news from Liputan6 Url
* @param url - URL Liputan6 News.
* @example
* ```ts
* import liputan6 from 'nb-scraper';
*
* const result = await liputan6.newsDetail()
* console.log(result)
* ```
* @beta
*/
newsDetail(url: string): Promise<NBScraperResponse<Liputan6NewsDetail>>;
};
/**
* Translates text using lara.com's API with different modes.
*
* @param options - The translation options.
* @returns A promise that resolves to the translated data.
* @example
* ```typescript
* import { laraTranslate } from 'nb-scraper';
*
* async function main() {
* const result = await laraTranslate({
* text: 'Hello, world!',
* targetLanguage: 'id',
* mode: 'Fluid'
* });
*
* if (result.status) {
* console.log('Translation:', result.data.translation);
* console.log('Quota left:', result.data.quota);
* } else {
* console.error('Error:', result.error);
* }
* }
*
* main();
* ```
* @author Daffa
* @alpha
*/
declare function laraTranslate(options: LaraTranslateOptions): Promise<NBScraperResponse<LaraTranslateData>>;
/**
* @fileoverview Instagram Downloader using savegram.info service
* @author FongsiDev (original author) & NB Team (integration)
* @beta
*
* Note: This scraper relies on executing obfuscated JavaScript from a third-party website
* within a Node.js `vm` context. This method is inherently fragile and highly
* susceptible to breaking if the target website changes its front-end logic or obfuscation.
* While `vm` provides a sandbox, executing external, untrusted code always carries
* potential security implications. Use with caution.
*/
/**
* Downloads Instagram media (videos/photos) via the savegram.info service.
* This function is highly dependent on the target website's dynamic JS,
* making it prone to breaking changes.
*
* @param url - The Instagram post URL (e.g., photo, video, reel, IGTV).
* @returns A promise that resolves to an NBScraperResponse containing an array of download items.
*
* @example
* ```typescript
* import { savegram } from 'nb-scraper';
*
* (async () => {
* const instagramUrl = '[https://www.instagram.com/reel/DG7I2Ezz2sy/?igsh=MTFoN2Z1MDJpeGNj](https://www.instagram.com/reel/DG7I2Ezz2sy/?igsh=MTFoN2Z1MDJpeGNj)';
* const result = await savegram(instagramUrl);
*
* if (result.status) {
* console.log('Download items:', result.data.items);
* } else {
* console.error('Error:', result.error);
* }
* })();
* ```
* @author Puruu Puruu
*/
declare function savegram(url: string): Promise<NBScraperResponse<SavegramResult>>;
/**
* Get Weater Info
* @example
* ```
* import { WeatherMaster } from 'nb-scraper';
* // with default location (jakarta)
* const weather = new WeatherMaster();
* console.log(weather)
*
* // or with specific coordinates
* const customWeather = new WeatherMaster({
* lat: "-6.200000",
* lon: "106.816666"
* });
* console.log(customWeather)
* ```
* @author Fgsi (FongsiDev)
*/
declare class WeatherMaster {
private lat;
private lon;
private encryptedKeyV1;
private encryptedKeyV2;
private secret;
private headers;
private keyV1;
private keyV2;
/**
* Initializes the WeatherMaster scraper.
* @param options - Optional latitude and longitude. Defaults to Jakarta.
*/
constructor(options?: WeatherMasterOptions);
/**
* Decrypts an encrypted string using AES.
* @param encrypted - The encrypted string.
* @returns The decrypted string.
*
*/
private decrypt;
/**
* Fetches time zone information from TimeZoneDB.
* @returns Promise<NBScraperResponse<TimezoneResponse>>
*/
getTimeZoneDB(): Promise<NBScraperResponse<TimezoneResponse>>;
/**
* Fetches weather forecast data from Open-Meteo.
* @returns Promise<NBScraperResponse<WeatherData>>
*/
getOpenMeteoForecast(): Promise<NBScraperResponse<WeatherData>>;
/**
* Fetches weather forecast data from WeatherAPI.com.
* @returns Promise<NBScraperResponse<WeatherAPIResponse>>
*/
getWeatherAPI_Forecast(): Promise<NBScraperResponse<WeatherAPIResponse>>;
/**
* Fetches astronomy data (sunrise, sunset, moon phase) from WeatherAPI.com.
* @returns Promise<NBScraperResponse<WeatherAPIResponse>>
*/
getWeatherAPI_Astronomy(): Promise<NBScraperResponse<WeatherAPIResponse>>;
/**
* Fetches weather alerts from WeatherAPI.com.
* @returns Promise<NBScraperResponse<WeatherAPIResponse>>
*/
getWeatherAPI_Alerts(): Promise<NBScraperResponse<WeatherAPIResponse>>;
private fetchOpenMeteoData;
getOpenMeteoHourly(): Promise<NBScraperResponse<WeatherData>>;
}
/**
* Scrape Youtube From
*/
/**
* Scrapes a YouTube community post to extract its content.
* Supports text, single/multiple images, polls, and video shares.
* @param url The URL of the YouTube community post.
* @returns A promise that resolves to the scraped post data.
* @example
* ```typescript
* import { getYoutubePost } from 'nb-scraper';
*
* async function fetchPost() {
* const url = "http://youtube.com/post/UgkxChSWx6pfUUCxxHeR3LsodyV6Aqwf4GOS?si=tSbmlFuR2dYH_wtk";
* const result = await getYoutubePost(url);
*
* if (result.status) {
* console.log(`Post by ${result.data.author}`);
* console.log(`Content: ${result.data.text}`);
* console.log(`Post Type: ${result.data.postType}`);
* } else {
* console.error(result.error);
* }
* }
*
* fetchPost();
* ```
* @author wolep
*/
declare function getYoutubePost(url: string): Promise<NBScraperResponse<YouTubePostData>>;
/**
* Generates song lyrics based on a topic, genre, mood, and structure.
* @param options - The configuration for lyric generation.
* @returns A promise that resolves to the generated lyrics data.
* @example
* ```typescript
* import { generateLyrics } from 'nb-scraper';
*
* async function createSong() {
* const result = await generateLyrics({
* topic: 'longing for a summer long past',
* genre: 'folk',
* mood: 'nostalgic',
* language: 'en',
* structure: 'verse_chorus_bridge'
* });
*
* if (result.status) {
* console.log(`Title: ${result.data.title}`);
* console.log('--- LYRICS ---');
* console.log(result.data.