Skip to main content

Ditto is a server that serves a static copy of PokeAPI's data.

Project description

image

Ditto

https://bulbapedia.bulbagarden.net/wiki/Ditto_(Pokémon)

This repository contains:

  • a static copy of the JSON data generated from PokeAPI based on Veekun’s data
  • a PokeAPI schema generated from the above data
  • a script to serve the data in the same form as PokeAPI
  • a script to crawl an instance of PokeAPI to regenerate the data
  • a script to analyze the generated data and produce a JSON Schema

Usage

This project is on Docker Hub. If you just want to run it, you just have to run one command. Replace 8080 with the port of your choice.

docker run -p 8080:80 pokesource/ditto

Development

If you plan to edit the project, you can install it locally for development. Poetry is required.

cd ~
git clone https://github.com/PokeAPI/ditto.git
cd ditto
poetry install

# now you can run ditto!
poetry run ditto --help

Advanced

You can manually update the data if necessary. If I abandon this project, here’s how to update it. It's a bit of an involved process.

Before starting, you’ll need to install Docker and Docker Compose.

These instructions assume you've already set up the project for development in ~/ditto.

First clone the PokeAPI repository:

cd ~
git clone https://github.com/PokeAPI/pokeapi.git

Apply the patch to disable rate limiting on your local PokeAPI:

# Assuming you have the repos in ~
cd ~/pokeapi
git apply ~/ditto/extra/disable-rate-limit.patch

Run PokeAPI using docker-compose:

docker volume create --name=redis_data
docker volume create --name=pg_data
docker-compose up -d

Build the PokeAPI database:

docker-compose exec app python manage.py migrate
docker-compose exec app python manage.py shell
from data.v2.build import build_all
build_all()

The above step can take a really long time to complete. Once it’s done, you can finally update Ditto’s data:

cd ~/ditto
rm -r ./data
poetry install
poetry run ditto clone --source http://localhost/ --destination ./data
poetry run ditto analyze --api-dir ./data/api --schema-dir ./data/schema

This will crawl your local instance of PokeAPI, copy all the data to ./data, and regenerate the schema. Once that's finished, you can serve the freshly updated data!

poetry run ditto serve --port 8080

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pokeapi-ditto-0.2.0.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

pokeapi_ditto-0.2.0-py3-none-any.whl (23.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page