Skip to content

JSON-LD / RDF support #1483

@veeara282

Description

@veeara282

I think it would be valuable to be able to use a PokéAPI endpoint as a canonical URL within RDF linked data, so other RDF documents can refer to Pokémon concepts. For example, someone could make character bios using JSON-LD that look like:

{
  "@context": {
    "@vocab": "https://schema.org/",
    "pkmn": "https://pokemonkg.org/ontology/version/1.0.0"
  },
  "@id": "<...>",
  "@type": "Person",
  "name": "Meowth",
  "description": "Team Rocket's Meowth",
  "url": "https://bulbapedia.bulbagarden.net/wiki/Meowth_(Team_Rocket)",
  "pkmn:species": { "@id": "https://pokeapi.co/api/v2/pokemon-species/meowth" },
  "gender": { "@id": "https://schema.org/Male" },
  "memberOf": {
    "@type": "Organization",
    "name": "Team Rocket",
    "url": "https://bulbapedia.bulbagarden.net/wiki/Team_Rocket"
  },
  "knows": {
    "@id": "<...>",
    "@type": "Person",
    "name": "Meowzie",
    "url": "https://bulbapedia.bulbagarden.net/wiki/Meowzie",
    "pkmn:species": { "@id": "https://pokeapi.co/api/v2/pokemon-species/meowth" },
    "gender": { "@id": "https://schema.org/Female" }
  }
}

This would be very useful for creating original characters in a somewhat-standard machine-readable format, e.g. for use in TTRPG campaigns.

Some notes:

  • There is a readily available Pokémon ontology for RDF, but we could extend it or make our own for PokéAPI if it doesn't have all the features we need.
  • In the example above, I used the Person type from Schema.org (https://schema.org/Person) as it integrates with the rest of the Schema.org ontology - for example, the CreativeWork.character property takes a Person as its value to represent a character within a creative work. However, the Comic Book Ontology also provides a dedicated Character type (https://comicmeta.org/cbo/#Character).

Similar to MusicBrainz, a client could request the JSON-LD for a Pokémon concept by modifying its HTTP request in the following form:

GET /api/v2/pokemon-species/meowth HTTP/2
Host: pokeapi.co
Accept: application/ld+json

or alternatively append ?format=json-ld to the resource URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions