PokeAPI / PokeAPI/pokeapi

JSON-LD / RDF support

Open
#1,483 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.4k
Forks
1.2k
Avg merge
2d 5h
Merged PRs (30d)
21

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files, tests, or entry points. Start by tracing how the API handles Accept headers and response formats, then determine the JSON-LD representation and ontology scope. Done would require an agreed implementation plan and support for the requested JSON-LD form.

Written by the indexing model from the issue text.

Assessment

Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.