Generate PokemonGo RPC Protos to Csharp

2016/7/132 min read
bookmark this
Responsive image

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.

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.

A:\protoc-3.0.0-win32\bin

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.

C:\Python27
C:\Python27\Scripts

3. Compile all the PokemonGO Api Protos

Once you get the Protos and 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.

python compile.py

Output result of csharp classes

After run the command line, you'll get all the csharp classes as following at out folder.