drawing

Animal Crossing is a well known series exclusive to Nintendo. Originally called "Animal Forest" when it first released on the Nintendo 64 in 2001, it is a simulation game where the player takes the role of a human managing a countryside village of animals. The newest title Animal Crossing: New Horizons (ACNH) on the Switch system has been a huge success for Nintendo, being the second most sold title on the Nintendo Switch (Covid-19 confinement had a lot to do with it). There is a huge community behind this title, most notably through the amazing discord forum.

Whenever a title gains popularity, it attracts a lot of talented people developing open-source companion softwares to help others.
Here I wil talk about the free and open source RESTful ACNH API developped mostly by alexislours. It is for example used in the really nice AC helper app I am using.

tl;dr

  1. ACNH api is a free RESTful API for all Animal Crossing New Horizons content.
  2. Using the request lib, it is possible to get the content through the ACNH api endpoint.

RESTful api

Representational state transfer (REST) is a software architectural style initiated by Roy Fielding, that defines a set of constraints to be used for creating Web services [1]. When using a RESTful api, you will usually make requests to specific URLs, and get the relevant data back in the response.
This has many advantages: scalability, flexibility, portability and low resources usage (an important criteria when developing mobile apps). One of its main disadvantage is that it is heavily dependent on the server and the internet connection.

There are four data transactions in any REST system (and HTTP specs): POST (create), GET (read), PUT (edit) and DELETE. Here, we will mostly use GET requests.

ACNH API

The ACNH api is a free RESTful API for critters, fossils, art, music, furniture and villagers from Animal Crossing: New Horizons. No authentification is needed, and all the data will be available in the json format.

For the following, we will use the python requests library.

In [1]:

We start by creating a function to create POST requests, adn get the result as a dict.

In [2]:
# Create a GET request on the server, and get the response as a json object
def request_json(https):
    resp = requests.get(https)
    if resp.status_code != 200:
        # This means something went wrong.
        raise Exception('{}: Error {}'.format(https, resp.status_code))

    return resp.json()

Let's list all the fishes available in ACNH, and take one randomly.

In [3]:
# Get the information from a random fish
# fixing the random state
seed = 0
np.random.seed(seed)
# getting json information from the api
api_endpoint = 'http://acnhapi.com/v1/{}'
fishes = request_json(api_endpoint.format('fish'))
fish_name = np.random.choice(list(fishes.keys()))
seleted_fish = fishes[fish_name]
print(seleted_fish)
{'id': 45, 'file-name': 'saddled_bichir', 'name': {'name-USen': 'saddled bichir', 'name-EUen': 'saddled bichir', 'name-EUde': 'Flösselhecht', 'name-EUes': 'bichir ensillado', 'name-USes': 'bichir ensillado', 'name-EUfr': 'bichir', 'name-USfr': 'bichir', 'name-EUit': 'polipteride', 'name-EUnl': 'kwastsnoek', 'name-CNzh': '恩氏多鳍鱼', 'name-TWzh': '恩氏多鰭魚', 'name-JPja': 'エンドリケリー', 'name-KRko': '엔드리케리', 'name-EUru': 'многопер Эндлихера'}, 'availability': {'month-northern': '6-9', 'month-southern': '12-3', 'time': '9pm - 4am', 'isAllDay': False, 'isAllYear': False, 'location': 'River', 'rarity': 'Uncommon', 'month-array-northern': [6, 7, 8, 9], 'month-array-southern': [12, 1, 2, 3], 'time-array': [21, 22, 23, 0, 1, 2, 3]}, 'shadow': 'Medium (4)', 'price': 4000, 'price-cj': 6000, 'catch-phrase': 'Wow! A saddled bichir! And me without my tiny riding crop...', 'museum-phrase': "What an elegant specimen you've found. The saddled bichir has a look entirely its own. They have poor eyesight, so they use their fine-tuned sniffers to seek out prey. Can you imagine relying solely on your sense of smell to find food? And if one nostril became clogged, would you be unable to tell how far away the scent was?", 'image_uri': 'https://acnhapi.com/v1/images/fish/45', 'icon_uri': 'https://acnhapi.com/v1/icons/fish/45'}

It is of course possible to show the graphical content of this fish:

In [4]:
# read the fish image and icon in a numpy array
fish_img = plt.imread(seleted_fish['image_uri'])
fish_icon = plt.imread(seleted_fish['icon_uri'])
In [5]:

We can make smart search through the data, for example listing all peppy villagers.

In [6]:
# getting json information from the api
villagers = request_json(api_endpoint.format('villagers'))
peppy_villagers = []
peppy_imgs = []
for villager in villagers:
    if villagers[villager]['personality'] == 'Peppy':
        peppy_imgs += [villagers[villager]['image_uri']]
        peppy_villagers += [villagers[villager]['name']['name-EUfr']]
print('Here is the list of all peppy villagers : {}'.format(peppy_villagers))
Here is the list of all peppy villagers : ['Mathilda', 'Anabelle', 'Rosine', 'Tutu', 'Titi', 'Neige', 'Rosie', 'Marine', 'Tigri', 'Suzy', 'Maud', 'Myrtille', 'Rosalie', 'Margaux', 'Cookie', 'Olympe', 'Terrine', 'Pompon', 'Caro', 'Ketchup', 'Rénata', 'Esther', 'Hippy', 'Victoria', 'Anne', 'Lili', 'Belle', 'Sucrette', 'Annie', 'Missy', 'Justine', 'Laurie', 'Trufa', 'Rose', 'Clara', 'Dorothée', 'Gaby', 'Nadia', 'Rubis', 'Kristine', 'Zoé', 'Sylvette', 'Karen', 'Rachida', 'Lola', 'Ninjette', 'Bengale', 'Noémie', 'Monica']

And their posters,

In [7]:

Finally, let's analyze the dominant colors in all ACNH houseware items.

In [8]:

The most used color for houseware items in AC NH is the white.

References

1. Fielding, R.T., Taylor, R.N.: Architectural styles and the design of network-based software architectures. University of California, Irvine Irvine (2000).