Skip to main content

Dart SDK

📥 Installation

Install the SDK using Dart:

dart pub add turnix_dart

📦 Import the SDK

Import the TurnixIO class in your Dart server-side application:

import 'package:turnix_dart/turnix_dart.dart';

🔐 Authenticate with Your API Token

Use your Turnix API token to make a call to request credentials (see Quickstart):

final creds = await TurnixIO.getIceCredentials(
apiToken: 'your-bearer-token',
);
Sensitive information

Always keep your API token secret - use it only in server-side environments.


🌐 Request ICE Credentials

Use the SDK to request ICE credentials with optional parameters like client IDs, room, region, and TTL:

final creds = await TurnixIO.getIceCredentials(
apiToken: 'your-bearer-token',
initiatorClient: 'alice@example.com',
receiverClient: 'bob@example.com',
room: 'demo-room',
ttl: 60, // optional time-to-live in seconds
);

🔎 Retrieve Available Regions

Fetch the full list of TURN regions supported by Turnix, including metadata and status flags:

final regions = await TurnixIO.getAvailableRegions(
apiToken: 'your-bearer-token',
);

print(
'Available regions: ${jsonEncode(
regions.map((region) => region.toString()).join(",")
)}',
);

Each Region includes:

  • slug: region identifier (e.g., us-east)
  • nat2: ISO country code
  • city: primary city location
  • name: human-readable region name
  • lat, lon: geographic coordinates
  • isOnline: whether the server is reachable
  • isOperational: whether allocation is functional

🎯 Use ICE Servers in WebRTC

Once you have the iceServers array, pass it into your WebRTC client setup on the frontend, e.g. in Flutter using 'flutter_webrtc':

final pc = await createPeerConnection({
'iceServers': creds.iceServers.map((s) => {
'urls': s.urls,
if (s.username != null) 'username': s.username,
if (s.credential != null) 'credential': s.credential,
}).toList(),
});

This completes your setup for establishing a secure and reliable peer-to-peer connection using Turnix.