Detailed API Documentation
Here you will find comprehensive guide to coding functionality, complete with detailed documentation covering all public features and APIs.
Please note that this documentation always aims to document the latest released version of Squiso. Old versions of Squiso might not follow this documentation entirely.
If you have any questions or find any mistakes, feel free to join the Discord.
- Events Squiso can listen to
- Keyboard
- Ko-fi
- onKofiDonation(OnKofiDonationData listener, API api)
- onKofiShopOrder(OnKofiShopOrderData data, API api)
- onKofiSubscription(OnKofiSubscriptionData data, API api)
- OBS Studio
- onOBSInputMuted(OnOBSInputMutedData data, API api)
- onOBSInputVolumeChanged(OnOBSInputVolumeChangedData data, API api)
- onOBSSceneChanged(OnOBSSceneChangedData data, API api)
- Speech
- Twitch
- onTwitchAd(OnTwitchAdData data, API api
- onTwitchChannelFollow(OnTwitchChannelFollowData data, API api)
- onTwitchChannelPointRedeem(OnTwitchChannelPointRedeemData data, API api)
- onTwitchChatMessage(OnTwitchChatMessageData data, API api)
- onTwitchCheer(OnTwitchCheerData data, API api)
- onTwitchGiftedSubs(OnTwitchGiftedSubsData data, API api)
- onTwitchHypeTrainStarted(OnTwitchHypeTrainStartedData data, API api)
- onTwitchPollEnded(OnTwitchPollEndedData data, API api)
- onTwitchRaided(OnTwitchRaidedData data, API api)
- onTwitchStreamEnded(OnTwitchStreamEndedData data, API api)
- onTwitchStreamStarted(OnTwitchStreamStartedData data, API api)
- onTwitchSubscription(OnTwitchSubscriptionData data, API api)
- Actions Squiso can do
- AI (Artificial intelligence)
- api.generateAIImage(String prompt)
- api.generateAIImageText(SquisoData imageData, String contentType, String userMessage)
- api.generateAIText(String systemMessage, String userMessage)
- Asynchronous
- api.async(int ms, AsyncUtil.OnPerform onPerform)
- api.doLater(int ms, AsyncUtil.OnPerform onPerform)
- api.sleep(int ms)
- SquisoInteger ms, boolean doImmediately, AsyncUtil.OnPerform onPerform)
- Audio
- Discord
- Keyboard
- Keyboard (Advanced)
- Miscellaneous
- api.getSystemInfo()
- api.log(String message)
- api.takeScreenshot(int x, int y, int width, int height, String format)
- api.uploadFileTemp(byte[] data, UploadFileFormat format)
- api.uploadFileTemp(DataObject data, UploadFileFormat format)
- Mouse
- api.getMousePosition()
- api.mouseButton4Press()
- api.mouseButton4Press(int ms)
- api.mouseButton5Press()
- api.mouseButton5Press(int ms)
- api.mouseButtonLeftPress()
- api.mouseButtonLeftPress(int ms)
- api.mouseButtonMiddlePress()
- api.mouseButtonMiddlePress(int ms)
- api.mouseButtonRightPress()
- api.mouseButtonRightPress(int ms)
- api.moveMouse(int x, int y)
- api.scrollMouse(int notches)
- api.setMousePosition(int x, int y)
- Networking
- api.doGetRequestToString(String url)
- api.doRequest(String url)
- api.downloadFile(String url, String file)
- OBS Studio
- api.setOBSInputMuted(SquisoString inputName, boolean mute)
- api.setOBSScene(SquisoString sceneName)
- api.setOBSSceneItemVisibility(SquisoString sceneName, SquisoString itemName, boolean visibility)
- Process
- Twitch
- api.createTwitchClip()
- api.getTwitchChannelData(String userID)
- api.getTwitchChannelFollower(String userID)
- api.getTwitchChannelFollowers()
- api.getTwitchClip(String clipID)
- api.getTwitchClips()
- api.getTwitchUserData(String userName)
- api.sendTwitchChatAnnouncement(String text, String color)
- api.sendTwitchChatAnnouncement(String text)
- api.sendTwitchChatMessage(String text)
- api.sendTwitchShoutout(SquisoString userID)
- api.updateTwitchChannelTitle(String title)
- Various utility methods that can help you out
- JSON
- List
- Random
- RandomUtil.getRandom(int min, int max)
- RandomUtil.getRandom(List<T> list)
- RandomUtil.getRandom(T... array)
- RandomUtil.randomize(List list)
- String
- StringUtil.isEmpty(String s)
- StringUtil.toFilenameFriendly(String s)
- StringUtil.truncate(String s, int maxLength, boolean appendTrailingDots)
- URL
- Data Types
Events Squiso can listen to
Squiso can listen to various events.
Keyboard
Squiso can register and listen to keyboard accelerators (shortcuts).
onKeyboardAccelerator(OnKeyboardAcceleratorData data, API api)
This will listen to a previous registered keyboard accelerator.
Example code
@Override
public void onKeyboardAccelerator(OnKeyboardAcceleratorData data, API api) throws SquisoException {
SquisoString accelerator = data.getAccelerator(); // "CTRL+NUMPAD0"
});
Ko-fi
Squiso can listen to Ko-fi various transaction events using their webhook API.
onKofiDonation(OnKofiDonationData listener, API api)
This listens to Ko-fi donation events.
Example code
@Override
public void onKofiDonation(OnKofiDonationData listener, API api) throws SquisoException {
SquisoString username = data.getUsername();
SquisoDouble amount = data.getAmount();
SquisoString message = data.getMessage();
}
onKofiShopOrder(OnKofiShopOrderData data, API api)
This listens to Ko-fi shop order events.
Example code
@Override
public void onKofiShopOrder(OnKofiShopOrderData data, API api) throws SquisoException {
SquisoString username = data.getUsername();
SquisoDouble amount = data.getAmount();
}
onKofiSubscription(OnKofiSubscriptionData data, API api)
This listens to Ko-fi subscription events.
Example code
@Override
public void onKofiSubscription(OnKofiSubscriptionData data, API api) throws SquisoException {
SquisoString username = data.getUsername();
SquisoString tierName = data.getTierName();
SquisoDouble amount = data.getAmount();
SquisoString message = data.getMessage();
}
OBS Studio
Squiso can listen to various OBS Studio events by connecting to its websocket server.
onOBSInputMuted(OnOBSInputMutedData data, API api)
Listens to when an input (such the desktop audio or a microphone) goes mute or not.
Example code
@Override
public void onOBSInputMuted(OnOBSInputMutedData data, API api) throws SquisoException {
SquisoString inputName = data.getInputName();
boolean muted = data.isMuted();
}
onOBSInputVolumeChanged(OnOBSInputVolumeChangedData data, API api)
Listens to when an input (such the desktop audio or a microphone) changes volume.
Example code
@Override
public void onOBSInputVolumeChanged(OnOBSInputVolumeChangedData data, API api) throws SquisoException {
SquisoString inputName = data.getInputName();
SquisoInteger volume = data.getVolume();
}
onOBSSceneChanged(OnOBSSceneChangedData data, API api)
Listens to scene changes.
Example code
@Override
public void onOBSSceneChanged(OnOBSSceneChangedData data, API api) throws SquisoException {
SquisoString sceneName = data.getSceneName();
}
Speech
Squiso has basic capabilities to listen and transcribe your voice to text.
onSimpleSpeechToSquiso(OnSimpleSpeechToSquisoData data, API api)
This listens to Speech-to-Text data coming to Squiso.
Example code
@Override
public void onSimpleSpeechToSquiso(OnSimpleSpeechToSquisoData data, API api) throws SquisoException {
SquisoString text = data.getText();
}
Twitch
Squiso can listen to various Twitch related events.
onTwitchAd(OnTwitchAdData data, API api
This listens to when a Twitch ad break starts.
Example code
@Override
public void onTwitchAd(OnTwitchAdData data, API api) throws SquisoException {
boolean automatic = data.isAutomatic();
SquisoInteger duration = data.getDuration();
}
onTwitchChannelFollow(OnTwitchChannelFollowData data, API api)
This listens to Channel follows.
Example code
@Override
public void onTwitchChannelFollow(OnTwitchChannelFollowData data, API api) throws SquisoException {
SquisoString userID = data.getUserID();
SquisoString userName = data.getUserName();
}
onTwitchChannelPointRedeem(OnTwitchChannelPointRedeemData data, API api)
This listens to Channel Points reward redeems.
Example code
@Override
public void onTwitchChannelPointRedeem(OnTwitchChannelPointRedeemData data, API api) throws SquisoException {
SquisoString userID = data.getUserID();
SquisoString userName = data.getUserName();
SquisoString rewardID = data.getRewardID();
SquisoString rewardName = data.getRewardName();
SquisoString redeemText = data.getRedeemText();
SquisoInteger redeemCost = data.getRedeemCost();
}
onTwitchChatMessage(OnTwitchChatMessageData data, API api)
This listens to various chat messages that happens in your Twitch channel.
Example code
@Override
public void onTwitchChatMessage(OnTwitchChatMessageData data, API api) throws SquisoException {
SquisoString userID = data.getUserID();
SquisoString userName = data.getUserName();
SquisoString messageText = data.getMessageText();
SquisoString messageTextWithoutEmotes = data.getMessageTextWithoutEmotes();
boolean broadcaster = data.isUserBroadcaster();
boolean moderator = data.isUserModerator();
boolean vip = data.isUserVip();
boolean subscriber = data.isUserSubscriber();
boolean primeSubscriber = data.isUserPrimeSubscriber();
boolean founder = data.isUserFounder();
boolean subGifter = data.isUserSubGifter();
boolean subGifterLeader = data.isUserSubGifterLeader();
boolean partner = data.isUserPartner();
boolean turbo = data.isUserTurbo();
boolean messageCheer = data.isMessageCheer();
boolean messageChannelPoint = data.isMessageChannelPoint();
boolean messageEffect = data.isMessageEffect();
boolean messageHighlight = data.isMessageHighlight();
boolean messageGiganticEmote = data.isMessageGiganticEmote();
boolean messageFirstTime = data.isMessageFirstTime();
}
onTwitchCheer(OnTwitchCheerData data, API api)
This listens to bit cheers.
Example code
@Override
public void onTwitchCheer(OnTwitchCheerData data, API api) throws SquisoException {
SquisoString userID = data.getUserID();
SquisoString userName = data.getUserName();
SquisoInteger bits = data.getBits();
SquisoString message = data.getMessage();
}
onTwitchGiftedSubs(OnTwitchGiftedSubsData data, API api)
This listens to when subs are gifted in the channel
Example code
public void onTwitchGiftedSubs(OnTwitchGiftedSubsData data, API api) throws SquisoException {
SquisoString userID = data.getUserID();
SquisoString userName = data.getUserName();
boolean anonymous = data.isUserAnonymous();
SquisoInteger totalGifted = data.getTotalGifted();
SquisoInteger cumulativeTotalGifted = data.getCumulativeTotalGifted();
}
onTwitchHypeTrainStarted(OnTwitchHypeTrainStartedData data, API api)
This listens to when a Hype Train is being started in the channel.
Example code
@Override
onTwitchHypeTrainStarted(OnTwitchHypeTrainStartedData data, API api) throws SquisoException {
}
onTwitchPollEnded(OnTwitchPollEndedData data, API api)
This listens to when Twitch polls have ended.
Example code
@Override
public void onTwitchPollEnded(OnTwitchPollEndedData data, API api) throws SquisoException {
SquisoString title = data.getTitle();
SquisoString winner = data.getWinner();
}
onTwitchRaided(OnTwitchRaidedData data, API api)
This listens to when the Twitch channel is being raided by another channel.
Example code
@Override
public void onTwitchRaided(OnTwitchRaidedData data, API api) throws SquisoException {
SquisoString userID = data.getUserID(); // 1234567890
SquisoString userName = data.getUserName(); // squiso
SquisoInteger nbrOfViewers = data.getNbrOfViewers(); // 1337
}
onTwitchStreamEnded(OnTwitchStreamEndedData data, API api)
This listens to when your stream goes offline and ends.
Example code
@Override
public void onTwitchStreamEnded(OnTwitchStreamEndedData data, API api) throws SquisoException {
}
onTwitchStreamStarted(OnTwitchStreamStartedData data, API api)
This listens to when your stream goes online and starts.
Example code
@Override
public void onTwitchStreamStarted(OnTwitchStreamStartedData data, API api) throws SquisoException {
}
onTwitchSubscription(OnTwitchSubscriptionData data, API api)
This listens to channel subscriptions.
Example code
@Override
public void onTwitchSubscription(OnTwitchSubscriptionData data, API api) throws SquisoException {
SquisoString userID = data.getUserID();
SquisoString userName = data.getUserName();
SquisoString tierName = data.getTierName();
boolean gifted = data.isGifted();
boolean reSubscription = data.isReSubscription();
SquisoInteger cumulativeMonths = data.getCumulativeMonths();
SquisoString message = data.getMessage();
}
Actions Squiso can do
Squiso can perform various actions.
AI (Artificial intelligence)
Squiso can perform various AI related actions.
api.generateAIImage(String prompt)
This generates an AI response given a prompt and returns an Image.
Returns
SquisoData
- An AI generated image object in JPEG format
Example code
// Compose an image prompt using the number of sub-gifts
String prompt = "A ninja baking a pizza. Japanese Manga Style. Full Background. No Text.";
// Generate an AI image using a given prompt
SquisoData image = api.generateAIImage(prompt);
// Save the image to d:\generated.jpg
FileUtil.writeFile("d:\\generated.jpg", image);
api.generateAIImageText(SquisoData imageData, String contentType, String userMessage)
This will ask AI to analyze a given image with and system message and give back a written response.
Returns
String
- The AI generated text
Example code
// Take a screenshot of the desktop as a JPG
SquisoData screenshot = api.takeScreenshot(0, 0, 1920, 1080, "jpg");
// Ask AI to analyze the image
String description = api.generateAIImageText(screenshot, "jpg", "Give me a short description of what you see.");
api.generateAIText(String systemMessage, String userMessage)
This generates an AI response given both a system message (prompt) and a user message (user input).
Returns
String
- The AI generated text
Example code
// Compose the system message (prompt)
String systemMessage = "";
systemMessage += "Your name is Mr Robot and you are Squiso's AI sidekick. ";
systemMessage += "Squso is a Twitch streamer.";
systemMessage += "You are talking to " + user.getUsername() + " who is a viewer. ";
systemMessage += "Follow the Twitch chat guidelines. ";
systemMessage += "Use same language as the chat message. ";
systemMessage += "Keep the answer truthful but humorous and make it only a few sentences.";
// This is just to highlight that the AI needs a user message as well
String userMessage = "what the user typed";
// Generate an AI response
String aiResponse = api.generateAIText(systemMessage, userMessage);
Asynchronous
Normally Squiso does synchronous operations, but it is also possible to do special asynchronous operations.
api.async(int ms, AsyncUtil.OnPerform onPerform)
Used to do an operation asynchronously.
Example code
// Do something asynchronously (in the background on its own)
api.async(() -> {
api.log("This will be written asynchronously!");
});
api.doLater(int ms, AsyncUtil.OnPerform onPerform)
This perform operation (asynchronously) after a given set of ms.
Example code
// Do this after 20 seconds
api.doLater(20 * 1000, () -> {
api.log("This will be written 20 seconds later!");
});
api.sleep(int ms)
This will pause / halt your application for a certain amount of time specified in milliseconds.
Example code
// Specify how long it should pause. 2.5 seconds is 2500 milliseconds.
int duration = 2500;
// Pausing
api.sleep(duration);
SquisoInteger ms, boolean doImmediately, AsyncUtil.OnPerform onPerform)
Used to do an operation periodically every given ms.
Example code
// Every 5 seconds
SquisoInteger interval = new SquisoInteger(5 * 1000);
// Do this every 5 seconds
api.doEvery(interval, true, () -> {
api.log("Tick!");
});
Audio
Various audio related actions.
api.playAudio(String file)
This will take in a path to a an audio file and play it. Only WAV or MP3 audio files are supported.
Example code
api.playAudio("c:\streaming\sound_effects\zelda.mp3");
api.speak(String voiceID, SquisoString message)
Plays a TTS (Text-To-Speech) message given a voice ID and a message. Some AI voices requires that you are a Project Supporter. You can find all voices here: https://www.api.com/voices/
Example code
// Specify the voice
String voiceID = "abcd1234";
// Specify what message should be spoken.
SquisoString message = new SquisoString("You are looking pog today!");
// Play the TTS
api.speak(voiceID, message);
Discord
Squiso can perform various Discord related actions.
api.sendSimpleDiscordMessage(String discordWebhookURL, String message)
This sends a simple plaintext message to a Discord channel through the webhook URL.
Example code
// A string that contains the Discord webhook URL
String webhookURL = "https://discord.com/api/webhooks/123/abc";
// The message that should be sent to the Discord channel
// The \n character creates a "new line" in the message
String message = "Squiso says hi! \n https://www.api.com";
api.sendSimpleDiscordMessage(webhookURL, message);
Keyboard
Squiso can simulate various keyboard key operations.
api.keyPress(int ms, KeyboardKey... keys)
This simulates a keyboard press of one or several keys with a certain given ms duration.
Example code
// Simulate key press SHIFT + p + o + g, holding it down for 50ms
api.keyPress(50, KeyboardKey.SHIFT, KeyboardKey.P, KeyboardKey.O, KeyboardKey.G);
api.keyPress(KeyboardKey... keys)
This simulates a keyboard press of one or several keys with a default duration.
Example code
// Simulate key press SHIFT + p + o + g
api.keyPress( KeyboardKey.SHIFT, KeyboardKey.P, KeyboardKey.O, KeyboardKey.G);
Keyboard (Advanced)
Squiso can simulate various keyboard key operations.
api.keyDown(KeyboardKey... keys)
This simulates a keyboard key down of one or several keys. Please remember to api.keyUp() as well or else there could be weird and unpredictable side effects on your system.
Example code
// Simulate the W key down
api.keyDown(KeyboardKey.W);
api.keyUp(KeyboardKey... keys)
This simulates a keyboard key up of one or several keys.
Example code
// Simulate the W key up
api.keyUp(KeyboardKey.W);
Miscellaneous
Various miscellaneous actions.
api.getSystemInfo()
This will return various information about your current system.
Returns
SystemInfo
- An object that contains various information about your system.
Example code
// Retrieve various information about your system
SystemInfo si = api.getSystemInfo();
double totalMemoryBytes = si.getTotalMemoryBytes(); // 3.4282610688E10
double usedMemoryBytes = si.getUsedMemoryBytes(); // 1.7612066816E10
double availableMemoryBytes = si.getAvailableMemoryBytes(); // 1.6670543872E10
String totalMemoryGB = si.getTotalMemoryGB(); // 31.93
String usedMemoryGB = si.getUsedMemoryGB(); // 16.40
String availableMemoryGB = si.getAvailableMemoryGB(); // 15.53
String os = si.getOS(); // Microsoft Windows 10 64 bit
String osManufacturer = si.getOSManufacturer(); // Microsoft
String osFamily = si.getOSFamily(); // Windows
String osVersion = si.getOSVersion(); // 10
int osBitness = si.getOSBitness(); // 64
String gpu = si.getGPU(); // NVIDIA GeForce GTX 1660 SUPER
String cpu = si.getCPU(); // AMD Ryzen 5 2600X Six-Core Processor
api.log(String message)
Simply logs a message to the terminal.
Example code
api.log("This will be displayed in the terminal window.");
api.takeScreenshot(int x, int y, int width, int height, String format)
This will take a screenshot of your desktop, given an X and Y starting position and width and height and what type of image.
Returns
SquisoData
- A Screenshot data object with byte[] data
Example code
// Take as a JPG screenshot of the desktop from position 0x0 with width 1920px and height 1080px
SquisoData screenshot = api.takeScreenshot(0, 0, 1920, 1080, "jpg");
api.uploadFileTemp(byte[] data, UploadFileFormat format)
Uploads a file temporarily onto the Squiso web servers and returns a public URL.
Returns
String
- An temporarily URL of the uploaded file.
Example code
byte[] data = ...;
// Uploads a DataObject and returns an URL
String url = api.uploadFileTemp(data, UploadFileFormat.PNG);
api.uploadFileTemp(DataObject data, UploadFileFormat format)
Uploads a file temporarily onto the Squiso web servers and returns a public URL.
Returns
String
- An temporarily URL of the uploaded file.
Example code
DataObject screenshot = ...
// Uploads a DataObject and returns an URL
String url = api.uploadFileTemp(screenshot, UploadFileFormat.PNG);
Mouse
Squiso can simulate various mouse operations.
api.getMousePosition()
Retrieves the current mouse position.
Returns
MousePosition
- Contains the X and Y position of the mouse.
Example code
// Get the current mouse position
MousePosition position = api.getMousePosition();
// Get the specific X and Y position
int x = position.getX();
int y = position.getY();
api.mouseButton4Press()
Simulate the button 4 press for a given amount of ms duration.
Example code
// Simulate a normal 4 button press.
api.mouseButton4Press()
api.mouseButton4Press(int ms)
Simulate the button 4 press for a given amount of ms duration.
Example code
// Simulate a 3 seconds 4 button press.
api.mouseButton4Press(3000)
api.mouseButton5Press()
Simulate the button 5 press for a given amount of ms duration.
Example code
// Simulate a normal 5 button press.
api.mouseButton5Press()
api.mouseButton5Press(int ms)
Simulate the button 5 press for a given amount of ms duration.
Example code
// Simulate a 3 seconds 5 button press.
api.mouseButton5Press(3000)
api.mouseButtonLeftPress()
Simulate the button left press for a given amount of ms duration.
Example code
// Simulate a normal left button press.
api.mouseButtonLeftPress()
api.mouseButtonLeftPress(int ms)
Simulate the button left press for a given amount of ms duration.
Example code
// Simulate a 3 seconds left button press.
api.mouseButtonLeftPress(3000)
api.mouseButtonMiddlePress()
Simulate the button middle press for a given amount of ms duration.
Example code
// Simulate a normal middle button press.
api.mouseButtonMiddlePress()
api.mouseButtonMiddlePress(int ms)
Simulate the button middle press for a given amount of ms duration.
Example code
// Simulate a 3 seconds middle button press.
api.mouseButtonMiddlePress(3000)
api.mouseButtonRightPress()
Simulate the button right press for a given amount of ms duration.
Example code
// Simulate a normal right button press.
api.mouseButtonRightPress()
api.mouseButtonRightPress(int ms)
Simulate the button right press for a given amount of ms duration.
Example code
// Simulate a 3 seconds right button press.
api.mouseButtonRightPress(3000)
api.moveMouse(int x, int y)
This moves the mouse pointer relative to its current position.
Example code
// Move the mouse position to the right 200px and down 50px
api.moveMouse(200, 50);
api.scrollMouse(int notches)
Simulate mouse wheel scrolling.
Example code
// Scroll the mouse wheel 5 notches.
api.scrollMouse(5);
// Scroll the mouse wheel -5 notches.
api.scrollMouse(5);
api.setMousePosition(int x, int y)
This moves the mouse pointer to a given position.
Example code
// Move the mouse position to position 800x600 on the screen
api.setMousePosition(800, 600);
Networking
Squiso can also do basic HTTP requests (webhooks).
api.doGetRequestToString(String url)
Does a simple HTTP GET request to the given URL and returns the response body as plain text.
Returns
String
- The response body as a String
Example code
String responseBody = api.doGetRequestToString("https://www.api.com");
api.doRequest(String url)
Does a simple HTTP GET request to the given URL.
Example code
// Does a simple HTTP GET request
api.doRequest("https://www.api.com");
api.downloadFile(String url, String file)
Downloads the specific URL resource to the given file.
Example code
String url = "https://file-examples.com/wp-content/storage/2017/04/file_example_MP4_480_1_5MG.mp4";
String file = "video.mp4";
api.downloadFile(url, file);
OBS Studio
Squiso can tell OBS Studio to perform certain actions.
api.setOBSInputMuted(SquisoString inputName, boolean mute)
Tell OBS Studio to mute or unmute an input source.
Example code
// Specify the input name
SquisoString inputName = new SquisoString("Desktop Audio");
// Whether it should be muted or not
boolean mute = true;
// Mute or unmute the input
api.setOBSInputMuted(inputName, mute);
api.setOBSScene(SquisoString sceneName)
Tell OBS Studio to switch to a certain scene.
Example code
// Specify the scene we should switch to
SquisoString sceneName = new SquisoString("BRB");
// Change scenes
api.setOBSScene(sceneName);
api.setOBSSceneItemVisibility(SquisoString sceneName, SquisoString itemName, boolean visibility)
Tell OBS Studio or show or hide a certain scene item.
Example code
// Specify the scene
SquisoString sceneName = new SquisoString("Gaming");
// Specify the item
SquisoString itemName = new SquisoString("My Camera");
// Specify whether the item should be be visible or not
boolean visibility = false;
// Toggle the item visibility
api.setOBSSceneItemVisibility(sceneName, itemName, visibility);
Process
Various application process related actions.
api.exec(String command)
This will execute a command on your computer, as if it was executed in a window command terminal.
Example code
// Start notepad
api.exec("notepad");
// Start steam.exe with game ID 1091500
api.exec("C:\\games\\steam\\Steam.exe steam://rungameid/1091500");
api.openURL(String url)
Opens up an URL using your default browser.
Example code
// Opens up https://www.api.com/
api.openURL("https://www.api.com/");
Twitch
Squiso can perform various Twitch related actions.
api.createTwitchClip()
Creates a Twitch clip and returns the clip creation data.
Returns
CreateTwitchClipResult
- Clip creation data
Example code
// Create a clip
CreateTwitchClipResult createData = api.createTwitchClip();
// The clip ID
String clipID = createData.getClipID();
// The clip URL
String clipURL = createData.getClipURL();
// The clip edit URL
String editURL = createData.getEditURL();
api.getTwitchChannelData(String userID)
Returns data about the Twitch channel. If the channel does not exist, it returns null.
Returns
ChannelData
- Various channel data. If the channel does not exist, it will be null.
Example code
// Get channel data for 01234567890
ChannelData channelData = api.getTwitchChannelData("01234567890");
SquisoString userID = channelData.getID(); // 1234567890
SquisoString name = channelData.getName(); // squiso
SquisoString language = channelData.getLanguage(); // en
SquisoString title = channelData.getTitle(); // Current channel title
SquisoString gameName = channelData.getGameName(); // Current game category name
api.getTwitchChannelFollower(String userID)
Returns follower data for the specific user ID. If the user does not follow your channel, it will return null.
Returns
FollowerData
- FollowerData if the user follows your channel, else it will return null.
Example code
FollowerData follower = api.getTwitchChannelFollower("1234567890");
String userID = follower.getID(); // 1234567890
String name = follower.getName(); // Squiso
SquisoDate followedAt = follower.getFollowedAt(); // A date object to when the user started to follow your channel
api.getTwitchChannelFollowers()
Returns the list of followers of your Twitch channel.
Returns
SquisoList
- A list of Followers.
Example code
SquisoList<FollowerData> followers = api.getTwitchChannelFollowers();
api.getTwitchClip(String clipID)
Fetches data about a certain clip.
Returns
TwitchClip
- Clip data
Example code
String clipID = "";
// Get data about the clip
GetClipDataResult clipData = api.getTwitchClip(clipID);
// Get the .mp4 video URL
String videoURL = clipData.getVideoURL()
api.getTwitchClips()
Returns a list of all clips for your Twitch channel.
Returns
List<TwitchClip>
- A list of twitch clips.
Example code
// Get all clips on your channel
List<TwitchClip> allClips = api.getTwitchClips();
api.getTwitchUserData(String userName)
Returns data about the Twitch user. If the user does not exist, it returns null.
Returns
UserData
- Various user data. If the user does not exist, it will be null.
Example code
// Get user data for "squiso"
UserData userData = api.getTwitchUserData("squiso");
SquisoString userID = userData.getID(); // 1234567890
SquisoString name = userData.getName(); // squiso
SquisoString description = userData.getDescription(); // User description
SquisoDate userCreated = userData.getCreated(); // When the user account was created
boolean affiliate = userData.isAffiliate(); // true/false whether they are an affiliate
boolean partner = userData.isPartner(); // true/false whether they are a partner
api.sendTwitchChatAnnouncement(String text, String color)
Creates a chat announcement in your Twitch channel with a specific color (primary, blue, green, orange or purple).
Example code
// Create the message that should be displayed
String message = "Ads will start in 1 minute!"
// Specify the color of the announcement
String color = "orange";
// Send the announcement
api.sendTwitchChatAnnouncement(message, color);
api.sendTwitchChatAnnouncement(String text)
Creates a chat announcement in your Twitch channel using the primary color
Example code
// Create the message that should be displayed
String message = "Ads will start in 1 minute!"
// Send the announcement
api.sendTwitchChatAnnouncement(message);
api.sendTwitchChatMessage(String text)
Sends a chat message to your Twitch channel.
Example code
// Create the message that should be sent to chat
String message = "Please support me by following my instagram! https://instagram.com/username/";
// Send the chat message
api.sendTwitchChatMessage(message);
api.sendTwitchShoutout(SquisoString userID)
Creates a Twitch shoutout in the chat.
Example code
SquisoString userID = new SquisoString("437933731");
// Send the shoutout in chat
api.sendTwitchShoutout(userData.getID());
api.updateTwitchChannelTitle(String title)
Updates your Twitch channel title.
Example code
String newTitle = "This is my new stream title!";
// Update the Twitch channel title
api.updateTwitchChannelTitle(newTitle);
Various utility methods that can help you out
Various utility methods in order to help developers solve common tasks.
JSON
Various random JSON utility methods.
JSONUtil.toObject(String json, Class<T> c)
Converts a JSON string back to an object.
Returns
T
- The object
Example code
WebhookData webhookData = JSONUtil.toObject(jsonString, WebhookData.class);
JSONUtil.toString(Object object)
Returns a JSON string out of the given object.
Returns
String
- JSON representation of the object.
Example code
String json = JSONUtil.toString(object);
List
Various List related utility methods.
ListUtil.getBasedOnString(List<T> list, String s)
Returns a specific item in the given list based on the string.
Returns
<T>
- An item from the list
Example code
// Get a voice based on the username
String voiceID = ListUtil.getBasedOnString(voices, username);
Random
Various random related utility methods.
RandomUtil.getRandom(int min, int max)
Returns a random number between two given numbers.
Returns
int
- A random number between min and max.
Example code
int randomNumber = RandomUtil.getRandom(0, 100);
RandomUtil.getRandom(List<T> list)
Returns a random item from generic list.
Returns
<T>
- A random item from a generic list.
Example code
// A list of stuff
List<String> names = new ArrayList<>();
names.add("anna");
names.add("steve");
names.add("emelie");
names.add("george");
// Returns a random string from the given list
String name = RandomUtil.getRandom(names);
RandomUtil.getRandom(T... array)
Returns a random item from a generic varargs array.
Returns
<T>
- A random item from a generic varargs array.
Example code
// Returns a random string from the given arguments
String name = RandomUtil.getRandom("anna", "steve", "emelie", "george");
RandomUtil.randomize(List list)
Shuffles a list of items.
Example code
// A list of stuff
List<String> names = new ArrayList<>();
names.add("anna");
names.add("steve");
names.add("emelie");
names.add("george");
// The list is now shuffled
RandomUtil.randomize(names);
String
Various String related utility methods.
StringUtil.isEmpty(String s)
Checks if a String is either null or empty ("").
Returns
boolean
- True or false whether the given string is empty or not.
Example code
// False
boolean empty = StringUtil.isEmpty("squiso");
// True
boolean empty = StringUtil.isEmpty(null);
// True
boolean empty = StringUtil.isEmpty("");
StringUtil.toFilenameFriendly(String s)
Makes the given string safe for filenames.
Returns
String
- Filename safe string.
Example code
String file = clip.getCreated().toYYYYMMDDHHMMSS() + "__" + clip.getGameID() + "__" + clip.getCreator().toLowerCase() + ".mp4";
// Make the filename disk friendly
file = StringUtil.toFilenameFriendly(file);
StringUtil.truncate(String s, int maxLength, boolean appendTrailingDots)
Truncates and trims a given string based on max length and whether "..." should be appended as well.
Returns
String
- The truncated String
Example code
// Returns "Hello"
String truncated = StringUtil.truncate("Hello Squiso!", 6, false);
// Returns "Hel..."
String truncated = StringUtil.truncate("Hello Squiso!", 6, true);
// Returns "Hello Squiso!"
String truncated = StringUtil.truncate("Hello Squiso!", 50, false);
URL
Various URL related utility methods.
URLUtil.encode(String value)
URL encode a query parameter value so it becomes safe to use in an URL.
Returns
String
- URL encoded value
Example code
String url = "https://www.squiso.com/?name=" + URLUtil.encode("Mr Squiso");
Data Types
Squiso has its own data types in order to be as user friendly as possible by hide technical complexity.
SquisoData
Contains binary data
squisoData.writeToFile(String file)
Writes the binary data to the given file.
Example code
// Save the screenshot to the disk as well
screenshot.writeToFile("screenshot.jpg");
SquisoDate
Contains date and time information.
squisoDate.getDetailedDurationFromNow()
Returns a detailed duration with multiple time units from now.
Returns
String
- A string with multiple time units since now.
Example code
String s = squisoDate.getDetailedDurationFromNow(); // 1 month 22 days 21 hours 15 minutes 8 seconds
squisoDate.getDurationFromNow()
Returns a string duration with a single time unit since now.
Returns
String
- A string with a single time unit since now.
Example code
String s = squisoDate.getDurationFromNow(); // 1 month
SquisoDate.nowLocal()
Creates a new SquisoDate based on the local time.
Returns
SquisoDate
- A SquisoDate object.
Example code
SquisoDate now = SquisoDate.nowLocal();
SquisoDate.nowUTC()
Creates a new SquisoDate based on the UTC time.
Returns
SquisoDate
- A SquisoDate object.
Example code
SquisoDate now = SquisoDate.nowUTC();
SquisoDate.parse(String s)
Tries to parse the given string as a date.
Returns
SquisoDate
- A SquisoDate object.
Example code
SquisoDate date = SquisoDate.parse("2020-01-02 11:12:13");
squisoDate.toYYYYMMDDHHMMSS()
Returns the date according to the format: yyyy-MM-dd HH:mm:ss
Returns
String
- In the format: yyyy-MM-dd HH:mm:ss
Example code
String s = squisoDate.toYYYYMMDDHHMMSS();
SquisoString
Contains string data.
squisoString.isEmpty()
Returns true or false whether the string is empty (including empty spaces).
Returns
boolean
- Returns true or false whether the string is empty (including empty spaces).
Example code
SquisoString s = new SquisoString(" ");
boolean empty = s.isEmpty(); // true