> For the complete documentation index, see [llms.txt](https://rooster-protocol.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rooster-protocol.gitbook.io/docs/developers/call-data-api.md).

# Call Data API

## Generate swap call data for Rooster Protocol

> Endpoint to generate the necessary call data for executing a token swap on the Rooster Protocol.

```json
{"openapi":"3.0.0","info":{"title":"Rooster Protocol Swap API","version":"v1"},"servers":[{"url":"http://api.rooster-protocol.xyz/api"}],"paths":{"/swap/callData":{"post":{"summary":"Generate swap call data for Rooster Protocol","description":"Endpoint to generate the necessary call data for executing a token swap on the Rooster Protocol.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"inputTokenAddress":{"type":"string","description":"Address of the input token. Use '0x0000000000000000000000000000000000000000' for the native gas token."},"outputTokenAddress":{"type":"string","description":"Address of the output token."},"recipientAddress":{"type":"string","description":"Address of the recipient of the output tokens."},"amount":{"type":"string","description":"Amount of the input token to swap (in its smallest unit, e.g., Wei)."},"slippage":{"type":"number","format":"float","description":"Optional. Slippage tolerance percentage (e.g., 3 for 3%). Defaults to a predefined value."},"amountOutMinimum":{"type":"string","description":"Optional. Minimum amount of output tokens expected (in Wei). If not provided, it will be calculated based on the slippage."}},"required":["inputTokenAddress","outputTokenAddress","recipientAddress","amount"]}}}},"responses":{"200":{"description":"Successfully generated swap call data.","content":{"application/json":{"schema":{"type":"object","properties":{"callData":{"type":"string","description":"Call data to be sent to the router contract."},"to":{"type":"string","description":"Address of the router contract."},"value":{"type":"string","description":"Value (in Wei) to be sent with the transaction (usually 0, except when swapping with gas token)."},"expectedOutput":{"type":"string","description":"Estimated amount of output tokens the user will receive."},"amountOutMinimum":{"type":"string","description":"Minimum amount of output tokens the user should receive after slippage (in Wei)."},"slippage":{"type":"number","format":"float","description":"The final slippage used for the calculation."},"status":{"type":"integer","description":"HTTP status code (200 for success)."}}}}}},"400":{"description":"Bad request. Missing parameters or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message."},"status":{"type":"integer","description":"HTTP status code (400 for error)."}}}}}}}}}}}
```


---

# 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://rooster-protocol.gitbook.io/docs/developers/call-data-api.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.
