> For the complete documentation index, see [llms.txt](https://rpslabs.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://rpslabs.gitbook.io/docs/using-lotto-sdk/for-developers/sdk-docs/hooks.md).

# Hooks

RPS SDK comes with powerful hooks to make accessing RPS data simple and efficient.

Our hooks are built on top of [SWR](https://swr.vercel.app/), a high-performance, lightweight data-fetching library. By utilizing SWR, you gain access to efficient request caching, request batching, and a host of robust features developed and tested by the SWR team. This means you can seamlessly incorporate these hooks into your components without concerns about performance bottlenecks or duplicate network requests. Moreover, you have the flexibility to customize SWR's configuration options for each of these SWR-powered hooks. Below, we outline the key properties returned by each of these hooks:

* **response**: This property contains the response obtained from the API.
* **data**: You can access the data extracted from the API response through this property.
* **mutate**: We expose SWR's `mutate` function, enabling you to efficiently refresh the data when needed.
* **error**: If there is an issue or error with the API request, you will find the details here.
* **isValidating**: This property allows you to check if there is an ongoing request or revalidation process.

<details>

<summary>useTicketPrice</summary>

```typescript
import { useTicketPrice } from '@rps-labs/lotto-sdk';

const { data: ticketPrice } = useTicketPrice()
```

Use this hook to fetch the ticket price in `eth` and `wei` using the `ticket price endpoint`

</details>

<details>

<summary>usePotInfo</summary>

```typescript
import { usePotInfo } from '@rps-labs/lotto-sdk';

const { data: potInfo } = usePotInfo()

```

Use this hook to fetch the current pot ID, size, limit and ticket number using the `current pot info endpoint`

</details>

<details>

<summary>useLeaderboard</summary>

```typescript
import { useLeaderboard } from '@rps-labs/lotto-sdk';

const { data: leaderboard } = useLeaderboard()
```

Use this hook to fetch all wallet addresses in a current pot sorted by their number of tickets using the `Get pot leaderboard endpoint.`

</details>

<details>

<summary>useTickets</summary>

```typescript
import { useTickets } from '@rps-labs/lotto-sdk';

const { data: tickets } = useTickets()
```

Use this hook to fetch all tickets a user has in the current pot using the `Get All Tickets endpoint`

</details>

<details>

<summary>usePreviousWinners</summary>

```typescript
import { usePreviousWinners } from '@rps-labs/lotto-sdk';

const { data: previousWinners } = usePreviousWinners()
```

Use this hook to fetch all users that won the raffle in the past and info related to their pots using the `Get previous winners endpoint.`

</details>
