Skip to main content

Result

Nosible API Client


Nosible API Client / Result

Class: Result

Defined in: src/search/result.ts:40

Represents a single search result from the Nosible search API.

This class encapsulates all the data and functionality associated with a search result, including metadata, content, semantic information, and methods for further operations like sentiment analysis, finding similar results, and URL scraping.

Example

const result = new Result({
client: nosibleClient,
result: apiResponseData
});

// Get sentiment analysis
const sentiment = await result.getSentiment();

// Find similar results
const similarResults = await result.getSimilar({ limit: 5 });

Constructors

Constructor

new Result(params): Result

Defined in: src/search/result.ts:174

Creates a new Result instance from raw API response data

Parameters

params

ResultParams

The result parameters containing client and raw data

Returns

Result

Properties

url_hash

url_hash: string

Defined in: src/search/result.ts:45

Unique hash identifier for the URL


url

url: string

Defined in: src/search/result.ts:50

The full URL of the web page


netloc

netloc: string

Defined in: src/search/result.ts:55

Network location (domain) of the URL


published

published: string

Defined in: src/search/result.ts:60

Publication date of the content (ISO 8601 format)


visited

visited: string

Defined in: src/search/result.ts:65

Date when the page was last visited/crawled (ISO 8601 format)


language

language: string

Defined in: src/search/result.ts:70

Language code of the content (e.g., 'en', 'es', 'fr')


author

author: string

Defined in: src/search/result.ts:75

Author of the content, if available


title

title: string

Defined in: src/search/result.ts:80

Title of the web page


description

description: string

Defined in: src/search/result.ts:85

Meta description or summary of the content


content

content: string

Defined in: src/search/result.ts:90

Full text content of the web page


best_chunk

best_chunk: string

Defined in: src/search/result.ts:95

The most relevant content chunk for the search query


semantics

semantics: object

Defined in: src/search/result.ts:100

Semantic search metadata including similarity scores and chunk information

origin_shard

origin_shard: number

chunks_total

chunks_total: number

chunks_matched

chunks_matched: number

chunks_kept

chunks_kept: number

similarity

similarity: number

bitstring

bitstring: string


brand_safety

brand_safety: string | null

Defined in: src/search/result.ts:106

Brand safety classification


continent

continent: string | null

Defined in: src/search/result.ts:111

Continent classification


region

region: string | null

Defined in: src/search/result.ts:116

Geographic region classification


country

country: string | null

Defined in: src/search/result.ts:121

Country classification (ISO 3166-1 alpha-2 code)


sector

sector: string | null

Defined in: src/search/result.ts:126

Economic sector classification


industry_group

industry_group: string | null

Defined in: src/search/result.ts:131

Industry group classification


industry

industry: string | null

Defined in: src/search/result.ts:136

Industry classification


sub_industry

sub_industry: string | null

Defined in: src/search/result.ts:141

Sub-industry classification


iab_tier_1

iab_tier_1: string | null

Defined in: src/search/result.ts:147

IAB Tier 1 content category


iab_tier_2

iab_tier_2: string | null

Defined in: src/search/result.ts:152

IAB Tier 2 content category


iab_tier_3

iab_tier_3: string | null

Defined in: src/search/result.ts:157

IAB Tier 3 content category


iab_tier_4

iab_tier_4: string | null

Defined in: src/search/result.ts:162

IAB Tier 4 content category


client

client: NosibleClient

Defined in: src/search/result.ts:167

The Nosible client instance used for API operations

Methods

fromFlatten()

static fromFlatten(client, flatten): Result

Defined in: src/search/result.ts:190

Creates a Result instance from a flattened result structure

This method reconstructs the nested semantics object from flattened properties and creates a new Result instance.

Parameters

client

NosibleClient

The Nosible client instance

flatten

FlattenResult

The flattened result data

Returns

Result

A new Result instance


getSentiment()

getSentiment(model?): Promise<number>

Defined in: src/search/result.ts:228

Analyzes the sentiment of the result content using an LLM

This method requires the Nosible client to be configured with an OpenRouter API key. The sentiment analysis returns a numerical score (typically ranging from -1 to 1) where negative values indicate negative sentiment and positive values indicate positive sentiment.

Parameters

model?

string

Optional model name for sentiment analysis (uses default if not specified)

Returns

Promise<number>

A promise that resolves to the sentiment score

Throws

Error if the client is not configured with an OpenRouter API key

Example

const sentiment = await result.getSentiment('gpt-4');
console.log(`Sentiment score: ${sentiment}`);

getSimilar()

getSimilar(params): Promise<ResultSet>

Defined in: src/search/result.ts:264

Finds search results similar to this one based on content and metadata

This method performs a new search using the title of this result as the query, excluding the current result from the returned results. It's useful for discovering related content or alternative sources on the same topic.

Parameters

params

Search parameters for finding similar results

autoGenerateExpansions?

boolean = ...

expansions?

string[] = ...

sqlFilter?

string = ...

algorithm?

"string" | "baseline" | "lexical" | "hamming" | "hybrid-1" | "hybrid-2" | "hybrid-3" | "company" = ...

nResults?

number = ...

nProbes?

number = ...

nContextify?

number = ...

minSimilarity?

number = ...

mustInclude?

string[] = ...

mustExclude?

string[] = ...

brandSafety?

"safe" | "sensitive" | "unsafe" = ...

language?

string = ...

continent?

"Africa" | "Asia" | "Europe" | "North America" | "Oceania" | "South America" | "Worldwide" = ...

region?

"North America" | "Oceania" | "South America" | "Worldwide" | "Caribbean" | "Central Africa" | "Central America" | "Central Asia" | "Central Europe" | "East Africa" | "East Asia" | "Eastern Europe" | "Middle East" | "North Africa" | "Northern Europe" | "South Asia" | "Southeast Asia" | "Southern Africa" | "Southern Europe" | "Sub-Saharan Africa" | "The Amazon Basin" | "The Andes" | "The Arctic Region" | "The Balkans" | "The Caucasus" | "The Horn of Africa" | "The Levant" | "The Middle East" | "The Sahel" | "West Africa" | "Western Europe" = ...

country?

string = ...

sector?

string = ...

industryGroup?

string = ...

industry?

string = ...

subIndustry?

string = ...

iabTier1?

string = ...

iabTier2?

string = ...

iabTier3?

string = ...

iabTier4?

string = ...

companies?

string[] = ...

publishStart?

Date = ...

publishEnd?

Date = ...

visitedStart?

Date = ...

visitedEnd?

Date = ...

certain?

boolean = ...

includeNetlocs?

string[] = ...

excludeNetlocs?

string[] = ...

includeCompanies?

string[] = ...

excludeCompanies?

string[] = ...

includeDocs?

string[] = ...

excludeDocs?

string[] = ...

Returns

Promise<ResultSet>

A promise that resolves to a ResultSet containing similar results

Example

// Find 5 similar results
const similar = await result.getSimilar({ limit: 5 });

// Find similar results with specific filters
const filteredSimilar = await result.getSimilar({
limit: 10,
country: 'US',
language: 'en'
});

scrapeUrl()

scrapeUrl(): Promise<WebPageData>

Defined in: src/search/result.ts:290

Scrapes the full web page content from the result's URL

This method uses the client's scraping functionality to retrieve the complete web page content, which may include additional information not present in the search result snippet.

Returns

Promise<WebPageData>

A promise that resolves to WebPageData containing the scraped content

Example

const pageData = await result.scrapeUrl();
console.log('Full page title:', pageData.title);
console.log('Full page content:', pageData.text);

flatten()

flatten(): FlattenResult

Defined in: src/search/result.ts:310

Converts the Result to a flattened structure

This method transforms the nested Result object into a flat structure where semantic properties are top-level fields. This is useful for serialization, storage, or when working with systems that prefer flat data structures.

Returns

FlattenResult

A FlattenResult object with all properties flattened to top level

Example

const flattened = result.flatten();
console.log('Similarity score:', flattened.similarity);
console.log('Chunks matched:', flattened.chunks_matched);

data()

data(): object

Defined in: src/search/result.ts:362

Returns a plain object representation of the Result data

This method provides a clean object with all the result properties, maintaining the nested structure for semantic data. It's useful for serialization, logging, or when you need to work with the raw data without the class methods.

Returns

object

A plain object containing all result properties

url_hash

url_hash: string

url

url: string

netloc

netloc: string

published

published: string

visited

visited: string

language

language: string

author

author: string

title

title: string

description

description: string

content

content: string

best_chunk

best_chunk: string

brand_safety

brand_safety: string | null

continent

continent: string | null

region

region: string | null

country

country: string | null

sector

sector: string | null

industry_group

industry_group: string | null

industry

industry: string | null

sub_industry

sub_industry: string | null

iab_tier_1

iab_tier_1: string | null

iab_tier_2

iab_tier_2: string | null

iab_tier_3

iab_tier_3: string | null

iab_tier_4

iab_tier_4: string | null

semantics

semantics: object

semantics.origin_shard

origin_shard: number

semantics.chunks_total

chunks_total: number

semantics.chunks_matched

chunks_matched: number

semantics.chunks_kept

chunks_kept: number

semantics.similarity

similarity: number

semantics.bitstring

bitstring: string

Example

const rawData = result.data();
console.log('Result metadata:', rawData.semantics);

// Serialize to JSON
const json = JSON.stringify(rawData, null, 2);