neuwo-api
Version:
TypeScript/JavaScript SDK client for the Neuwo content classification API
85 lines • 3.96 kB
TypeScript
/**
* EDGE API client for Neuwo API.
*
* This module provides a client for analysis where content is identified by URL (websites).
*/
import { GetAiTopicsResponse } from "./models.js";
import type { EdgeGetAiTopicsParams, EdgeGetAiTopicsWaitParams } from "./types.js";
/**
* Client for Neuwo EDGE API endpoints.
*
* EDGE endpoints operate over standard HTTP methods and use an EDGE API token passed as a query parameter.
* EDGE endpoints are designed for client-side integration where content is identified by URL.
* The EDGE API serves publishers who want to enrich the data of published articles.
*/
export declare class NeuwoEdgeClient {
private static readonly DEFAULT_TIMEOUT;
private readonly requestHandler;
private readonly defaultOrigin?;
/**
* Initialise the EDGE API client.
*
* @param config - Client configuration
* @param config.token - EDGE API authentication token
* @param config.baseUrl - Base URL for the API server
* @param config.timeout - Request timeout in seconds (default: 60)
* @param config.defaultOrigin - Default origin header for requests
*/
constructor(config: {
token: string;
baseUrl: string;
timeout?: number;
defaultOrigin?: string;
});
/**
* Retrieve AI-generated tags for a URL (raw response).
*
* Returns the raw HTTP response without parsing.
*
* @returns Raw HTTP Response object
* @throws {ValidationError} If URL is invalid
* @throws {AuthenticationError} If token is invalid
* @throws {ForbiddenError} If token lacks permissions
* @throws {NoDataAvailableError} If URL hasn't been processed yet
* @throws {ContentNotAvailableError} If tagging could not be created
* @throws {NeuwoAPIError} For other API errors
*/
getAiTopicsRaw(params: EdgeGetAiTopicsParams): Promise<Response>;
/**
* Retrieve AI-generated tags and classifications for a URL.
*
* If the URL has been processed by the Neuwo crawler, returns tags, brand safety,
* marketing categories (IAB Content Taxonomy, IAB Audience Taxonomy, Google Topics),
* and smart tags for the article.
*
* When called for the first time with a specific URL or if the URL is still in the
* queue being processed, raises NoDataAvailableError (the URL is queued for
* processing, which typically takes 10-60 seconds).
*
* @returns GetAiTopicsResponse object containing tags, brand safety, marketing categories, and smart tags
* @throws {ValidationError} If URL is invalid
* @throws {AuthenticationError} If token is invalid
* @throws {ForbiddenError} If token lacks permissions
* @throws {NoDataAvailableError} If URL hasn't been processed yet
* @throws {ContentNotAvailableError} If tagging could not be created
* @throws {NeuwoAPIError} For other API errors
*/
getAiTopics(params: EdgeGetAiTopicsParams): Promise<GetAiTopicsResponse>;
/**
* Retrieve AI-generated tags for a URL with automatic retry on 404.
*
* This method automatically handles the case when a URL hasn't been processed yet.
* It will wait and retry multiple times until the data is available or max retries
* is reached. Typically processing takes 10-60 seconds for new URLs.
*
* @returns GetAiTopicsResponse object containing tags, brand safety, marketing categories, and smart tags
* @throws {ValidationError} If URL is invalid
* @throws {AuthenticationError} If token is invalid
* @throws {ForbiddenError} If token lacks permissions
* @throws {NoDataAvailableError} If data not available after max retries
* @throws {ContentNotAvailableError} If tagging could not be created
* @throws {NeuwoAPIError} For other API errors
*/
getAiTopicsWait(params: EdgeGetAiTopicsWaitParams): Promise<GetAiTopicsResponse>;
}
//# sourceMappingURL=edge-client.d.ts.map