Try Live Demo

What is Periscope Producer API?

Periscope Producer API

Periscope Producer API was first announced with this post on twitter blog at March 21, 2017 by defining it as follows

Periscope Producer API which opens up new ways to share live video, such as starting broadcasts directly from external hardware, software, cameras and web services – without the need to connect them via the app. The API enables third-party applications to authenticate Periscope accounts, configure streams, start and stop broadcasts and publish broadcasts to Twitter.

Then lots of tech sites like Variety, VentureBeat, etc. will publish this news on their site. It was also announced on TwitterDev account

Unfourtunately, this api was first announced as private beta and developers need to fill the private beta waitlist form to get documentation and some parameters like client id from Periscope Support so we did.

Today, we are honored to share, probably the first, JAVA implementation of Periscope Producer API on Github with the approval from Periscope side and now let’s look at how to use this api.

How to use Periscope Producer API

First Periscope Producer API library download and add jar to your class path

Authorize Your App

There are two ways for this.

  • Device Code
  • OAuth2 Authorization Code

We provide source code for Device Code method below, please go to github page to see OAuth2 Authorization Code sample

//create an AuthorizationEndPoint instance
AuthorizationEndpoints authorizationEndpoint = PeriscopeEndpointFactory.getAuthorizationEndpoint();

//make a create device code request
CreateDeviceCodeResponse createDeviceCodeResponse = authorizationEndpoint.createDeviceCode(CLIENT_ID);

//Follow the instructions 
System.out.println("Go to this url: " + createDeviceCodeResponse.associate_url);
System.out.println("Enter this user code: " + createDeviceCodeResponse.user_code);
System.out.println("and come back here");

CheckDeviceCodeResponse checkDeviceCode;
do {
    System.out.println("Waiting for " + createDeviceCodeResponse.interval + " seconds to check device code");
    //wait for interval seconds to check device code
    Thread.sleep(createDeviceCodeResponse.interval * 1000);

    //make a check device code to test if user code is entered to associated url as mentioned above
    checkDeviceCode = authorizationEndpoint.checkDeviceCode(createDeviceCodeResponse.device_code, CLIENT_ID);
} while(!checkDeviceCode.state.equals("associated"));
// save access and refresh token fields to use in later requests.

Create and Publish Broadcast

Here is the sample code that creates and publishs a broadcast. We provide
in-line comments to help you understand easily

//Initialize Periscope Endpoint Factory by giving access and refresh token
PeriscopeEndpointFactory periscopeEndpointFactory = 
    new PeriscopeEndpointFactory(TOKEN_TYPE, ACCESS_TOKEN, REFRESH_TOKEN);
//get broadcast end point     
BroadcastEndpoints endpoint = periscopeEndpointFactory.getBroadcastEndpoints();
// get region end point
RegionEndpoints regionEndpoints = periscopeEndpointFactory.getRegionEndpoints();
//create broadcast
CreateBroadcastResponse createBroadcastResponse = 
      endpoint.createBroadcast(regionEndpoints.get(), false);
//createBroadcastResponse has all the required information you need for your encoder and player
//rtmp, hls, configuration etc.
//right now it is time to publish
String title = "test";
PublishBroadcastResponse publishBroadcastResponse = 
            endpoint.publishBroadcast(, title, true, 
                                       new Locale("tr", "TR").toString());

Stop Broadcast

Just call BroadcastEndpoints’ stopBroadcast function with the broadcast id that is returned in creating and publishing broadcast


Delete Broadcast

Just call BroadcastEndpoints’ deleteBroadcast function with the broadcast id that is returned in creating and publishing broadcast


Get Broadcast

Just call BroadcastEndpoints’ getBroadcast function with the broadcast id to query the broadcast

Broadcast broadcast = endpoint.getBroadcast(;

As you see, function calls are so straightforward and we have reached the end. If you have any question about the API, please drop a comment or contact via

Btw, I hope this implementation will help some guys out there and make your task finish faster 😉

You can have Android and iOS SDKs for free.

Categories: Tutorial


Leave a Reply

Avatar placeholder

Your email address will not be published.