Now we'll update BROCK's Pokémon or, more aptly, his party of Pokémon.
First, let's inspect BROCK's current party by making a request to the GET /v1/trainers/parties/:trainer_id
endpoint:
curl \
-H 'Authorization: Bearer <access_token>' \
https://api.pkmnapi.com/v1/trainers/parties/34
Yielding:
{
"data": {
"id": "34",
"type": "trainer_parties",
"attributes": {
"parties": [
{
"party": [
{
"level": 12,
"pokemon": {
"id": "74",
"type": "pokemon_names",
"attributes": {
"name": "GEODUDE"
},
"links": {
"self": "https://api.pkmnapi.com/v1/pokemon/names/74"
}
}
},
{
"level": 14,
"pokemon": {
"id": "95",
"type": "pokemon_names",
"attributes": {
"name": "ONIX"
},
"links": {
"self": "https://api.pkmnapi.com/v1/pokemon/names/95"
}
}
}
]
}
]
},
"links": {
"self": "https://api.pkmnapi.com/v1/trainers/parties/34"
}
},
"links": {
"self": "https://api.pkmnapi.com/v1/trainers/parties/34"
}
}
📄 Trainers may have more than one party for different encounters (because trainers are re-used in different locations). For example, the YOUNGSTER trainer has 13 parties (some of which are unused). Gym leaders (with the exception of Giovanni) only have 1 party because they are only battled once.
Now let's fill his party with a bunch of level 5 Geodude!
The game stores parties in 1 of 2 ways:
Because the first way takes up less space, we can actually fill BROCK's party with 4 Geodude of the same level, where before he only had room for a Geodude and Onix of different levels.
Let's do so by sending a request to the POST /v1/trainers/parties/:trainer_id
endpoint:
curl \
-X POST \
-H 'Authorization: Bearer <access_token>' \
-H "X-Patch-Description: Nerf BROCK's party" \
-H 'Content-Type: application/json' \
-d '{
"data": {
"type": "trainer_parties",
"attributes": {
"parties": [
{
"party": [
{
"level": 5,
"pokemon": {
"id": "74"
}
},
{
"level": 5,
"pokemon": {
"id": "74"
}
},
{
"level": 5,
"pokemon": {
"id": "74"
}
},
{
"level": 5,
"pokemon": {
"id": "74"
}
}
]
}
]
}
}
}' \
https://api.pkmnapi.com/v1/trainers/parties/34
As always, we should verify that our change stuck:
curl \
-H 'Authorization: Bearer <access_token>' \
https://api.pkmnapi.com/v1/trainers/parties/34
Yielding:
{
"data": {
"id": "34",
"type": "trainer_parties",
"attributes": {
"parties": [
{
"party": [
{
"level": 5,
"pokemon": {
"id": "74",
"type": "pokemon_names",
"attributes": {
"name": "GEODUDE"
},
"links": {
"self": "https://api.pkmnapi.com/v1/pokemon/names/74"
}
}
},
{
"level": 5,
"pokemon": {
"id": "74",
"type": "pokemon_names",
"attributes": {
"name": "GEODUDE"
},
"links": {
"self": "https://api.pkmnapi.com/v1/pokemon/names/74"
}
}
},
{
"level": 5,
"pokemon": {
"id": "74",
"type": "pokemon_names",
"attributes": {
"name": "GEODUDE"
},
"links": {
"self": "https://api.pkmnapi.com/v1/pokemon/names/74"
}
}
},
{
"level": 5,
"pokemon": {
"id": "74",
"type": "pokemon_names",
"attributes": {
"name": "GEODUDE"
},
"links": {
"self": "https://api.pkmnapi.com/v1/pokemon/names/74"
}
}
}
]
}
]
},
"links": {
"self": "https://api.pkmnapi.com/v1/trainers/parties/34"
}
},
"links": {
"self": "https://api.pkmnapi.com/v1/trainers/parties/34"
}
}
That should make (B)ROCK an easier challenge!