# Authorization

A system for obtaining and managing increased API rate limits through request authorization.

### Initialization

```typescript
const afSdk = new Aftermath("MAINNET");
await afSdk.init(); // initialize provider

const auth = afSdk.Auth();
```

### Rate Limits

Default rate limit: 1000 requests per 10 seconds.

To request increased limits:

1. Visit [Aftermath Discord](https://discord.com/invite/KvVCAauXk5)
2. Open a ticket with:

```
sui-address: <your-sui-address>
rate-limit-requests: [<sdk-call>: <desired-rate-limit>]
```

### Methods

#### Initialize with Private Key

```typescript
const keypair = Helpers.keypairFromPrivateKey("your-private-key");

const stopAuth = await auth.init({
	signMessageCallback: async ({ message }) => {
		const { signature } = await keypair.signPersonalMessage(message);
		return { signature };
	},
	walletAddress: keypair.toSuiAddress(),
});

// Make authorized requests
const pools = await afSdk.Pools().getAllPools();

// Stop authorization
stopAuth();
```

### Types

```typescript
interface AuthInitOptions {
	signMessageCallback: (args: { message: Uint8Array }) => Promise<{
		signature: string;
	}>;
	walletAddress: string;
}
```

### Example Usage

```typescript
const afSdk = new Aftermath("MAINNET");
await afSdk.init();

// Initialize with private key
const keypair = Helpers.keypairFromPrivateKey("your-private-key");
const stopAuth = await afSdk.Auth().init({
	signMessageCallback: async ({ message }) => {
		const { signature } = await keypair.signPersonalMessage(message);
		return { signature };
	},
	walletAddress: keypair.toSuiAddress(),
});

// Make authorized requests
const pools = await afSdk.Pools().getAllPools();
const prices = await afSdk.Prices().getCoinPrice({
	coin: "0x2::sui::SUI",
});

// Clean up
stopAuth();
```


---

# Agent Instructions: 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:

```
GET https://docs.aftermath.finance/for-developers/typescript-sdk/utils/authorization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
