Giter Club home page Giter Club logo

pokeapi.co's Introduction


PokeAPI

build status data status deploy status License Backers on Open Collective Sponsors on Open Collective



A RESTful API for Pokémon - pokeapi.co

Beta GraphQL support is rolling out! Check out the GraphQL paragraph for more info.

Setup   pyVersion310

  • Download this source code into a working directory, be sure to use the flag --recurse-submodules to clone also our submodules.

  • Install the requirements using pip:

    make install
    # This will install all the required packages and libraries for using PokeAPI
  • Set up the local development environment using the following command:

    make setup
  • Run the server on port 8000 using the following command:

    make serve

Database setup

To build or rebuild the database by applying any CSV file update, run

make build-db

Visit localhost:8000/api/v2/ to see the running API!

Each time the build-db script is run, it will iterate over each table in the database, wipe it, and rewrite each row using the data found in data/v2/csv.

If you ever need to wipe the database use this command:

make wipe-sqlite-db

If the database schema has changed, generate any outstanding migrations and apply them

make make-migrations
make migrate

Run make help to see all tasks.

Docker and Compose   docker hub

There is also a multi-container setup, managed by Docker Compose V2. This setup allows you to deploy a production-like environment, with separate containers for each service, and is recommended if you need to simply spin up PokéAPI.

Start everything by

make docker-setup

If you don't have make on your machine you can use the following commands

docker compose up -d
docker compose exec -T app python manage.py migrate --settings=config.docker-compose
docker compose exec -T app sh -c 'echo "from data.v2.build import build_all; build_all()" | python manage.py shell --settings=config.docker-compose'

Browse localhost/api/v2/ or localhost/api/v2/pokemon/bulbasaur/ on port 80.

To rebuild the database and apply any CSV file updates, run

make docker-build-db

If the database schema has changed, generate the migrations and apply those

make docker-make-migrations
make docker-migrate

GraphQL  

When you start PokéAPI with the above Docker Compose setup, an Hasura Engine server is started as well. It's possible to track all the PokeAPI tables and foreign keys by simply

# hasura cli needs to be installed and available in your $PATH: https://hasura.io/docs/latest/graphql/core/hasura-cli/install-hasura-cli.html
# hasura cli's version has to greater than v2.0.8
make hasura-apply

When finished browse http://localhost:8080 and you will find the admin console. The GraphQL endpoint will be hosted at http://localhost:8080/v1/graphql.

A free public GraphiQL console is browsable at the address https://beta.pokeapi.co/graphql/console/. The relative GraphQL endpoint is accessible at https://beta.pokeapi.co/graphql/v1beta

A set of examples is provided in the directory /graphql/examples of this repository.

Kubernetes   Build Docker image and create k8s with it

Kustomize files are provided in the folder https://github.com/PokeAPI/pokeapi/tree/master/Resources/k8s/kustomize/base/. Create and change your secrets:

cp Resources/k8s/kustomize/base/secrets/postgres.env.sample Resources/k8s/kustomize/base/secrets/postgres.env
cp Resources/k8s/kustomize/base/secrets/graphql.env.sample Resources/k8s/kustomize/base/secrets/graphql.env
cp Resources/k8s/kustomize/base/config/pokeapi.env.sample Resources/k8s/kustomize/base/config/pokeapi.env
# Edit the newly created files

Configure kubectl to point to a cluster and then run the following commands to start a PokéAPI service.

kubectl apply -k Resources/k8s/kustomize/base/
kubectl config set-context --current --namespace pokeapi # (Optional) Set pokeapi ns as the working ns
# Wait for the cluster to spin up
kubectl exec --namespace pokeapi deployment/pokeapi -- python manage.py migrate --settings=config.docker-compose # Migrate the DB
kubectl exec --namespace pokeapi deployment/pokeapi -- sh -c 'echo "from data.v2.build import build_all; build_all()" | python manage.py shell --settings=config.docker-compose' # Build the db
kubectl wait --namespace pokeapi --timeout=120s --for=condition=complete job/load-graphql # Wait for Graphql configuration job to finish

This k8s setup creates all k8s resources inside the Namespace pokeapi, run kubectl delete namespace pokeapi to delete them. It also creates a Service of type LoadBalancer which is exposed on port 80 and 443. Data is persisted on 12Gi of ReadWriteOnce volumes.

Wrappers

Official wrapper Repository Features
Node server-side PokeAPI/pokedex-promise-v2 Auto caching
Browser client-side PokeAPI/pokeapi-js-wrapper Auto caching, Image caching
Java/Kotlin PokeAPI/pokekotlin
Python 2/3 PokeAPI/pokepy Auto caching
Python 3 PokeAPI/pokebase Auto caching, Image caching
Wrapper Repository Features
.Net Standard mtrdp642/PokeApiNet Auto caching
Dart prathanbomb/pokedart
Go mtslzr/pokeapi-go Auto caching
PHP lmerotta/phpokeapi Auto caching, lazy loading
PowerShell Celerium/PokeAPI-PowerShellWrapper
Python beastmatser/aiopokeapi Auto caching, asynchronous
Ruby rdavid1099/poke-api-v2
Rust lunik1/pokerust Auto caching
Scala juliano/pokeapi-scala Auto caching
Spring Boot dlfigueira/spring-pokeapi Auto caching
Swift kinkofer/PokemonAPI
Typescript server-side/client-side Gabb-c/Pokenode-ts Auto caching

Donations

Help to keep PokéAPI running! If you're using PokéAPI as a teaching resource or for a project, consider sending us a donation to help keep the service up. We get 1+ billion requests a month!

Thank you to all our backers! Become a backer

Join Us On Slack!

Warning Currently no maintainer has enough free time to support the community on Slack. Our Slack is in an unmaintained status.

Have a question or just want to discuss new ideas and improvements? Hit us up on Slack. Consider talking with us here before creating a new issue. This way we can keep issues here a bit more organized and helpful in the long run. Be excellent to each other 😄

Sign up easily!

Once you've signed up visit PokéAPI on Slack

Contributing

This project exists thanks to all the people who contribute

All contributions are welcome: bug fixes, data contributions, and recommendations.

Please see the issues on GitHub before you submit a pull request or raise an issue, someone else might have beat you to it.

To contribute to this repository:

  • Fork the project to your own GitHub profile

  • Download the forked project using git clone:

    git clone --recurse-submodules [email protected]:<YOUR_USERNAME>/pokeapi.git
  • Create a new branch with a descriptive name:

    git checkout -b my_new_branch
  • Write some code, fix something, and add a test to prove that it works. No pull request will be accepted without tests passing, or without new tests if new features are added.

  • Commit your code and push it to GitHub

  • Open a new pull request and describe the changes you have made.

  • We'll accept your changes after review.

Simple!

Deprecation

As of October 2018, the v1 API has been removed from PokéAPI. For more information, see pokeapi.co/docs/v1.html.

pokeapi.co's People

Contributors

ajimenezucla avatar beastmatser avatar cmmartti avatar emw3 avatar fallendeity avatar gabrielsroka avatar henrikac avatar henriqueartur avatar holly-hacker avatar hrkings avatar imgbotapp avatar jintoyamanaka avatar jtwotimes avatar juliano avatar kronopt avatar mattxwang avatar mlemesle avatar mtslzr avatar naramsim avatar phalt avatar rdavid1099 avatar rnegron avatar rocco avatar sargunv avatar tdmalone avatar thidinh21 avatar triangulum avatar usagi-f avatar veteranovis avatar vitalyavolyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pokeapi.co's Issues

Slack

The Slack link you provided is not up to date(I clicked it, and it gave me a message that said, "This link is no longer active
To join this workspace, you’ll need to ask the person who originally invited you for a new link."). I am spectacular in HTML Dev and a little bit of Python.

Incorrect types in documentation

When putting together my rust wrapper I found some fields whose types are incorrectly documented. Here's a complete list to the best of my knowledge:

  • condition field of EncounterConditionValue should be NamedAPIResource (EncounterCondition), is list NamedAPIResource (EncounterCondition)
  • category field of Item should be NamedAPIResource (ItemCategory), is ItemCategory
  • pokemon field of ItemHolderPokemon should be NamedAPIResource (Pokemon), is string
  • rarity field of ItemHolderPokemonVersionDetail should be integer, is string
  • items field of ItemFlingEffect should be list NamedAPIResource (Item), is NamedAPIResource (Item)
  • language field of MoveFlavorText should be NamedAPIResource (Language), is list NamedAPIResource (Move)
  • version_group field of MoveFlavorText should be NamedAPIResource (VersionGroup), is list NamedAPIResource (Move)
  • category field of MoveMetaData should be NamedAPIResource (MoveCategory), is NamedAPIResource (Move)
  • pokemon_species field of PokemonShape should be list NamedAPIResource (PokemonSpecies), is list PokemonSpecies
  • characteristics field of Stat ahould be list APIResource (Characteristic), is APIResource (Characteristic)

Issues with the V2 documentation page

There are several issues with the V2 documentation page.
I tried to fix them by myself, I even followed the installation guide and was able to quickly have a local instance of the site running, but I don't know much about node.js, so I got stuck there.

"Contents" side bar

By using the side bar, we can notice that some links are linking to the wrong resources:

  • Contest Types links to Encounter Conditions
  • Contest Effects links to Evolution Triggers
  • Encounter Conditions links to Item Attributes
  • Evolution Triggers links to Pal Park Areas
  • Pokedexes links to Move Ailments
  • Version Groups links to Move Targets
  • Item Attributes links to Natures
  • Item Fling Effects links to Pokémon Forms
  • Move Ailments links to nowhere
  • Move Damage Classes links to nowhere
  • Move Targets links to nowhere
  • Characteristics links to nowhere
  • Natures links to nowhere
  • Pokemon links to the wrong header (also called 'Pokemon')
  • Pokémon Forms links to nowhere
  • Pokémon Shapes links to nowhere
  • Stats links to nowhere

Locations and Machines link to nowhere and their children links don't show up at all.

The following resources don't show up in the side bar at all:

  • Resource Lists / Un-named
  • Resource Lists / Named
  • Utility / Languages
  • Utility / Common Models

The highlight which is supposed to indicate the current section doesn't correctly highlight every resource. Some resources are not highlighted.

Resource description

Almost all resources have a small description before the GET text. I noticed this description is in the respective json in the src/docs/ folder.
For example, the Berry Flavors resource has the following description in src/docs/berries.json:

Flavors determine whether a Pokémon will benefit or suffer from eating a berry based on their nature. Check out Bulbapedia for greater detail.

However, from the resources that have a description in their respective json in src/docs/, some are missing that description in the documentation.
The following are missing the description in the documentation:

  • Berries
  • Contest Types
  • Contest Effects
  • Super Contest Effects
  • Encounter Conditions
  • Encounter Condition Values
  • Evolution Triggers
  • Generations
  • Pokedexes
  • Version
  • Version Groups
  • Item
  • Item Attributes
  • Item Categories
  • Item Fling Effects
  • Item Pockets
  • Locations
  • Location Areas
  • Pal Park Areas
  • Regions
  • Machines
  • Moves
  • Move Ailments
  • Move Battle Styles
  • Move Damage Classes
  • Move Learn Methods
  • Move Targets
  • Abilities
  • Characteristics
  • Egg Groups
  • Natures
  • Pokeathlon Stats
  • Pokemon
  • Pokémon Colors
  • Pokémon Forms
  • Pokémon Habitats
  • Pokémon Shapes
  • Pokémon Species
  • Stats
  • Types
  • Languages

The following have no small description at all (not in the documentation and not in the src/docs/*.json):

  • Un-named
  • Named
  • Berry Firmnesses
  • Common Models

GET

Contest Types shows GET /api/v2/berry-firmness/{id or name}/ over the correct GET text.

The text GET /api/v2/<resource_name>/{id or name}/ has different sizes all across the documentation. The following have a smaller size and I think should be changed to match the others:

  • Berries
  • Berry Firmness
  • Contest Effects
  • Encounter Conditions
  • Evolution Triggers
  • Pokedexes
  • Version Groups
  • Item Attributes
  • Item Fling Effects
  • Locations
  • Pal Park Areas
  • Machines
  • Move Ailments
  • Move Damage Classes
  • Move Targets
  • Characteristics
  • Natures
  • Pokemon
  • Pokémon Forms
  • Pokémon Shapes
  • Stats
  • Languages

Sorry for the huge wall of text 😅

npm i error

Trying to install project locally and it breaks in Win10 and Ubuntu. Tried latest and stable node with no luck.

npm ERR! In file included from /home/suns/.node-gyp/16.13.1/include/node/v8.h:30,
npm ERR! from /home/suns/.node-gyp/16.13.1/include/node/node.h:63,
npm ERR! from ../src/common.cc:22:
npm ERR! /home/suns/.node-gyp/16.13.1/include/node/v8-internal.h: In function ‘void v8::internal::PerformCastCheck(T*)’:
npm ERR! /home/suns/.node-gyp/16.13.1/include/node/v8-internal.h:492:38: error: ‘remove_cv_t’ is not a member of ‘std’; did you mean ‘remove_cv’?
npm ERR! 492 | !std::is_same<Data, std::remove_cv_t>::value>::Perform(data);

Please provide OS, node/npm compatible version you have successfully installed and run project

Add Digital Ocean logo

We're still using a server provided for free by Digital Ocean, so their logo should still be on the website somewhere (probably on the home page beside the Netlify logo).

Invalid redirect

When typing in the URL https://pokeapi.co/docs , an invalid redirect occurs.
Instead of being redirected to https://pokeapi.co/docs/v2 , you are redirected to docs/v2 (The browser looks for docs/v2 on the user's machine)
If the issue wasn't understood then this image might help.
image

I'm not that knowledgeable about JS but I think this line is the offending one

location_area_encounter response doesn't match docs

Looking through some of the other issues, this has been a little bit of a common thread among users, but I've found (yet another) difficulty with this data field.

The docs don't match what the API gives as a response. For example, take Butterfree.

  • Lookup butterfree.
  • The value for location_area_encounters is /api/v2/pokemon/12/encounters (this has already been brought up in PokeAPI/pokeapi#270).
  • The docs say that location_area_encounters should be an array/list of location_areas, each having a name and a url.

I saw from PokeAPI/pokeapi#332 that the url (instead of an array) was implemented as a temp fix, but could the docs be update to reflect this change? The other thing I'm wondering, is what is the planned future of this endpoint/data? I want to know how my code should handle the server's response. It seems like the intended behavior is ambiguous here, and I'm hoping we can get a definite answer for what's wanted and implement it everywhere, docs & all.

Edit this page

We could add in the footer an 'edit this page' link. So that if I am browsing the about page, clicking on this button will redirect me to https://github.com/PokeAPI/pokeapi.co/blob/master/src/pages/about.html.js

An example is vue: https://vuejs.org/v2/guide/ look at the footer

I think it can be done by looking at the URL the user is currently browsing and replacing the base URL with the Github's one. Something like:

`https://github.com/PokeAPI/pokeapi.co/tree/master/src/pages${window.location.pathname}.js`

This will also increase the popularity of this repo 😄

PS: @cmmartti why the about, the v1 and v2 files are named .html.js? While the others are only .js?

Documentation page is not mobile-friendly

It's fine for now because not many people will be looking up documentation on their `phones, but on smaller viewports I'd like to swap out the table of contents on the left for a stickied breadcrumbs menu bar. The breadcrumbs would show the current page section (such as "Items > Item Categories"), and clicking on each crumb would open a list of links to the crumb's sibling sections.

Working on this now.

Idea: Cosmetic Features

I want to show some of my suggestions regarding this website. Here are the lists of ideas:

  • Dark Mode: A toggle button for dark mode
  • Search Bar: Similar to Stripe's search bar
  • Design Revamp: A change in ui such as typography and layout

I shall contribute into this project if you think these ideas are relevant to the PokeAPI Community. I will then propose the new design of the website in this issue thread if i have no issue with time.

RealmIO Database

Hey, so over the past week I've been working on a little sub project of a larger one and was wondering what everyone's thoughts on it were... I scraped all of the v2 csv data and parsed it into a Realm Database with all appropriate linkages to associated fields. I did this for a few reasons...

  1. I wanted to have a completely locally hosted instance of the entire pokeAPI data source so I wasn't dependent on making API calls (not having internet would suck)
  2. I wanted to create an interface layer on top of that which would make it super easy and super fast to get all relevant data instead of having to send new API calls for sub data (which was solved with RealmIO's relationship models)
  3. I was bored and thought it might be cool and useful for anyone else that didn't want to rely on making network calls

Anyways, would be happy to upload the current instance of realmDB files and all Class definitions (currently ONLY written in swift), but wanted to ask about it all first :)

Screen Shot 2021-01-30 at 12 49 20 PM

Drop DO mention

We shouldn't mention anymore that DigitalOcean supports us.

Footer sometimes gets stuck

The footer sometimes gets stuck and covers the page. Something's wonky with the CSS. I'll investigate later.

stuck-footer

Add a little more explanation on height and weight

From PokeAPI/pokeapi#380:

When I create a sample request for a pokemon, say Garchomp (445), I get that its weight is stored as 950 (950 what?) and its height 19. Checking bulbapedia and pokemondb, I see that these values should be 95.0 and 1.9 respectively. Evidently, these values are ten times what they should be. This can be seen with other pokemon as well.

While this data comes directly from Veekun and we don't modify it, we could definitely document a little more, particularly the units used. Our documentation currently just says:

height: The height of this Pokémon.
weight: The weight of this Pokémon.

Look at deployment on to Firebase

Because we're now looking at Firebase for the API hosting (due to issues with Netlify), it would be preferable to deploy the documentation site on to our Firebase account as well.

We could technically have the static site on Netlify and the API on Firebase, but it introduces more moving parts - chiefly a proxy on one of the services, because the doc site & API are on the same domain.

Documentation json for Evolution Chains

In the documentation for Evolution chains, the GET /api/v2/evolution-chain/{id}/ section displays a JSON as an example (see this link). This JSON contains a format error related to the evolution_details node for Ratticate.

We can see that the doc says this node should be a list EvolutionDetail. However, the JSON displays the node as a regular object (i.e. { ... } instead of [ { ... } ].

Google has index'd /about/ so loads 404

Google has index/cached '/about/' as a page, which if you click on returns 404 as react is looking for /about.html to load the view. I'd suggest removing form google if you can or maybe just doing an OR of the location so it will redirect/load anyway.

I've forked but thought it would probably be easier to leave the decision up to you guys!

Documentation jump/hash links regenerate incorrectly upon browser refresh

After navigating to a specific documentation breadcrumb and refreshing, the url changes from url#id to url/#id (added forward slash). The elements no longer retain correct id's and consequently the breadcrumb jumplinks no longer work. Appears inconsistent as not all sections are affected.

In the image below section/sub-section "Pokemon Shapes" has an id of "item-pockets" and "PokemonSpecies", "itempocket"

https://pokeapi.co/docs/v2.html#pokemon-shapes => https://pokeapi.co/docs/v2.html/#pokemon-shapes

bad-jumplinks

Unable to get results due to "TypeError: Failed to execute on 'fetch' on 'Window'"

Discovered this awesome API today. I cannot make any calls as the following error message occurs:

API call: https://pokeapi.co/api/v2/berry-flavor/1/
API request source: Directly within pokeapi.co
Browser: Chrome
Browser mode: Default and Incognito

Error message: "An error occurred: "TypeError: Failed to execute 'fetch' on 'Window': The provided value 'force-cached' is not a valid enum value of type RequestCache."

I have attempted other endpoints as well and the same error message occurred:

  • pokemon/ditto/
  • ability/4/

Please see the attached screenshot.

error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.