> For the complete documentation index, see [llms.txt](https://docs.endless.link/endless/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.endless.link/endless/devbuild/build/endless-sdks/typescript-sdk/http-client.md).

# HTTP Client

## TS SDK HTTP Client <a href="#ts-sdk-http-client" id="ts-sdk-http-client"></a>

### Default HTTP Client <a href="#default-http-client" id="default-http-client"></a>

The SDK uses [@endless-labs/endless-client](https://www.npmjs.com/package/@endless-labs/endless-client) library with the ability to modify some request configurations like AUTH\_TOKEN, HEADERS, etc.

The @endless-labs/endless-client package supports `http2` protocol and implements 2 clients environment based:

* **axios** - To use in a browser environment (in a browser env it is up to the browser and the server to negotiate http2 connection)
* **got** - To use in a node environment (to support http2 in node environment, still the server must support http2 also)

### Custom HTTP Client <a href="#custom-http-client" id="custom-http-client"></a>

Sometimes developers want to set custom configurations or use a specific http client for queries.

The SDK supports a custom client configuration as a function with this signature:

```js
<Req, Res>(requestOptions: ClientRequest<Req>): Promise<ClientResponse<Res>>
```

:::note Both `ClientRequest` and `ClientResponse` are types defined in the SDK. :::

```js
async function customClient<Req, Res>(requestOptions: ClientRequest<Req>): Promise<ClientResponse<Res>> {
  ....
}

const config = new EndlessConfig({ client: { provider: customClient } });
const endless = new Endless(config);
```


---

# 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.endless.link/endless/devbuild/build/endless-sdks/typescript-sdk/http-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.
