Watch2Gether API Documentation

Watch2Gether provides a simple API that allows you to programmatically create new rooms and set an initial video for those rooms.

If you don’t have a Watch2Gether account yet, sign up here first: https://w2g.tv/auth/sign_up

The required API key can be generated in you account settings.
Login to your account > “Edit Profile” on the right > At the bottom “New” to generate a new key

All rooms that you create using the key will be owned by the account associated with the key.

You can create a new room by sending a POST request to:

https://w2g.tv/rooms/create.json

You can include these parameters in the JSON formatted body of your request:

{ 
    "w2g_api_key" : "<your api key>",
    "share" : "https://www.youtube.com/watch?v=tpiyEe_CqB4",  // URL of the video to share - optional
    "bg_color" : "#00ff00", // Background color of the room in HTML notation - optional
    "bg_opacity" : "50" // Background opacity of the room (0 - 100) - optional
}

In return you get a JSON string. The value of “streamkey” can be used to build the URL of the new Watch2Gether room: https://w2g.tv/rooms/{streamkey}

When you open that room, the shared video will be preloaded.

1 Like

Hey is it possible to add the feature to set the room color and gradient to this api as an optional field?

Cool idea… yes that should be possible quite easily. Will have a look later.

1 Like

And i have an second idea: Because the api key is now linked with my account is it possible to link the username and/or profile picture also? (So in the channel members its not a “User-randomstring”) Or to hide the creator if its created via API?

You can now set the background color and opacity in the API call.

1 Like

Spelling: “programmatically”, not “problematically”.

1 Like

Thanks a lot! I just fixed it. That does really make a difference :slight_smile:

1 Like

How do I get the api key?

It’s explained above in the first post!

What is the name of the library?

Is there possible to make a room timeout"able" if no one joins = if someone “spams” for example the command in the discord bot that these dont clump Watch2Gether :slight_smile:

If not, can be a option for that?

Is the “share” attribute broken? I tried different links, but whenever I create a new room, the link in the “share” attribute is ignored and a random video is loaded.
If “share” is not broken, I will create an extra thread for trouble shooting.

Sorry for the late reply. The option generally works and is in use by some internal tools as well. I assume that your request is not properly formatted.

Hi, I tried your method but doesn’t work.

I tried this:

fetch('https://w2g.tv/rooms/create.json', {method: 'POST', 
  body: { 
    "w2g_api_key" : "key",
    "share" : 'https://www.youtube.com/watch?v=bJqJKAoUWkU',  // URL of the video to share - optional
}});

and it returned me the streamKey but it created a random room but no with my video. Thanks

Check if the video at all could be played in watch2gether

Yes I can, I tested some videos and no one works

1 Like

You have ‘link’ instead of “link” <-- thats probably the problem

Nah, same problem, tested in my app and postman

and you have a “,” afterthat but that is the last argument that has normaly no “,”