Hierarchy (View Summary)

Constructors

Properties

apiExtra?: unknown
apiKey?: string
apiUrl: string
apiUrlPlaceholder: string = "https://api-edge.cognitive.microsofttranslator.com"
baseLang: string = config.baseLang
fetchOpts: Record<string, unknown>
headers: { "Content-Type": string; "User-Agent": string } = ...
origin: string
originPlaceholder: string = "https://www.bing.com"
sessionUrl: string = "https://edge.microsoft.com"

Methods

  • Returns Promise<{ creationTimestamp: number; maxAge: number; token: string }>

  • Parameters

    • body: null | string
    • headers: Record<string, string> = {}
    • method: RequestMethod = "POST"

    Returns {
        body: null | string;
        headers: {
            "Content-Type": string;
            Origin: string;
            Referer: string;
            "User-Agent": string;
        };
        method: RequestMethod;
    }

  • Parameters

    • params: Record<string, string> = {}

    Returns string

  • You can use this method if you need a multi detect

    Parameters

    • text: string | string[]

    Returns Promise<
        {
            isTranslationSupported: boolean;
            isTransliterationSupported: boolean;
            language: string;
            score: number;
        }[],
    >

  • The standard method for requesting the API, if necessary, you can override how it is done in the example

    Type Parameters

    • T extends object

    Parameters

    • path: string
    • body: null | string = null
    • headers: Record<string, string> = {}
    • method: RequestMethod = "POST"

    Returns Promise<ProviderResponse<T>>