# API and WebSocket

> Authenticate with your API key, manage what you track over REST, and stream your feed over one WebSocket.

Doggo, Top Dog

Everything here uses the API key from your [Account page](https://www.bark.gg/account) and acts on your account.

## WebSocket feed

1. **Connect**: to `wss://news.bark.gg/ws`.
2. **Log in**: send `login <your api key>`.
3. **Stay connected**: send `ping` regularly; Bark answers `pong`.

Each alert is one JSON object; its `tags` hold the data, such as `NEWS_TYPE` and `PREFERRED_TRADING_URL` (the token on your platform). Every kind: [WebSocket messages](https://www.bark.gg/docs/websocket-messages). You get what the **Terminal & API** switches in Settings → [Delivery](https://www.bark.gg/settings?section=delivery) allow, on up to 10 connections per key.

```js
const ws = new WebSocket("wss://news.bark.gg/ws");

ws.onopen = () => ws.send(`login ${process.env.BARK_API_KEY}`);
setInterval(() => ws.send("ping"), 15_000);

ws.onmessage = ({ data }) => {
  if (data === "pong") return;
  const alert = JSON.parse(data);
  console.log(alert.time, alert.title, alert.tags.NEWS_TYPE);
};
```

## REST API

The base address is `https://news.bark.gg`; send your key in the `X-API-KEY` header. Every endpoint: [REST API reference](https://www.bark.gg/docs/rest-api).

| Call | What it does |
|---|---|
| `GET /settings/<collection>` | Lists what you track, such as `wallets` |
| `PUT /settings/<collection>` | Tracks or updates something |
| `DELETE /settings/<collection>` | Stops tracking it |
| `POST /settings/detect` | Says what pasted text is and how to track it |
| `GET /news/export` | Your feed's history, page by page (free, 60 calls a minute) |
| `GET /check-twitter?handle=…` | Looks up an X account (100 [credits](https://www.bark.gg/docs/plans#api-credits)) |

Add `entityId` and `channelId` to change a server's channel or a group's topic instead of your own feed. Errors: `400` bad request, `404` not found, `409` plan limit reached.

```bash
# Track a wallet, then list your wallets
curl -X PUT "https://news.bark.gg/settings/wallets" \
  -H "X-API-KEY: $BARK_API_KEY" -H "Content-Type: application/json" \
  -d '{"address": "<wallet address>", "label": "whale 3"}'
curl "https://news.bark.gg/settings/wallets" -H "X-API-KEY: $BARK_API_KEY"
```

## AI assistants

Use the [MCP server](https://www.bark.gg/docs/mcp).

---

Page: https://www.bark.gg/docs/api · Every page: https://www.bark.gg/llms.txt · The whole guide: https://www.bark.gg/llms-full.txt
