How to get the participantId

I am starting to work with the External API.
For several eventListeners a participantId is required. I can’t figure out how to get this ID.
Can you help me out?

Yes, I was dealing with the same issue.
The solution is:

api.on(‘participantJoined’, (object) => join(object.id));

“.on” is one way of eventListener. In the local variable called object you store .json object from ‘participantJoined’, then I add the id paramerer to my function “join” to execute.

Hope this will work for you to.

1 Like

Thanks a lot, that works very good.
Is there also a way to get the id of the first one to enter the room?

hay i too need this but didnt understand what you wrote

stromguy1’s answer helped but didn’t get me to the final solution.

The final solution for me was to pass a parameter into the function and then use that parameter within the function to get the participant’s id and displayName.

Option 1:
api.on(‘participantJoined’, function(abc) {
console.log( abc );
});

Option 2:
var participants = api.addEventListener(‘participantJoined’ , function(abcd){
console.log( abcd );
});

I just printed out the object information into the console in the example above, but you could basically use the info in whichever way you want from here.

Fully Jitsi JQuery code for context:

$(document).ready(function(){
	var domain = "meet.jit.si";
	var options = {
		roomName: "JitsiMeetAPIExample", //any meeting room name you want
		width: 700,
		height: 700,
		parentNode: document.querySelector('#meet')
	}
	var api = new JitsiMeetExternalAPI(domain, options);

	api.on('participantJoined', function(abc) {
		console.log( abc );
	});
	
	var participants = api.addEventListener('participantJoined' , function(abcd){
		console.log( abcd );
	});
	
});