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

# StakingApiClient

> The object for accessing all network-specific methods of P2P.ORG Staking SDK.

A `StakingApiClient` object is initialized with a base URL and an authentication token that will be used by various methods.

<CodeGroup>
  ```javascript JavaScript theme={null}
  import { StakingApiClient } from '@p2p/staking-api';

  const client = new StakingApiClient({
    baseUrl: 'https://api.p2p.org',
    token: 'eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9',
    network: 'mainnet-beta',
    retry: {
      retryOn: [429, 500, 502, 503],
      retryDelayMs: 500,
      retries: 3,
      retryOnTimeout: true,
    },
  });
  ```
</CodeGroup>

The methods for each supported network can be accessed via a specific field in the `StakingApiClient` object. For example:

<CodeGroup>
  ```javascript JavaScript theme={null}
  await client.solana.stake({
    feePayer: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw',
    fromPublicKey: '9i5cTqci1W6DHdYfT7WbiNhP5DXvnPNTXvS9fTBFfuSw',
    amount: '1002282880',
  });
  ```
</CodeGroup>

Currently, the following networks are supported:

* `client.solana` — [Solana](/docs/staking-sdk-solana).

More networks will be added in future versions.

## Parameters

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **baseUrl** *string, required*<br />The base URL for all P2P.ORG API endpoints:<br />\* `https://api.p2p.org` for production,<br />\* `https://api-test.p2p.org` for testing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **token** *string, required*<br />The [authentication token](/docs/authentication) for accessing P2P.ORG API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| **network** *string, required*<br />Network to use in all API calls by default, e.g., `mainnet` or `testnet`. See the specific methods' documentation for allowed values.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **timeoutMs** *number*<br />If specified, any request that takes longer than this amount of milliseconds will fail.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| **retry** *object*<br />Parameters that affect how the API client handles HTTP errors.<br />If the client encounters one of HTTP response codes listed in `retryOn`, it will wait for at least `retryDelayMs` milliseconds and attempt the same API request again. If the request fails repeatedly, the delay grows exponentially, according to formula: *retryDelayMs + 2^(attempt-1) + random jitter*. The client will throw an exception only if the request failed as many times as specified in the `retries` option.<br />If `retryOnTimeout` is set to true, the same retry behavior will be used for requests that failed according to `timeoutMs`. Enable with caution for non-idempotent operations like [sendTransaction()](/docs/staking-sdk-solana-sendtransaction).<br />If these parameters are not provided, the client will never retry failed requests and will fail immediately. |
| **logger** *object*<br />An optional object for accepting log messages. Any console-compatible logger object can be provided: `console`, [`pino`](https://getpino.io/), [`winston`](https://github.com/winstonjs/winston), etc.<br />If the object is not provided, Staking SDK will not log any messages.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |


## Related topics

- [Staking SDK for Solana](/docs/staking-sdk-solana.md)
- [Staking API reference](/reference/solana-staking-stake.md)
