# Initialize the client

Let's begin by initializing the API client in our `form.php` file. Copy this code:

```php
<?php
use Deskpro\API\DeskproClient;
use Deskpro\API\Exception\APIException;

include(__DIR__ . '/vendor/autoload.php');

// Pass the URL to your Deskpro instance when creating the client.
$client = new DeskproClient('http://deskpro.company.com');

// `Many API methods require authentication. Set the ID of the user
// to authenticate with and either the auth key or token.`
$client->setAuthKey(1, 'dev-admin-code');
// $client->setAuthToken(1, 'AWJ2BQ7WG589PQ6S862TCGY4');

try {
    $resp = $client->get('/articles');
    print_r($resp->getData());
    print_r($resp->getMeta());
} catch (APIException $e) {
    echo $e->getMessage();
}
```

Run this page in your browser and you'll see a bunch of JSON output. Something like:

```
Array
(
    [0] => Array
        (
            [id] => 1
            [title] => "Mary Had a Little Lamb"
            ...
        )

    [1] => Array
        (
            [id] => 2
            [title] => "Baa Baa Black Sheep"
            ...
        )
)
```

```
Array
(
    [pagination] => Array
        (
            [total] => 2
            [count] => 2
            [per_page] => 10
            [current_page] => 1
            [total_pages] => 1
        )
)
```


---

# Agent Instructions: 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:

```
GET https://deskpro.gitbook.io/dev-guide/getting-started-with-the-api/php/initialize-the-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
