To authenticate your requests with the TruPDF API, users need to generate an API token from their profile settings and include it in the Authorization header of API requests.

Here's how you can authenticate your requests:

  1. User Registration: Users need to register on the TruPDF website to access the API.

  2. Generate API Token: Once registered, users can generate an API token from their profile settings.

  3. Include Token in Requests: Include the generated API token in the Authorization header of your API requests.

Example using cURL: #

curl -X GET \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  https://trupdf.com/api/v1/whoami

Example using PHP: #

// Using PHP
use GuzzleHttp\Client;

$client = new Client();
$token = 'YOUR_API_TOKEN';
$response = $client->get('https://trupdf.com/api/v1/whoami', [
    'headers' => [
        'Authorization' => 'Bearer ' . $token
    ]
]);

$userInfo = json_decode($response->getBody(), true);

Response from 'whoami' Endpoint #

Upon successful authentication, the whoami endpoint will return the user's information in the following format:

{
  "name": "Joe Doe",
  "username": "joe",
  "email": "[email protected]"
}

Replace YOUR_API_TOKEN with the token obtained in Step 2 to authenticate your requests successfully.