Picarto API Support

Description

Picarto.tv is an alternative streaming platform primarily focused on art and creation streams. It has a subscription service for all streamers, offers built in commissions (using a Twitch Bits like alternative) and several other niceties for creatives to get their foot in the door. This API extension primarily will focus on giving its users follower and subscriber related triggers and variables to integrate into their workflows. Kudos, the currency used for commissions and tipping do not seem to have a public endpoint at this time but that may be added later.

Major Note

This is a live project and I’m releasing updates fairly regularly right now, so subscribe to the topic and grab the new version as soon as possible. Outside of bug fixes and changes to the implementation where needed, I hope to not break too many things and mess with your ability to add custom tweaks for your needs. If you need to modify Actions, I’d recommend making two separate actions (one for the code modifications and the other to call both the old and new code if the changes are not directly being made to my implementation but as an extension).

The current webhook generation code may break on Streamer.Bot 0.2.2 and under. The 0.2.3 Beta should be starting soon, so an upgrade to that would be recommended.

Tutorial

Import Code / Downloads

Required Downloads (in order)

picarto-api-extension-actions-0.0.9.sb (16.5 KB)
picarto-api-extension-0.0.9-extras.zip

Optional Download

picarto-api-extension-webhooks-0.0.8.sb (11.3 KB)

Resources

picarto.tv API Documentation
picarto.tv ChatBot API Documentation

Base Installation

In Streamer.bot click the Import button in the top menu. Drag the .sb file into the Import String field. Imports by default are disabled. You’ll need to manually enable the Timed Action Trigger - Picarto API Ping and the many Actions (added in 0.0.2+) under the Picarto Group.

Added in 0.0.7

The zip file above is required for running this extension. Extract that into your Streamer.Bot folder, extract the zip file in the new picarto folder and drag it to your C drive. This is to make it so that you don’t need to change the DLL reference for any actions that rely on it. If you place it in a different location, you’ll need to change the SubstractionSoft.dll reference in the C# methods of the Register Picarto Follow Webhook and Register Picarto Webhooks with Streamer.Bot actions.

On the Picarto API page:

  1. Right-Click the Oauth link to open where you will setup your app (required for API access) and Click Open In New Tab

  2. Click Authorize to pull up the window you’ll put your Oauth info in. You’ll need to enable all four permissions for Webhook creation and access (changed in 0.0.3 release)

On the Picarto OAUTH Page:

  1. Login with your Picarto Credentials. A bot account will mess with getting notifications so it’s not recommended.

  2. Click Add Client and fill in all of the info. The Redirect URIs section must have this or it won’t work at all: https://api.picarto.tv/api/oauth2-callback .

  3. Click Edit Client and copy both Client ID and Client Secret into the proper fields in the Authorize window opened in Step 2. You’ll need these for Step 12.

Back on the Picarto API page:

  1. Click the public dropdown

  2. Click where it says GET /channel/name/{channel_name} .

  3. Click Try it out on the right.

  4. Type in your Channel Name and click Execute.

  5. Scroll down to the curl section and copy the entire string that comes after -H Authorization: Bearer minus the spaces and the single quotation marks. Should begin with an ey

  6. Open Streamer.bot but don’t close the Picarto API page (in case you need to go back and fix something).

In Streamer.Bot:

  1. Add these Global Permanent Variables
  • picartoBearer - <Bearer Token copied from previous step>
  • picartoChannelName - <your Channel Name>

Note Anytime you need to either change your Client Token and/or Client ID, you’ll need to redo Steps 6 - 12. The Bearer token for this last step need to be regenerated and reregistered with Streamer.bot

Added for 0.0.3

  • picartoClientID - <the client id from Step 5>
  • picartoClientToken - <the client secret from Step 5>

May remove these in the future since Webhooks are going to be more useful for this

  1. Create two new Actions under the Picarto Group and Picarto Queue with the following names:
  • Process Picarto Follow
  • Process Picarto Subscriber

These are where you will process the alerts and decide how you want to use them. Typically, Picarto is a secondary platform with another platform as the main, so you may want to integrate this into your implementation for those but there are many different ways you can handle this.

Chat Websocket Installation

Added for 0.0.4

  1. Install the latest LTS release of Node.js for your operating system.

  2. Download the server code file in Resources section and unzip it where your Streamer.Bot instance is running from. It will add a picarto folder. All of the code will be inside of that.

  3. Open Windows Command Prompt or any terminal on your operating system and navigate to the picarto/scripts/net folder.

  4. Run npm install -g yarn (yarn is the recommended way to manage the code).

  5. Run yarn to install all of the required libraries for the code to work. If no errors show up, close your terminal. No need to use it for any other steps.

  6. Right-click this page link, click Open in New Tab and sign in to your account on that page.

  7. Scroll down and click Approve to generate a chat bot token (will only appear once). Keep this page open for the next steps.

In Streamer.Bot

  1. Click Variables up top.

  2. Create a new Persisted Global variable and name it picartoChannelToken

  3. Copy the token from Step 7 and paste it as the value for this new variable.

  • NOTE if you don’t have a picartoChannelName Persisted Global variable, make it now and set its value to your channel name. This is important for the bot to watch the right chat. Would not recommend using a bot account for this for the time being.
  1. Close the page opened in Step 7

  2. In your Picarto group on the Actions page, click the Picarto Chat Server Init action. Adjust the trigger to your setup. Mine runs on a single 5 second timer on startup that runs once.

  3. Right click the trigger and click Test. If everything was installed and setup correctly in the previous steps, a Command Prompt window should have appeared and stayed open with some log info and the word Node in the title. Minimize this but don’t close it. It’s the Websocket relay server but doesn’t work in headless mode right now.

  4. Click Servers/Clients. Click Websocket Clients. Right click Picarto Chat (ws://127.0.0.1:8080/) and click Connect. It should say Open if everything worked correctly.

You can now use this Websocket Client as a trigger for Actions based on Picarto chat events. It has some limitations, though (see below).

New Variables from Extension

Global

  • picartoOnline (Temp Variable) - is Picarto stream online? Use this as a trigger for anything that relies on you being live
  • picartoFollowerCount - how many followers your Picarto channel currently has
  • picartoSubCount - how many subscribers your Picarto channel currently has

Added in 0.0.3

  • picartoFollowHook - follow webhook ID
  • picartoUnfollowHook - unfollow webhook ID
  • picartoSubHook - subscribe webhook ID
  • picartoUnsubHook - unsubscribe webhook ID
  • picartoOnlineHook - online webhook ID
  • picartoOfflineHook - offline webhook ID
  • picartoEvStartHook - event_start webhook ID
  • picartoEvEndHook - event_end webhook ID

Updated in 0.0.5

  • picartoChannelID - Made this a persistent global variable since it’s just so important for future API endpoint calls

Arguments Available for the Actions in Step 13 (of Initial Setup Steps)

  • user - display name of user that triggered event; useful for displaying user from chat
  • userName - login name of user that triggered event; useful for displaying the account name and not chat name
  • avatar - the profile picture URL of user that triggered event; useful for Browser Source based alerts that can display this

Configuration (extras)

  • picartoInit (Temp) - set this to True (twice) to activate the Webhook registration mechanism and wait at least 5 minutes for it to finish (although, my tests have shown 10+ minutes once due to Picarto server rate limiting)
  • picartoPort (optional Global variable) - the default port for this is 9005. Only change if you’re already using http://localhost:9005 for something else. If you change, you will need to regenerate all webhooks (will add a mechanism to do this for you with one of my next updates)

Current Known Limitations

  • Kudos, the built in tipping system, does not have official Webhooks or endpoints in the core API. I will not support this part.
  • Public rate limits are 30/minute but everything else seems to not have a consistent amount of time allowed between API calls; once my Webhooks implementation is fully built, I’ll be able to test rate limits there

Added in 0.0.4

  • The chat API is pretty basic. It has most of what’s expected (name of chatter, timestamps, etc) but they are labeled using abbreviations and aren’t extrapolated in the bot library itself.
  • There’s no official way to use a bot account and have it join your channel. Whatever account is used to generate the token found in Step 7 of the Chat Websocket Initialization section, that channel is what the bot will read chat messages from. A workaround that some older bots have used for it involves scraping the streamer’s page, parsing its code and then sending the message as the bot to the channel’s chat websocket, but that seems complex and prone to errors right now.
1 Like

You seem to be missing the Table of Contents in your post. This is needed for the docs portion of and to keep everything uniform.

Just added to the bottom as per extension template. Took a bit to figure out what to do, but hopefully it works now. Thanks again