yahsieh / vt-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VTuber API

Development

  • Prerequisites

  • Installation

# Install dependencies and create your .env copy
$ npm i
$ cp .env.sample .env

# Make sure to adjust your .env file before continuing!

# Check the template.json file inside the channels folder first! Then run:
$ npm run init

# If all things went well, you can then start the api.
$ npm start

API Basics

Queries

  • any[] are queries split with ,.
    • Example: status=live,upcoming
  • Add queries by adding parameters to GET requests.
    • Example using node-js with axios:
const axios = require('axios');
const parameters = { status: 'live,upcoming', title: 'apex' };

axios.get('http://localhost:2434/live', { params: parameters })
  .then(res => console.log(res.data));
  • Access nested fields query with . or ().
    • Example:
const singleFields = { id: 1, fields: 'id,channel_stats.views,channel_stats.subscribers' };
const multipleFields = { id: 1, fields: 'id,channel_stats(views,subscribers)' };
const eitherFields = { id: 1, fields: 'id,channel_stats(views),channel_stats.subscribers' }

/**
 * Any of these queries will return:
 * [
 *   {
 *     id: 1,
 *     channel_stats: {
 *       views: number,
 *       subscribers: number
 *     }
 *   }
 * ]
 */

Endpoints

/live

Displays live, upcoming, and ended videos.

Query parameters:
{
  "status": "string[]",
  "title": "string",
  "group": "string"
}
Returns:
{
  "live": "object[]",
  "upcoming": "object[]",
  "ended": "object[]"
}
Video object:
{
  "id": "string",
  "title": "string",
  "channel": "string",
  "group": "string",
  "published_at": "number",
  "scheduled_time": "number",
  "start_time": "number",
  "end_time": "number",
  "length": "number",
  "viewers": "number",
  "status": "string"
}

/channels

Shows a list of all channels (Max 150).

Query parameters:
{
  "id": "number[]",
  "name": "string",
  "group": "string",
  "youtube": "string[]",
  "channel": "string",
  "fields": "string[]",
  "limit": "number"
}

You can use number ranges for id query, example:

// Any of these queries will return channels with ids from 1 to 5
const idArray = { id: '1,2,3,4,5' };
const idRange = { id: '1-5' };
const idBoth = { id: '1,2,3-5' };
Returns:
[
  {
    "id": "number",
    "name_jp": "string",
    "name_en": "string",
    "youtube": "string",
    "twitter": "string",
    "channel": "string",
    "channel_stats": {
      "published_at": "number",
      "views": "number",
      "subscribers": "number",
      "videos": "number",
    },
    "description": "string",
    "thumbnail": "string"
  }
]

/videos

Shows a list of all videos (Max 100).

Query parameters:
{
  "group": "string[]",
  "status": "string[]",
  "channel": "string[]",
  "title": "string",
  "fields": "string[]",
  "limit": "number"
}
Returns:
[
  {
    "id": "string",
    "title": "string",
    "channel": "string",
    "group": "string",
    "published_at": "number",
    "scheduled_time": "number",
    "start_time": "number",
    "end_time": "number",
    "length": "number",
    "status": "string"
  }
]

TO-DOs

  • Add support for Bilibili channels(?)
  • Sort queries
  • API documentation
  • Cooler name, maybe?

About

License:Do What The F*ck You Want To Public License


Languages

Language:JavaScript 69.3%Language:HTML 21.4%Language:CSS 6.8%Language:Shell 1.9%Language:Dockerfile 0.5%