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

# JetStream İstemcisi

> İşlem ve hesap filtreleri ile gRPC akışları olarak sunulan OrbitFlare'ın çözümlenmiş shred'leri.

## Kurulum

```bash theme={null}
npm install @orbitflare/sdk @grpc/grpc-js yaml
```

`@grpc/grpc-js` ve `yaml` isteğe bağlı peer bağımlılıklardır. Yalnızca JetStream (veya YAML yapılandırması) kullanıyorsanız kurun.

## İstemciyi oluşturma

```ts theme={null}
import { JetstreamClientBuilder } from '@orbitflare/sdk/jetstream';
import type { RetryPolicy } from '@orbitflare/sdk';

const client = new JetstreamClientBuilder()
  .url('http://ny.jetstream.orbitflare.com')
  .fallbackUrl('http://fra.jetstream.orbitflare.com')
  .retry({
    initialDelayMs: 100,
    maxDelayMs: 30_000,
    multiplier: 2.0,
    maxAttempts: 0,
  })
  .timeoutSecs(30)
  .keepaliveSecs(60)
  .pingIntervalSecs(10)
  .maxMissedPongs(3)
  .channelCapacity(4096)
  .build();
```

Minimal:

```ts theme={null}
const client = new JetstreamClientBuilder()
  .url('http://ny.jetstream.orbitflare.com')
  .build();
```

URL, ayarlanmazsa `ORBITFLARE_JETSTREAM_URL` ortam değişkenine düşer. Tüm builder yöntemleri [gRPC istemcisi](/tr/sdk/typescript-grpc) ile aynıdır - aynı varsayılanlar, aynı davranış.

## YAML yapılandırması yazma

JetStream işlem ve hesap filtrelerini destekler. Slot, blok veya taahhüt yok - bunlar Yellowstone'a özgüdür.

```yaml theme={null}
# jetstream.yml
transactions:
  raydium:
    account_include:
      - "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
  pumpfun:
    account_include:
      - "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"

accounts:
  my_wallet:
    account:
      - "YOUR_WALLET_ADDRESS"
    owner:
      - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
```

### YAML filtre referansı

**`transactions`** - adlı filtreler. `account_include`, bu adresleri içeren işlemlerle eşleşir. `account_exclude` eşleşmeleri çıkarır. `account_required` listelenen tüm adreslerin görünmesini gerektirir.

**`accounts`** - `account` ile belirli adresleri veya `owner` ile bir programa ait tüm hesapları izleyin.

`${ENV_VAR}` genişletmesini destekler.

## Olaylara abone olma ve okuma

### YAML'dan

```ts theme={null}
const stream = client.subscribeYaml('jetstream.yml');
```

### Programatik olarak

```ts theme={null}
import { proto } from '@orbitflare/sdk/proto';

const request: proto.jetstream.SubscribeRequest = {
  transactions: {
    target: {
      accountInclude: [someAddress],
      accountExclude: [],
      accountRequired: [],
    },
  },
  accounts: {},
  ping: { id: 1 },
};

const stream = client.subscribe(request);
```

### Akışı okuma

```ts theme={null}
for await (const update of stream) {
  if (update.transaction) {
    // update.transaction.slot - the slot number
    // update.transaction.transaction - transaction info with signature, accountKeys,
    //   instructions, addressTableLookups
  } else if (update.account) {
    // update.account.slot - the slot
    // update.account.account - account info (pubkey, lamports, owner, data)
    // update.account.isStartup - true during initial snapshot
  }
}
```

Kapatma, birden çok akış, yeniden bağlanma ve ping/pong, [gRPC istemcisi](/tr/sdk/typescript-grpc) ile birebir aynı şekilde çalışır.

## Tam örnek

Raydium AMM takaslarını izleyen ve her işlemin imzası ile talimat sayısını yazdıran bir akış.

```ts theme={null}
import bs58 from 'bs58';
import { JetstreamClientBuilder } from '@orbitflare/sdk/jetstream';

async function main() {
  const client = new JetstreamClientBuilder()
    .url('http://ny.jetstream.orbitflare.com')
    .build();

  const stream = client.subscribeYaml('jetstream.yml');
  let count = 0;

  console.log('streaming raydium txs...');

  for await (const update of stream) {
    if (update.transaction) {
      count += 1;
      const info = update.transaction.transaction;
      if (info?.signature) {
        const sig = bs58.encode(info.signature);
        const numIx = info.instructions.length;
        const numAccounts = info.accountKeys.length;
        console.log(
          `#${count} slot=${update.transaction.slot} sig=${sig.slice(0, 16)}... ix=${numIx} accounts=${numAccounts}`,
        );
      }
    }
  }
}

void main();
```

Bu `jetstream.yml` ile:

```yaml theme={null}
transactions:
  raydium:
    account_include:
      - "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
```
