# go-pkparse-server

`go-pkparse-server` is a multi-generational pokemon parser written in Go.


### API Usage

##### `POST /parse`

Query Params as multipart form:

| Param   | Required | Description                                                                      |
| ---     | ---      | ---                                                                              |
| pokemon | ✔️        | One or more pk7 files uploaded in a multipart form and/or base64 encoded strings |

Query Params as JSON:

| Param   | Required | Description                            |
| ---     | ---      | ---                                    |
| pokemon | ✔️        | JSON array of base64 encoded pk7 files |

Response:

| Param          | Description                                            |
| ---            | ---                                                    |
| pokedex_number | National pokedex number of the pokemon                 |
| nickname       | The UTF-16LE encoded nickname of the pokemon           |
| raw_nickname   | Base 64 encoded byte string of the pokemon's nickname  |
| raw_pokemon    | Base 64 encoded byte string of the entire pokemon data |

Sample request and response:

`curl -X POST http://localhost:8080/parse -F "pokemon=/path/to/thefile.pk7" -F "pokemon=wJsMkgAAN4IZAAAA0qVgJQAAAAAJAQAA7DtV5QAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAFAAaQBrAGEAYwBoAHUAAAAAAAAAAAAAAAAA8QFVABgB5wAPDw8PAAAAAFUAYgBXAGEAAAAWYq41UABQAG8AcgBnAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAARgAAAAAAAAAAAAAAAABBAHMAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAEYAAAAAAAAAAAARChAAAABBnAQBAB9OAAICAAAAAA==" -H "Content-Type: multipart/form-data"`:
**or**
`curl -X POST http://localhost:8080/parse -H "Content-Type: application/json" -d '{"pokemon":["ewMXgQAA3QEUAAAAbaoyREAfAAAvBAAAQ1aIAxISAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFIAYQB0AGkAYwBhAHQAZQAAAAAAAAAAAAAApAB1AVMBngAKDxQPAAAAAAAAAAAAAAAAAAA8/P8XUABQAG8AcgBnAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAARgAAAAAAAAAAAAAAAABQAFAAbwByAGcAAAAAAAAAAAAAAAAAAAAAAEYAAAAAAAAAAAARCxIAAADKAAQUACEBAgACAAAAAA==","wJsMkgAAN4IZAAAA0qVgJQAAAAAJAQAA7DtV5QAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAFAAaQBrAGEAYwBoAHUAAAAAAAAAAAAAAAAA8QFVABgB5wAPDw8PAAAAAFUAYgBXAGEAAAAWYq41UABQAG8AcgBnAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAARgAAAAAAAAAAAAAAAABBAHMAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAEYAAAAAAAAAAAARChAAAABBnAQBAB9OAAICAAAAAA=="]}'`:
```
{
   [
      {
         "nickname" : "R\u0000a\u0000t\u0000i\u0000c\u0000a\u0000t\u0000e\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
         "pokedex_number" : 20,
         "raw_nickname" : "UgBhAHQAaQBjAGEAdABlAAAAAAAAAAAA",
         "raw_pokemon" : "ewMXgQAA3QEUAAAAbaoyREAfAAAvBAAAQ1aIAxISAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFIAYQB0AGkAYwBhAHQAZQAAAAAAAAAAAAAApAB1AVMBngAKDxQPAAAAAAAAAAAAAAAAAAA8/P8XUABQAG8AcgBnAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAARgAAAAAAAAAAAAAAAABQAFAAbwByAGcAAAAAAAAAAAAAAAAAAAAAAEYAAAAAAAAAAAARCxIAAADKAAQUACEBAgACAAAAAA=="
      },
      {
         "nickname" : "P\u0000i\u0000k\u0000a\u0000c\u0000h\u0000u\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000",
         "pokedex_number" : 25,
         "raw_nickname" : "UABpAGsAYQBjAGgAdQAAAAAAAAAAAAAA",
         "raw_pokemon" : "wJsMkgAAN4IZAAAA0qVgJQAAAAAJAQAA7DtV5QAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAFAAaQBrAGEAYwBoAHUAAAAAAAAAAAAAAAAA8QFVABgB5wAPDw8PAAAAAFUAYgBXAGEAAAAWYq41UABQAG8AcgBnAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAARgAAAAAAAAAAAAAAAABBAHMAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAEYAAAAAAAAAAAARChAAAABBnAQBAB9OAAICAAAAAA=="
      }
   ]
}
```

Sample error response:

| Param | Description              |
| ---   | ---                      |
| error | description of the error |

Example error:
`curl -X POST http://localhost:8080/parse -F "pokemon=/path/to/an/invalidfile.pk7" -H "Content-Type: multipart/form-data"`:
```
{
  "error": "Invalid length for generation 7 pokemon: 229 bytes"
}
```

