How to generate Pokemon Proto API to Csharp Type
Pokemon API use Google Protocol Buffers to generate API contract to C#. This blog will demo how to do that. Following demo we'll use Protobuf's 3.0.0-beta-2 for csharp., you can download from following link, Protobuf release. Also, we'll need Python, because POGOProtos need Python to run command to generate Protos to Csharp.
- Protobuf Release
- Download google's protobuf for your enviroment.
- You can click following link to download or go to above link to check the latest version.
- Github repo contains ProtoBuf, the .proto files need to decode PokemonGo RPC api.
- Python Download
- POGOProtos need Python to run for generate Csharp type.
1. Download Google Protobuff
At this blog, I'm using the 3.0.0-beta-2 with my windows 10, once you download this to your pc, you'll also need to add path to Enviroment Variables.
Add path to System Enviroment Variables
Once you add the path, you can type
protoc at command line tools.
Following is example command line to get version of he protoc
> protoc --version
2. Download Python
You'll need Python, so go to this website to get the Python, once you download the Python, try not to change their default folder, add also add the path to the system Vnviroment Variables as well.
3. Compile all the PokemonGO Api Protos
Once you get the
Python, you can start to get what's you really want, which is the PokemonGo Protos to call Pokemon API. Go to this Github Repo to get latest souce code.
You have couple of choice to compile Protos to Csharp here, I'm using following command to compile all protos to csharp classes, you will move location to the place contains the
compile.py, then run following command line.
Output result of csharp classes
After run the command line, you'll get all the csharp classes as following at out folder.