Testing with the Sandbox API
How-to Guide - Use Sandbox API to test your Fishjam integration quickly without a backend
The Sandbox API is a development tool that lets you create rooms and peers for testing without setting up your own backend server. This guide shows you how to use it effectively.
Prerequisites
- Access to Fishjam Dashboard
- A Sandbox environment set up
Step 1: Get your Fishjam ID
- Log in to Fishjam Dashboard
- Navigate to your Sandbox Environment
- Copy your Fishjam ID
FISHJAM_ID
is your unique sandbox identifier. Anyone who knows this ID can join your rooms, so keep it secure during development.
Step 2: Create a room and get peer tokens
With the useSandbox
hook
- React Native
- React
import {
useSandbox } from '@fishjam-cloud/react-native-client'; // ... const {getSandboxPeerToken } =useSandbox ({fishjamId :FISHJAM_ID }); constpeerToken = awaitgetSandboxPeerToken (roomName ,peerName );
import {
useSandbox } from '@fishjam-cloud/react-client'; // ... const {getSandboxPeerToken } =useSandbox (); constpeerToken = awaitgetSandboxPeerToken (roomName ,peerName );
Required parameters
roomName
- Name of the room to create/joinpeerName
- Name for the peer joining the room
Optional parameters
roomType
- Type of room to create (defaults toconference
)
Room types available
conference
- For video/audio conferencing (default)audio-only
- For audio-only conferencinglivestream
- For one-to-many video/audio streaming
Step 3: Handle the response
The Sandbox API returns a JSON response with connection details:
{ "peerToken": "<PEER_TOKEN>", "url": "wss://fishjam.io/api/v1/connect/${YOUR_APP_UUID}", "room": { "id": "<ROOM_ID>", "name": "foo" }, "peer": { "id": "<PEER_ID>", "name": "bar" } }
Step 4: Use the tokens in your client app
Below are examples on how to use tokens from the Sandbox API in your frontend applications:
- React Native
- React
import {
useSandbox } from "@fishjam-cloud/react-native-client"; export default functionTestScreen () { const [peerToken ,setPeerToken ] =useState <string | null>(null); const {getSandboxPeerToken } =useSandbox ({fishjamId :FISHJAM_ID });useEffect (() => { constfetchPeerToken = async () => { try { consttoken = awaitgetSandboxPeerToken (roomName ,peerName );setPeerToken (token ); } catch (error ) {console .error ("Failed to create room:",error ); } };fetchPeerToken (); }, []); if (!peerToken ) { return <Text >Creating room...</Text >; } return ( <RoomView peerToken ={peerToken } /> ); }
import {
FishjamProvider ,useConnection ,useSandbox } from "@fishjam-cloud/react-client"; functionVideoCallComponent () { const {joinRoom ,peerStatus } =useConnection (); const {getSandboxPeerToken } =useSandbox (); consthandleJoinRoom = async () => { constroomName = "testRoom"; constpeerName = `user_${Date .now ()}`; try { constpeerToken = awaitgetSandboxPeerToken (roomName ,peerName ) awaitjoinRoom ({peerToken }); } catch (error ) {console .error ("Failed to join room:",error ); } }; constisConnected =peerStatus === "connected"; return ( <div > {isConnected ? <p >Connected to room!</p > : <button onClick ={handleJoinRoom }>Join Room</button >} </div > ); } export default functionApp () { return ( <FishjamProvider > <VideoCallComponent /> </FishjamProvider > ); }
Step 5: Test different room types
Testing audio-only rooms
const
audioOnlyUrl = awaitgetSandboxPeerToken ( "audioTest", "user1", "audio_only", );
Testing livestream rooms
const
livestreamName = "livestream1"; // For the streamer conststreamerUrl = awaitgetSandboxLivestream (livestreamName ); // For viewers, you need a viewer token (different endpoint) constviewerTokenUrl = awaitgetSandboxViewerToken (livestreamName );
Step 6: Handle multiple peers
To test with multiple participants, create multiple peer tokens with different peer names:
// First peer const
peer1Response = awaitgetSandboxPeerToken ("multiTest", "alice"); // Second peer constpeer2Response = awaitgetSandboxPeerToken ("multiTest", "bob");
Both peers will join the same room (multiTest
) and can communicate with each other.
Common testing patterns
Pattern 1: Random room names for isolation
const
roomName = `test_${Math .random ().toString (36).substring (7)}`; constpeerName = `user_${Date .now ()}`;
Pattern 2: Consistent naming for repeated tests
const
roomName = "development-room"; constpeerName = `developer_1`;
Pattern 3: Feature-specific room names
const
roomName = `screenshare-test-${Date .now ()}`; constroomName = `audio-only-test`; constroomName = `livestream-demo`;
Troubleshooting
Issue: Room not found errors
Problem: Rooms might not persist between requests.
Solution: Always create rooms fresh for each test session.
Issue: Connection failures
Problem: Invalid Fishjam ID or network issues.
Solution:
- Verify your Fishjam ID in the Fishjam Dashboard
- Check network connectivity
- Ensure you're using the sandbox environment
Security reminder
The Sandbox API is not safe for production!
- No authentication required
- Anyone with your Fishjam ID can join rooms
- Identical room/peer names get the same tokens
- No rate limiting or abuse protection
Only use the Sandbox API for development and testing.
Resetting your app
If you need to reset your Sandbox API:
- Go to Fishjam Dashboard
- Click Settings
- Click Reset App
- Get your new Fishjam ID
This will invalidate all existing tokens (including the management token!) and give you a fresh sandbox environment.
Next steps
Once you've tested your integration with the Sandbox API:
For production deployment: