aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Data/senpy.ts
blob: 9f85f1ed632750b504184f59bec38d19ba6acc5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const senpyAPI = 'https://api.senpy.club/v2';

export interface SenpyRandomImage {
  language: string;
  image: string;
}

class Senpy {
  static async getImages(language: string): Promise<string[]> {
    language = language.replace('#', '%23');

    const response = await fetch(`${senpyAPI}/language/${language}`);

    return await response.json();
  }

  static async getLanguages(): Promise<string[]> {
    const response = await fetch(`${senpyAPI}/languages`);

    return await response.json();
  }

  static async getRandomImage(): Promise<SenpyRandomImage> {
    const response = await fetch(`${senpyAPI}/random`);

    return await response.json();
  }
}

export default Senpy;