Fetching Data

This guide will help you get started with fetching data from the API.

When you have set up your application and created a new application, you can start fetching data from the API. We do ask that you cache the data to prevent unnecessary requests to the API. If you need to update the data, you can do so by setting up a cron job to fetch the data at a specific interval. See the Caching Data guide for more information.

Fetching Data

To fetch data from the API, you can use the following code snippet:

fetch.ts
import { fetch } from 'vtubers';
// If you are using a library that has fetch, you can use:
// import { fetch as fetchVtubers } from 'vtubers';

const data = await fetch('users/someUsername', {
    method: 'GET',
    query: {
        someKey: 'someValue',
    },
    headers: {
        'X-My-Header': 'someValue',
    },
    body: {
        someKey: 'someValue',
    },
});

Replace someUsername with the username of the user you want to fetch data for.