> For the complete documentation index, see [llms.txt](https://docs.pandium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pandium.com/getting-started/pandium-integration-tutorial/pokemon-of-the-day-part-1/write-the-integration-in-typescript/add-the-pokemon-client.md).

# Add the Pokémon client

A client is a class with methods that allow you to interact a particular API, e.g. making asynchronous requests to fetch and post records. You will import the PokéAPI's client from a library.

At the moment the code doesn't have any Pokémon information to work with, so let's set up a Pokémon client that will fetch our first Pokémon of the day!

1. Run `npm install pokedex-promise-v2 --save`.

The [docs for this library](https://www.npmjs.com/package/pokedex-promise-v2?activeTab=readme#install-) show how to create an instance of a Pokémon client.

2. In `src/index.ts` import `Pokedex` from the Pokémon library, and create an instance of the Pokémon client. Do this within the `run` function so that your code will be able to use it when it runs.
3. Use the [`getPokemonByName` method ](https://www.npmjs.com/package/pokedex-promise-v2?activeTab=readme#pokemon)from your instance of the Pokémon client to fetch a Pokémon by name .

At this point your src/index.ts should look like this:

```typescript
import * as dotenv from 'dotenv'
dotenv.config()
import Pokedex from 'pokedex-promise-v2'
import { Config, Secret, Context } from './lib.js'

const run = async () => {
    const context = new Context()
    const secrets = new Secret()
    const config = new Config()

    console.error(`This run is in mode: ${context['run_mode']}`)
    console.error('------------------------CONFIG------------------------')
    console.error(config)

    console.error('------------------------CONTEXT------------------------')
    console.error(context)

    const pokeClient = new Pokedex()

    const tyranitar = await pokeClient.getPokemonByName('tyranitar')
    console.error(tyranitar)
}

run().then(
    () => {},
    () => {
        process.exitCode = 1
    }
)
```

4. Run `npm run build && npm run start`.

You should see something like this logged - except that the printed object should include the whole `tyranitar` object.

```
> pokemon-of-the-day@1.0.0 start
> node build/src/

This run is in mode: normal
------------------------CONFIG------------------------
Config {}
------------------------CONTEXT------------------------
Context { run_mode: 'normal' }
{
  abilities: [
    { ability: [Object], is_hidden: false, slot: 1 },
    { ability: [Object], is_hidden: true, slot: 3 }
  ],
  ... further properties of the Pokémon Tyranitar
}
```

This shows the Pokémon client works, so you can remove the logic for fetching and logging out `tyranitar`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pandium.com/getting-started/pandium-integration-tutorial/pokemon-of-the-day-part-1/write-the-integration-in-typescript/add-the-pokemon-client.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
