Posts

Showing posts from April, 2026

How to Use APIs in a Web Game (Pokémon Example with JSON Optimization)

How I Built a Pokémon API Game and Optimized It Using JSON I built a simple browser game where you compare two Pokémon and guess which one has higher stats. The idea is very simple. You see two Pokémon and pick the one you think has the higher value. The game uses real data from an API, in this case the PokéAPI. That makes it a good small project to understand how APIs work in a real scenario. Overview Random Pokémon Generator Fetching Data per Round Using a Local JSON File Performance Impact Conclusion At the beginning I used the most direct approach. Every time the user clicked a button, the game sent a fetch request to the API. I had already used this pattern in an earlier project, a random Pokémon generator, so it felt natural to reuse it. For that kind of tool it works fine. The problem started when I turned the idea into a game. In a higher or lower game you do not just fetch once. You fetch multiple times per round. One round needs two Pokémon. Ten rounds can...