Nookipedia / nookipedia-api

Nookipedia's custom API for querying data from the Animal Crossing video game series.
https://api.nookipedia.com/
MIT License
42 stars 12 forks source link

`/nh/fish` and `/nh/bugs`: `"time"` property is always empty #76

Closed WillsterJohnson closed 2 years ago

WillsterJohnson commented 2 years ago

Problem

EDIT: this applies to /nh/bugs and /nh/bugs/{bug} too.

When querying the /nh/fish or /nh/fish/{fish} endpoints, seemingly with any params, there is no data for the time property.

Looking on the docs, there should be;

[
  {
    "url": "https://nookipedia.com/wiki/Cherry Salmon",
    "name": "Cherry Salmon",
    "number": 27,
    "image_url": "https://dodo.ac/np/images/d/db/Cherry_Salmon_NH_Icon.png",
    "render_url": "https://dodo.ac/np/images/c/c0/Cherry_Salmon_NH.png",
    "time": "4 PM – 9 AM", HERE
    "location": "River (clifftop)",
    "shadow_size": "Small",
    "rarity": "Uncommon",
    "total_catch": 100,
    "sell_nook": 1000,
    "sell_cj": 1500,
    "tank_width": 1,
    "tank_length": 1,
    "catchphrases": [],
    "north": {},
    "south": {}
  }
]

Example

Code

import fetch from "node-fetch";
import dotenv from "dotenv";
dotenv.config();

// retrieve data from api
const response = await fetch(`https://api.nookipedia.com/nh/fish`, {
  headers: {
    "X-API-KEY": process.env["NOOKIPEDIA_API_KEY"],
    "Accept-Version": "1.5.0",
    "content-type": "application/json",
  },
});
// get data as object
const allFishData = await response.json();
// print to console an array of { "fish name": "fish's time property" }
console.log(
    allFishData.map(
      (fish) => ({ [fish.name]: fish.time })
    )
  );

Expected

An array of data following the form;

[
  { Anchovy: "X AM - Y PM" },
  { Angelfish:"X AM - Y PM" },
  { Arapaima: "X AM - Y PM" },
  // ...etc
]

Actual

An array of data following the form;

[
  { Anchovy: undefined },
  { Angelfish: undefined },
  { Arapaima: undefined },
  // ...etc
]
Show data ```js [ { Anchovy: undefined }, { Angelfish: undefined }, { Arapaima: undefined }, { Arowana: undefined }, { 'Barred Knifejaw': undefined }, { Barreleye: undefined }, { Betta: undefined }, { Bitterling: undefined }, { 'Black Bass': undefined }, { Blowfish: undefined }, { 'Blue Marlin': undefined }, { Bluegill: undefined }, { 'Butterfly Fish': undefined }, { Carp: undefined }, { Catfish: undefined }, { Char: undefined }, { 'Cherry Salmon': undefined }, { 'Clown Fish': undefined }, { Coelacanth: undefined }, { Crawfish: undefined }, { 'Crucian Carp': undefined }, { Dab: undefined }, { Dace: undefined }, { Dorado: undefined }, { 'Football Fish': undefined }, { 'Freshwater Goby': undefined }, { Frog: undefined }, { Gar: undefined }, { 'Giant Snakehead': undefined }, { 'Giant Trevally': undefined }, { 'Golden Trout': undefined }, { Goldfish: undefined }, { 'Great White Shark': undefined }, { Guppy: undefined }, { 'Hammerhead Shark': undefined }, { 'Horse Mackerel': undefined }, { Killifish: undefined }, { 'King Salmon': undefined }, { Koi: undefined }, { Loach: undefined }, { 'Mahi-Mahi': undefined }, { 'Mitten Crab': undefined }, { 'Moray Eel': undefined }, { Napoleonfish: undefined }, { 'Neon Tetra': undefined }, { 'Nibble Fish': undefined }, { Oarfish: undefined }, { 'Ocean Sunfish': undefined }, { 'Olive Flounder': undefined }, { 'Pale Chub': undefined }, { Pike: undefined }, { Piranha: undefined }, { 'Pond Smelt': undefined }, { 'Pop-Eyed Goldfish': undefined }, { 'Puffer Fish': undefined }, { Rainbowfish: undefined }, { 'Ranchu Goldfish': undefined }, { Ray: undefined }, { 'Red Snapper': undefined }, { 'Ribbon Eel': undefined }, { 'Saddled Bichir': undefined }, { Salmon: undefined }, { 'Saw Shark': undefined }, { 'Sea Bass': undefined }, { 'Sea Butterfly': undefined }, { 'Sea Horse': undefined }, { 'Snapping Turtle': undefined }, { 'Soft-Shelled Turtle': undefined }, { Squid: undefined }, { Stringfish: undefined }, { Sturgeon: undefined }, { Suckerfish: undefined }, { Surgeonfish: undefined }, { Sweetfish: undefined }, { Tadpole: undefined }, { Tilapia: undefined }, { Tuna: undefined }, { 'Whale Shark': undefined }, { 'Yellow Perch': undefined }, { 'Zebra Turkeyfish': undefined } ] ```

What this means

The time property is not being set, or is being set to None/null/undefined by the API.

The part where I guess what's wrong and am probably off by a mile

I'd guess this is a remnant of a previous version of the API where instead of monthly time data for the hemispheres, it was just a single datapoint. Unless this was never a thing, then I'd guess I'm wrong.

Either that or it's just a mistake in the docs, an accident in the schema, something like that.

KevinPayravi commented 2 years ago

Thank you for pointing this out, and for the detailed description!

Your guess is correct, that root-level time field is leftover from a previous version of the API. We moved all the time info into the north and south objects since times can vary between months. More details at https://github.com/Nookipedia/nookipedia-api/issues/14.

I've updated the docs to remove the time field.