PokeAPI/api-data

Default picture

Closed this issue · 7 comments

I mentioned this in PokeAPI/pokedex-promise-v2#61 before.

The idea was to set a default picture in the case that a API element need one but has none.

This is already did in some of the items in the API data, which use a question mark picture in pixel art.

Hi, sorry but I have to reject this idea. We are serving data and we don't do business logic. It's left to the developer to decide what to do if the sprite is missing.

Moreover, How could developers know that the sprite is missing if we serve a default one?

Because you put an identificable symbol like the question mark that is showed in some items (I don't have the ids here but I saw them while testing the API).

Yeah, but programmatically they would have to implement a picture parser. APIs should be machine-readable, not human-readable.

I dont get what you mean.

You already serve image links for the rest. You would only need to provide a link for the default picture and a default picture already exists for some items in the form of a question mark.

But what if another user of the API wants a different default image? They would have to know that a question mark image is the default image provided by the API. Naramsim is suggesting leaving the field as null so that way any developer can choose what default image to use when the value returned is null, and not leave it up to the API to decide for every developer. This leaves the API to just serve data and not give opinionated results.

APIs should be machine-readable, not human-readable.

To both: would this proposal to the wrapper make more sense, since it already encapsulates the API requests.

No, because ultimately we want developers to have full flexibility. So porting this feature to a wrapper (i.e. pokedex-promise-v2) wouldn't be accepted.

const pokemon = fetch('api_url').json()
if (pokemon.sprites.front_default === null) {
  // render your default sprite for missing pokemon
} else {
  // render pokemon.sprites.front_default
}