Headers for interacting with Yandex API
Protected
apiOptional
headers: Record<string, string>Optional
method: stringProtected
getProtected
getThe standard method for requesting the Yandex API, if necessary, you can override how it is done in the example
import { getVideoData } from "../packages/node/dist/utils/videoData";
import { ClientResponse } from "../packages/core/dist/types/client";
// https://github.com/axios/axios
const client = new (class AxiosVOTClient extends VOTClient {
async request<T = unknown>(
path: string,
body: Uint8Array,
headers: Record<string, string> = {},
method = "POST",
): Promise<ClientResponse<T>> {
try {
const res = await axios({
url: `https://${this.host}${path}`,
method,
headers: {
...this.headers,
...headers,
},
data: body,
responseType: "arraybuffer",
...this.fetchOpts,
});
return {
success: res.status === 200,
data: res.data as T,
};
} catch (err) {
return {
success: false,
data: (err as Error)?.message,
};
}
}
//...
})();
const videoData = await getVideoData("https://youtu.be/LK6nLR1bzpI");
Optional
headers: Record<string, string>Optional
method: stringOptional
body: unknownOptional
headers: Record<string, string>Optional
method: stringOptional
headers: Record<string, string>Optional
partialAudio: undefinedOptional
headers: Record<string, string>Optional
headers: Record<string, string>Protected
translateProtected
translate
If you don't want to use the classic fetch
Example