https://github.com/miguelo981/viewstats-api
Unofficial viewstats API wrapper for Nodejs and Deno.
https://github.com/miguelo981/viewstats-api
api deno mrbeast nodejs viewstats
Last synced: 5 months ago
JSON representation
Unofficial viewstats API wrapper for Nodejs and Deno.
- Host: GitHub
- URL: https://github.com/miguelo981/viewstats-api
- Owner: Miguelo981
- License: mit
- Created: 2024-10-23T13:50:21.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-10-23T14:59:07.000Z (7 months ago)
- Last Synced: 2024-12-18T04:36:40.880Z (5 months ago)
- Topics: api, deno, mrbeast, nodejs, viewstats
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/viewstats-api
- Size: 11.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# viewstats-api
`viewstats-api` is an unofficial wrapper for the ViewStats API, designed to work with both Node.js and Deno. It provides easy-to-use methods to interact with ViewStats, retrieve channel data, and perform advanced searches.## Features
- Retrieve channel statistics, averages, and rankings
- Fetch featured videos and popular channels
- Advanced search capabilities for YouTube channels## Installation
### Node.js
Install the package via npm:
```bash
npm install viewstats-api
```### Deno
Import the package from your repository URL:
```typescript
import { ViewStatsAPI } from "https://github.com/Miguelo981/viewstats-api/raw/main/index.ts";
```### API Key
To use the `viewstats-api`, you'll need to obtain an API key. This can be done by inspecting the network requests in your browser.
#### Steps to get your API Key:
1. Open your browser and navigate to the ViewStats website.
2. Open the **Developer Tools** (usually by pressing `F12` or `Ctrl+Shift+I`).
3. Go to the **Network** tab and perform any action that makes a request to the ViewStats API (e.g., searching for a channel).
4. Look for the request in the **Network** tab and select it.
5. Under the **Headers** section, find the **Authorization** header.
6. Copy the value of the **Bearer token**. This is your API key.### Usage
#### Basic Example```typescript
import { ViewStatsAPI } from "viewstats-api";const apiToken = "your_api_token";
const api = new ViewStatsAPI(apiToken);// Retrieve channel data by ID
const channel = await api.getChannel("mrbeast");
```## API Methods
| Method | Description |
|--------|-------------|
| `getChannel(channelId: string): Promise` | Fetch channel details by channel ID. |
| `getChannelStats(channelId: string, params: ChannelStatsParams): Promise` | Retrieve detailed statistics for a channel, including views, subscribers, and video counts. |
| `getChannelAverage(channelId: string): Promise` | Get average stats such as views and estimated revenue over a period of time. |
| `getChannelLongAndShort(channelId: string): Promise` | Retrieve long and short video statistics for a channel. |
| `getChannelFeaturedVideo(channelId: string): Promise` | Fetch the featured video of a channel. |
| `advancedChannelSearch(params: ChannelAdvancedSearchParams): Promise` | Perform an advanced search for channels based on specific criteria. |
| `getRankingChannels(params: RankingChannelsParams): Promise` | Fetch the rankings of channels based on subscribers or views. |
| `getPopularChannels(length: number = 10): Promise` | Retrieve a list of popular channels. |## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Contributing
Feel free to open issues and pull requests on the [GitHub repository](https://github.com/Miguelo981/viewstats-api/issues).