> For the complete documentation index, see [llms.txt](https://braindex.gitbook.io/braindex-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://braindex.gitbook.io/braindex-documentation/developer-documentation/braindex-api-integration/pathfinder-api-requesting-a-route.md).

# Pathfinder API - Requesting a Route

### Requesting a Route

A route request JSON object contains the following fields:

* chain\_id: ID number of the chain to search
* amount\_in: Hex-string formatted swap amount in
* token\_in: Hex-string formatted swap input token address
* token\_out: Hex-string formatted swap output token address
* max\_hops: The maximum number of hops a trade may use between input and output
* min\_splits: The minimum number of split paths to accept for a trade route
* max\_splits: The maximum number of split paths to accept for a trade route
* count: The number of best routes to return (currently returns 1 regardless of input)

#### Sample CURL request

```bash
curl -X POST https://api.braindex.io/app/myAppId \
    -H "Content-Type: application/json" \
    -d '{
	    	"chain_id":1284,
	    	"amount_in":"0x0579a814e10a740000",
	    	"token_in":"0xAcc15dC74880C9944775448304B263D191c6077F",
	    	"token_out":"0x818ec0a7fe18ff94269904fced6ae3dae6d6dc0b",
	    	"max_hops":3,
	    	"min_splits":0,
	    	"max_splits":3,
	    	"count":5
    	}'
```

## Route Request Parameters In-Depth

In order to preserve pathfinder performance and to prevent unnecessarily deep searches, we have defined several parameter ranges for the route request object.

#### chain\_id

You must submit a chain\_id parameter in number format with your query -- this includes single-chain protocols. For multi-chain protocols, you may change your chain\_id to route through your protocols' pools on the corresponding chain. You do not have to change your DEX ID.

Requests for routes via a chain on which you have no pools will result in a HTTP error 469: No Route Found.

#### amount\_in

amount\_in must be a hex-string formatted integer value of max uint128.

#### token\_in

token\_in must be a valid token for the chain\_id submitted along with the request.

Requests for routes with invalid tokens will result in a HTTP error 469: No Route Found.

#### token\_out

token\_out must be a valid token for the chain\_id submitted along with the request.

Requests for routes with invalid tokens will result in a HTTP error 469: No Route Found.

#### max\_hops

For performance reasons, max\_hops is capped at 4 for most networks.&#x20;

Requests for routes with max\_hops too high will result in HTTP error 403: Forbidden.

#### min\_splits

min\_splits must be smaller than max\_splits.

Requests for routes with min\_splits larger than max\_splits will result in HTTP error 403: Forbidden.

#### max\_splits

For performance reasons, max\_splits is capped at 4 for most networks.&#x20;

Requests for routes with max\_splits too high will result in HTTP error 403: Forbidden.

#### count

While a count value must be passed along with the JSON object, the parameter is currently unused internally and the route request will return a single route regardless of count.


---

# 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://braindex.gitbook.io/braindex-documentation/developer-documentation/braindex-api-integration/pathfinder-api-requesting-a-route.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.
