A YouTube API client for Edge environments
npm install youtubeapi-edgeYouTubeAPI-Edge is a lightweight library for interacting with the YouTube API, designed to run seamlessly in modern JavaScript environments, including edge platforms like Cloudflare Workers.
Note: This library is a work in progress. Currently, only list methods for GET requests are supported. Expect potential bugs and missing features.
---
- Edge-compatible: Designed to run in environments that support the Web standard fetch API, such as Cloudflare Workers.
- Standardized HTTP client: Uses the Web standard fetch API instead of Node.js-specific HTTP libraries like http or axios, ensuring broad compatibility.
- Familiar and intuitive interface: Mirrors the interface of the official Google API Node.js Client for ease of use.
Install the library using your preferred package manager:
``bash`
npm install youtubeapi-edgeOR
yarn add youtubeapi-edgeOR
pnpm add youtubeapi-edge
---
To use the library, initialize it with your Google API key and specify the API version (default is v3).
`typescript
import { youtubeapiEdge } from "youtubeapi-edge";
const youtube = youtubeapiEdge({
auth: process.env["GOOGLE_API_KEY"]!, // Replace with your API key
version: "v3",
});
const result = await youtube.channels.list({
id: channelId, // Replace with the target channel ID
part: ["snippet"],
});
`
---
This library is designed to align with the interface of the official Google API Node.js Client. Below are some of the supported endpoints and examples of how to use them.
`typescript`
const result = await youtube.channels.list({
id: channelId, // Replace with the target channel ID
part: ["snippet"],
});
`typescript`
const result = await youtube.videos.list({
id: videoId, // Replace with the target video ID
part: ["snippet", "statistics"],
});
`typescript`
const result = await youtube.search.list({
part: ["snippet"],
q: "query", // Replace with your search query
});
`typescript`
const result = await youtube.playlists.list({
channelId: channelId, // Replace with the target channel ID
part: ["snippet"],
});
`typescript`
const result = await youtube.commentThreads.list({
videoId: videoId, // Replace with the target video ID
part: ["snippet", "replies"],
});
`typescript`
const result = await youtube.comments.list({
parentId: commentParentId, // Replace with the parent comment ID
part: ["snippet"],
});
`typescript``
const result = await youtube.videoCategories.list({
part: ["snippet"],
});