Understanding the amiiboapi.com Public API with JavaScript Examples

Introduction

When building web applications, APIs are an essential part of integration between applications. One of such public APIs is amiiboapi.com which provides a RESTful interface for third party developers. This API provides details and information related to amiibo characters from various Nintendo games. This blog post will provide a basic understanding of how the amiiboAPI works using JavaScript examples.

API Endpoints

The amiiboAPI provides the following endpoints:

  • /amiibo – Retrieves all the available amiibo characters
  • /amiibo/?name={name} – Retrieves amiibo characters with a specific name
  • /amiibo/?gameSeries={gameSeries} – Retrieves amiibo characters belonging to a specific game series
  • /amiibo/?character={character} – Retrieves amiibo characters of a specific type/character
  • /amiibo/?amiiboSeries={amiiboSeries} – Retrieves amiibo characters belonging to a specific amiibo series
  • /amiibo/?releaseDate={YYYY-MM-DD} – Retrieves amiibo characters released on a specific date
  • /amiibo/?apiEndpoint={apiEndpoint} – Retrieves amiibo characters with a specific API endpoint

API Response

The API returns a JSON object containing the amiibo characters requested with all relevant information related to the amiibo. A sample response from the amiibo endpoint is shown below:

{
  amiibo: [
    {
      amiiboSeries: "Super Smash Bros.",
      character: "Mario",
      gameSeries: "Super Mario",
      head: "00000000",
      image: "https://raw.githubusercontent.com/N3evin/AmiiboAPI/master/images/icon_00000000-00000002.png",
      name: "Mario",
      release: {
        au: "2014-11-29",
        eu: "2014-11-28",
        jp: "2014-12-06",
        na: "2014-11-21"
      },
      tail: "00000002",
      type: "Figure"
    },
    {
      amiiboSeries: "Super Smash Bros.",
      character: "Donkey Kong",
      gameSeries: "Donkey Kong",
      head: "00020000",
      image: "https://raw.githubusercontent.com/N3evin/AmiiboAPI/master/images/icon_00020000-00020002.png",
      name: "Donkey Kong",
      release: {
        au: "2014-11-29",
        eu: "2014-11-28",
        jp: "2014-12-06",
        na: "2014-11-21"
      },
      tail: "00020002",
      type: "Figure"
    }
    // More amiibos....
  ]
}

Example Code

Installation

Before we can start using the API, we need to install a package called axios. Open your terminal and navigate to your project. Use the command below to install axios.

npm install axios

Retrieving All Amiibos

To retrieve all the available amiibo characters, we can simply make an HTTP GET request to the amiibo endpoint using the axios package. The code sample below demonstrates how this can be done.

import axios from 'axios';
    
axios.get('http://www.amiiboapi.com/api/amiibo')
  .then(response => console.log(response.data.amiibo))
  .catch(error => console.log(error));

The response can be seen in the console and can be manipulated to use in the client-side.

Retrieving Amiibos by Name

To retrieve amiibo characters with a specific name, we can use the /amiibo/?name={name} endpoint. The code sample below demonstrates how this can be done.

import axios from 'axios';

axios.get('http://www.amiiboapi.com/api/amiibo/?name=Link')
  .then(response => console.log(response.data.amiibo))
  .catch(error => console.log(error));

Retrieving Amiibos by Series

To retrieve amiibo characters belonging to a specific game series, we can use the /amiibo/?gameSeries={gameSeries} endpoint. The code sample below demonstrates how this can be done.

import axios from 'axios';
    
axios.get('http://www.amiiboapi.com/api/amiibo/?gameSeries=Super%20Mario')
  .then(response => console.log(response.data.amiibo))
  .catch(error => console.log(error));

Conclusion

Now that we have seen how to retrieve amiibo information using the amiiboapi.com API with JavaScript, you can use this knowledge in your web applications to add amiibo character information to your users. For more information on the API or how to use axios with other libraries, visit amiiboapi.com or the official axios documentation.

Related APIs in Games & Comics