> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript and Node.js SDK requests, types, and pagination

> Request and response types, file uploads, and automatic pagination.

## Request & Response types

This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:

```ts theme={null}
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});

const params: Telnyx.NumberOrderCreateParams = {
  phone_numbers: [{ phone_number: '+15558675309' }],
};
const numberOrder: Telnyx.NumberOrderCreateResponse = await client.numberOrders.create(params);
```

Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.

## Auto-pagination

List methods in the Telnyx API are paginated.
You can use the `for await … of` syntax to iterate through items across all pages:

```ts theme={null}
async function fetchAllAccessIPAddressResponses(params) {
  const allAccessIPAddressResponses = [];
  // Automatically fetches more pages as needed.
  for await (const accessIPAddressResponse of client.accessIPAddress.list({
    'page[number]': 1,
    'page[size]': 50,
  })) {
    allAccessIPAddressResponses.push(accessIPAddressResponse);
  }
  return allAccessIPAddressResponses;
}
```

Alternatively, you can request a single page at a time:

```ts theme={null}
let page = await client.accessIPAddress.list({ 'page[number]': 1, 'page[size]': 50 });
for (const accessIPAddressResponse of page.data) {
  console.log(accessIPAddressResponse);
}

// Convenience methods are provided for manually paginating:
while (page.hasNextPage()) {
  page = await page.getNextPage();
  // ...
}
```
