Giter Club home page Giter Club logo

pokeapi'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   k8s status

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's People

Contributors

bitomic avatar c-garza avatar cmmartti avatar daltonsw avatar deleca7755 avatar fallendeity avatar giginet avatar greatnovadragon avatar helblinglilly avatar indyandie avatar m-zuber avatar maleclercq avatar nairraghav avatar naramsim avatar nimaje avatar penelopeysm avatar phalt avatar phrasmotica avatar porocyon avatar prathanbomb avatar relrod avatar revoice1 avatar sargunv avatar simonorono avatar simplyblgdev avatar simylo avatar skcwillie avatar tillfox avatar wyattc16 avatar zaneadix 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  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

pokeapi's Issues

Add hold/consumable items.

The only thing preventing me from using this database as the sole source of information is the fact that hold items have not been added yet. Since hold items play a big roll in competitive play, the information for these are crucial to a competitive player. Thankfully, they don't really tie to any specific Pokemon, unless you're talking about the mega evolution stones.

Missing Sprites for Pokemons

For example:

pokemon/10016/ returns "Sprites" as an empty array, sprite/10016 returns 404

Similar issue with id 10010, 10033 etc.

Add Pokemon natures

Not absolutely essential as they are only a couple dozen or so, and it's a static list, but the short list of Pokemon natures would be useful to have.

Cache-Control / ETag headers

I think using proper HTTP caching could be a great boon to client-side developers, as documented here

I'm more than willing to contribute this, but not at a computer right now, so thought I'd document it for when I get home :p

Issues installing project requirements

I've been lurking about this project off and on for a few months now and I can't seem to figure out what I need to get it working clientside. I'm very new to Python, and I thought this would be a good way to get stated on learning the language. I have two questions that are not made clear in the readme:

  1. What version of Python have you built this project against?
  2. Do I need to install separately a PostgreSQL or SQLite library before any other of my requirements? (I get an error when attempting to pip install psycopg2, troubleshooting has been spotty.)

Pardon my naivety if either of these are supposed to be implied. Absolutely none of the documentation I've found for the requirements have been helpful or user-friendly. :/

Description doesn't match the correct game/generation

As example Charmander:

Description Gen 1 Red:
http://pokeapi.co/api/v1/description/48/
"Obviously prefers hot places. When it rains, steam is said to spout from the tip of its tail."
This seems to be correct

Description Gen 2 Crystal:
The flame that burns at the tip of its tail is an indication of its emotions. The flame wavers when CHARMANDER is happy, and blazes when it is enraged.
This is the description of Sapphire and Ruby(Gen 3)

So I kept searching after the one of Gen 2 (GSC)

I found the one from gold @ http://pokeapi.co/api/v1/description/50/
But It says it's from Pokémon Red
So this is incorrect information at your database

Keep up the good work!

Getting v2 data via API?

First of all, thanks for making this!

I just set up a local copy of the app, including loading the v2 data, as per the readme. However, I'm a bit at a loss for how to actually get the API to spit out that data for me.

It looks like only v1 API endpoints exist (e.g. /api/v1/pokemon/1), as trying to go to any URL with either v2 instead of v1 or no version in the path at all (e.g. /api/v2/pokemon/1 or /api/pokemon/1) results in a 404. When I go to a valid v1 URL, I get a database error that the correct table doesn't actually exist, which suggests to me that might in fact be trying to load from v1 data (which I presumably don't have loaded).

I'm not exactly sure what the root cause of my problem is: do v2 endpoints just not exist yet? Do they exist, but I just don't know the proper URL schema? Are v1 endpoints supposed to return v2 data but my local setup is somehow incorrect? Any insight you have would be greatly appreciated.

Fuzzy string matching on resources

In V1, we can search for Pokémon via name:

HTTP GET /api/v1/pokemon/mew

This would be nice to have on other resources like types, moves, et cetera, in the V2 api

Encounter Resource retrieval

I've been looking into Location resources and their relationships to Encounter Resources, trying to figure out how things should be consumable.

It doesn't seem like Encounter resources should be individually consumable because they're kind of arbitrary.

{
    "min_level": 20,
    "max_level": 30,
    "version": {
        "name": "diamond",
        "url": "http://localhost:8000/api/v2/version/12/"
    },
    "pokemon": {
        "name": "tentacool",
        "url": "http://localhost:8000/api/v2/pokemon/72/"
    },
    location_area: {
        "name": "canalave-city-area",
        "url": "http://localhost:8000/api/v2/location-area/1/"
    }
}

It would seem to make more sense just sending them along as collections in Pokemon resources or Location Area Resources. For Example.

{
    "id": 1,
    "name": "canalave-city-area",
    "game_index": 1,
    "location": {
        "name": "canalave-city",
        "url": "http://localhost:8000/api/v2/location/1/"
    },
    "encounters": [{
        "min_level": 20,
        "max_level": 30,
        "version": {
            "name": "platinum",
            "url": "http://localhost:8000/api/v2/version/14/"
        },
        "pokemon": {
            "name": "tentacool",
            "url": "http://localhost:8000/api/v2/pokemon/72/"
        },
    },
    ...
    ]
}

Am I assuming too much in thinking that people wouldn't have much use for a single Encounter Resource? There are 44340 of them total and theres no order to what are or pokemon they're tied to. Seems futile.

ON ANOTHER NOTE

When listing available resources on a Location Area or Pokemon resource, what would be the most useful default order? Listed by Pokemon is what I'm thinking but by version or encounter method also makes sense. veekun seems to be working based on encounter method (at least visually). I might be overthinking this.

Critical Hit Ratio & Priority?

How does one go about differentiating for moves with either increased critical hit ratios, or with increased/decreased priority?

  • EX 1: Find all pokemon that can learn Skill Swap AND any move with an increased critical hit ratio (eg. Psycho Cut, Razor Wind, etc....)
  • EX 2: Find all pokemon that can learn an offensive, increased priority move (eg. Mach Punch, Feint, Pursuit, etc....)

(I'm assuming that because this is RESTful, we'll just be passing from resource to resource. The first resource for a move, and the second for a pokemon. I just don't understand how to easily differentiate for these categories.)

Thank You

Naming inconsistency for lightningrod.

Every ability name follows the same naming convention (lowercase with hyphen).
Ex: pure-power, rock-head, heavy-metal, minus.

Following this convention, the ability Lightning Rod should be named lightning-rod but in the API, it is named lightningrod.
Ex: pokemon/112

description/1/ is 404ing

Hey, my integration tests happened to catch an issue with description/1/.

Note:
description/2/ still works

Docker/Vagrant or other automation tools

It'd be super-cool if there were environment setup tools (Docker and Vagrant being the flavours of the month lately) to ease setup for contributors and create a uniform working environment.

Again, more than willing to contribute, but not at home :p

Travis CI

Let's add Travis CI so we can run tests with each pull request and commit to GitHub.

Database create fails on association

Hey there. Working on a slack-bot that requires his own pokemon database instance, was hoping I could just snag from your app. Ran into the following when I ran your build.py:

>>> execfile('data/v2/build.py')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "data/v2/build.py", line 50, in <module>
    clearTable(Language)
  File "data/v2/build.py", line 34, in clearTable
    model.objects.all().delete()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 556, in delete
    collector.collect(del_query)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/deletion.py", line 168, in collect
    reverse_dependency=reverse_dependency)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/deletion.py", line 79, in add
    if not objs:
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 145, in __nonzero__
    self._fetch_all()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 966, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 265, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 700, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 786, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: relation "pokemon_v2_language" does not exist
LINE 1: ...."iso3166", "pokemon_v2_language"."official" FROM "pokemon_v...
                                                             ^

I unfortunately do not know django well enough yet to fix this.

404 page illegible

Albeit a small issue, thought I would raise this incase it's been overlooked - The 404 page is illegible due to insufficient margin from the navbar in the current state, see photo;

screenshot 2015-03-02 20 43 41

Add a full test suite

So far, there are no complex tests to ensure the correct data is given.

Let's add a full test suite for the API and models.

resource_uri for pokemons in Pokedex api missing a '/' before api

the resource_uri for pokemons in Pokedex responce is missing a '/' before api.
All other calls have their resource_uri starting with a '/' as such;
"resource_uri": "/api/v1/ability/2/"

but the Pokedex responce doesn't
Example request

GET http://pokeapi.co/api/v1/pokedex/1/
Result:

{
"created": "2013-11-09T15:14:48.957604",
"modified": "2013-11-09T15:14:48.957565",
"name": "national",
"pokemon": [
{
"name": "pidgeotto",
"resource_uri": "api/v1/pokemon/17/"
},
...
]
}

Is there any sort of quota?

Hello,

Is there any sort of quotas that we should respect in client applications? I didn't see any relevant part in the documentation.

My use case is: I'll use http://pokeapi.co/ in my personal project to fill my database with initial attributes (for pokemons, moves, items, ect.), this will likely fire hundreds API calls in a matter of seconds without throttle. Should I do something on my side to be respectful?

Great job anyway, thanks to the contributors!

CSV to database builder

We need to implement a new way of taking CSV data and turning it into database tables, whilst still ensuring the V2 models can communicate with the data correctly.

Add a Pre-Evolution attribute

Pretty self-explanatory title, I think it's a easy thing to add, and can be useful to link pokemon of the same "family".

It can work pretty much as the "evolutions" do.

List possible IDs

Forgive me if this already exists, but is there a way to get a list of valid IDs for a resource? So for example, if I want to get all Pokemons, I'd need the list of valid IDs first.

Use Veekun's Pokedex data instead of building our own

The data currently used in PokeAPI v1 builds out it's own data set, which isn't very efficient when we want to update it or add new content.

Let's reformat the v2 resources to use a mirror or as close to the original dataset as possible.

Types don't have "resistance"

Each type has a "resistance" member (array) but no types have been assigned any "resistances" meaning all "resistance" arrays are empty.

Ability endpoint doesn't return description

According to the documentation, the abilities endpoint should return a description of the ability queried, but the description field is returning as an empty string. Were the descriptions never added to the databases or is this an error?

Getting the project set up and running locally

I must be missing something here. I've cloned the repo and have followed the setup instructions

make install
make setup
make serve

but cannot get everything working. When I run make setup I get this response:

/usr/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py:226: UserWarning: No fixture named 'dev_data' found.

I'm guessing this failure is preventing me from running the next step (setting up the v2 data), but I'm not sure.

Are the setup instructions up to date? What do I need to do to get this set up and running locally?

I'm a little confused as to what belongs in the sqlite database and what belongs in postgres. Running the make commands only puts data in postgres. I try running
python manage.py migrate --settings=config.settings (those settings provide the postgres connections, which I believe I've set up correctly), but I only get errors like

django.db.utils.ProgrammingError: column "introduces_in_version_group_id" does not exist

I want to contribute here, but I'm having a lot of difficulties getting started. Thanks to anyone in advance who's willing to help!

Missing pokemon 719 and 720

The following two pokemon exist but are not in your data set.
719: http://www.pokemon.com/us/pokedex/diancie
720: http://www.pokemon.com/us/pokedex/hoopa

 curl -XGET http://pokeapi.co/api/v1/pokemon/718/
{"abilities": [{"name": "aura-break", "resource_uri": "/api/v1/ability/167/"}], "attack": 100, "catch_rate": 0, "created": "2013-11-03T15:05:42.488796", "defense": 121, "descriptions": [{"name": "zygarde_gen_6", "resource_uri": "/api/v1/description/6609/"}, {"name": "zygarde_gen_6", "resource_uri": "/api/v1/description/6610/"}], "egg_cycles": 0, "egg_groups": [{"name": "Undiscovered", "resource_uri": "/api/v1/egg/15/"}], "ev_yield": "", "evolutions": [], "exp": 0, "growth_rate": "", "happiness": 0, "height": "0", "hp": 108, "male_female_ratio": "", "modified": "2013-11-23T13:13:48.868734", "moves": [], "name": "Zygarde", "national_id": 718, "pkdx_id": 718, "resource_uri": "/api/v1/pokemon/718/", "sp_atk": 81, "sp_def": 95, "species": "", "speed": 95, "sprites": [{"name": "zygarde", "resource_uri": "/api/v1/sprite/719/"}], "total": 0, "types": [{"name": "ground", "resource_uri": "/api/v1/type/5/"}, {"name": "dragon", "resource_uri": "/api/v1/type/16/"}], "weight": "0"}

However, curling 719 and 720 which should exist returns nothing.

 curl -XGET http://pokeapi.co/api/v1/pokemon/719/
 curl -XGET http://pokeapi.co/api/v1/pokemon/720/

Support XML on V1 resources

Some people have asked for XML data format on the V1 resources. If it is added before January 2015 it can go in.

[Question] Limited dataset upon installation

Hey there. I've forked this project, ran the make steps, and am running into an issue where I see a limited dataset (dev_data). How do I populate the rest of the information locally?

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.