MikuAPI

GRATUIT
Par Alessandro Schwaiger | Mise à jour 2 महीने पहले | Video, Images
Popularité

8 / 10

Latence

99ms

Niveau de service

100%

Health Check

N/A

Retour à tous les tutoriels (1)

Practical example on how to get started

So you wanna get started with the MikuAPI. Let’s see how you would do that. As an example we will be using a Discord Bot that should utilize this API. I’ll be using Java in this tutorial, but you can of course use any programming language you want.

Let’s say you have a command that should show a random Image from the API. Then we would want to target the Random Endpoint of this API. Let get started

First we create a Request for the url “https://mikuapi.p.rapidapi.com/random/true”. Let’s break it down: “https://mikuapi.p.rapidapi.com” is the base URL, means it’s what you will need for (almost) every request to this API.
the “/random” part of it defines our endpoint which is in our case the Random Endpoint.
Last but not least there’s the “/true” part, this defines that you need it for a public service, in our case Discord.

Ok let’s continue, what do we do in this code snippet after we defined the URL?
First we define that this is a GET request and then we define two special Header:

  1. x-rapidapi-key
    * In here you define your API-Key that you get from RapidAPI.
  2. x-rapidapi-host
    * In here you have to put the Base URL (https://mikuapi.p.rapidapi.com) This will not change for any Request you do.

Ok, we made a request, let’s execute it and see what we got:

Yay, we get back a simple Json String, but what’s that? Why did the Base URL change?

That’s because of the “true” we set before, this makes the API available to online services like Discord. If we would put false or nothing there it will return a RapidAPI URL which requires you to add the Key to your request.

Alright so we got our URL now just extract it, I would recommend Gson for this in Java, you can take any method you would like though.

Great we got the URL, now we just gotta send it to Discord and we’re done!

And there we go let’s look at the results!

Yay, now we can just get Images of Miku in a easy Fashion. Enjoy!