# Keys and balance

> Manage your Nullgate account in the Telegram bot: create and revoke API keys, check your balance and usage, and top up via xRocket or the operator.

Manage your account in Telegram: [@nullgate_app](https://t.me/nullgate_app). There is no web account. [Prices](https://nullgate.club/en/prices).

```python
from nullgate import Nullgate

with Nullgate() as ng:
    account = ng.account()
    print(account["balance"], account["prices_per_1000"])
```

```typescript
import { Nullgate } from "@nullgate/sdk";

const account = await new Nullgate().account();
console.log(account.balance, account.pricesPer1000);
```

```go
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/nullgate-club/nullgate-sdk-go/v2"
	"github.com/nullgate-club/nullgate-sdk-go/v2/api"
)

func main() {
	client, err := nullgate.New("", api.Options{})
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	account, err := client.Accounts.Get(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(account.Balance, account.PricesPer1000)
}
```

```sh
curl -H "Authorization: Bearer $NULLGATE_API_KEY" https://api.nullgate.club/account
```

## Keys

1. In the bot, tap **Keys**, then **Create**.
2. Send a name (1 to 128 characters).
3. Choose **No expiry**, 30 days or 90 days.
4. Copy the key. The bot shows it only once.

All keys on one account share its balance.

In **Keys**, select a key and tap **Revoke**. Requests with that key immediately fail with [`invalid_key`](https://nullgate.club/en/errors#invalid_key).

All three SDKs read `NULLGATE_API_KEY`. To pass the key explicitly, use the first argument to `Nullgate(...)` in Python and TypeScript or `nullgate.New(...)` in Go.

Keep keys on your server, out of browser code and repositories.

## Balance and usage

The home screen shows balance, today's requests and spend, and 7-day spend. **Usage** breaks down requests and spend by product: today, 7 or 30 days.

The bot alerts you below $1.00. At zero, requests fail with [`insufficient_balance`](https://nullgate.club/en/errors#insufficient_balance).

SDK usage: hourly or daily.

```python
usage = ng.usage(interval="day", start="2026-11-01T00:00:00Z", end="2026-11-08T00:00:00Z")
for bucket in usage["buckets"]:
    print(bucket["start"], bucket["operation"], bucket["requests"], bucket["amount"])
```

```typescript
const usage = await ng.usage({
  interval: "day",
  start: "2026-11-01T00:00:00Z",
  end: "2026-11-08T00:00:00Z",
});
for (const bucket of usage.buckets)
  console.log(bucket.start, bucket.operation, bucket.requests, bucket.amount);
```

```go
package main

import (
	"context"
	"fmt"
	"log"
	"time"

	"github.com/nullgate-club/nullgate-sdk-go/v2"
	"github.com/nullgate-club/nullgate-sdk-go/v2/accounts"
	"github.com/nullgate-club/nullgate-sdk-go/v2/api"
)

func main() {
	client, err := nullgate.New("", api.Options{})
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	start := time.Date(2026, 11, 1, 0, 0, 0, 0, time.UTC)
	end := start.AddDate(0, 0, 7)
	usage, err := client.Accounts.Usage(context.Background(), accounts.UsageOptions{
		Interval: "day", Start: &start, End: &end,
	})
	if err != nil {
		log.Fatal(err)
	}
	for _, bucket := range usage.Buckets {
		fmt.Println(bucket.Start, bucket.Operation, bucket.Requests, bucket.Amount)
	}
}
```

## Top up

1. Tap **Top up**.
2. Choose an amount or enter one under **Your amount**. The bot shows the range.
3. Choose how to pay.

| Method                   | How it works                                                                                                          |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| **xRocket**              | The bot gives you an invoice. Pay it within 60 minutes. The bot adds the money to the balance by itself and tells you |
| **Through the operator** | The bot shows the operator's Telegram account. Write the amount and the network. The operator adds the money by hand  |

Expired xRocket invoices do not charge or credit you. Create a new invoice.

## Support

[Message the developer on Telegram](https://t.me/nullgate_app?start=support_en). Include `request_id` for failed requests.
