Custom APIs for Bots (Nightbot/Streamlabs Chatbot/Deepbot)
Edit - 2017-06-23:
This hasn’t been updated with new custom APIs that I’ve added over time from feature requests and such. If you want an over of what extra those might be, I suggest you take a look at the DecAPI documentation, even though it lacks good examples.
Information:
Over time I’ve written several “custom APIs” for certain things I’d find useful to have in chat, so that it’s a bit easier for myself and other chat moderators.
Some of these custom APIs are already documented on this blog such as the latest tweet, uptime or subscriber count.
Before moving on to covering all of the custom APIs, I will mention a few things beforehand:
- In most cases, you will be able to utilize other variables that the bot supports.
- Take a look at “Variables” page in the Nightbot docs, pages 50-58 of the Streamlabs Chatbot docs, or the custom commands page for Deepbot to see what options you have.
- For each custom API I will only provide the URL for it as well as a description of it. This URL has to be inserted in the specific bot’s respective variables.
- You can find the variables below where you replace
CUSTOM_API_URL_HERE
with the URL of the custom API you wish to use.- For Nightbot:
$(urlfetch CUSTOM_API_URL_HERE)
- For StreamLabs Chatbot:
$readapi(CUSTOM_API_URL_HERE)
- For Deepbot:
@customapi@[CUSTOM_API_URL_HERE]
- For Nightbot:
- If your bot isn’t listed here it’s still possible it has the ability to utilize these custom APIs. Please refer to your bot’s own documentation for information regarding this.
- You can find the variables below where you replace
- Example/placeholder parameters will be surrounded by ‘curly brackets’, for example
{CHANNEL}
.- Do not include these ‘curly brackets’ in the actual URLs. Example if the channel name is
decicus
, then you replace{CHANNEL}
with justdecicus
.
- Do not include these ‘curly brackets’ in the actual URLs. Example if the channel name is
- Optional parameters will be covered per custom API, for those that this applies to.
Twitch
- https://decapi.me/twitch/followcount/{CHANNEL}
- Description: Gives the current follower count of the specified channel.
- Example URL: https://decapi.me/twitch/followcount/decicus
- https://decapi.me/twitch/followed?channel={CHANNEL}&user={USER}
- Description: This posts the date (in UTC timezone) of when the {USER} followed the {CHANNEL}.
- Notes:
- You could modify
{USER}
to use the variables$(user)
(Nightbot),$user
(StreamLabs Chatbot) or@user@
(Deepbot), if you wish to make it so it checks the date of whoever does the command.
- You could modify
- Example URL: https://decapi.me/twitch/followed?channel=twitch&user=decicus
- https://decapi.me/twitch/followers?channel={CHANNEL}
- Description: Retrieves the latest followers for a specified channel.
- Optional parameters:
count
– Defaults to 1, but can be anything between 1 and 100.separator
– Defaults to a comma and a single space character afterwards (, ). This value is used to separate each user.- This should be URL encoded to prevent errors.
num
– Does not need any value specified, but when added to the URL, it will specify a number before each user where 1 is the latest follower.
- Example URL: https://decapi.me/twitch/followers?channel=decicus&count=5&num&separator=%20-%20
- https://decapi.me/twitch/help/{SEARCH}
- Description: Retrieves a Twitch help article based on the specified search.
- Optional parameters:
list
– Returns a list of available help articles, with the title of each article (cannot be used in chat due to length).
- Notes:
- If
{SEARCH}
islist
, it will provide a link to the list of help articles (with titles). - This generally requires another variable to accept user input, such as Nightbot’s
$(querystring)
or StreamLabs Chatbot’s$msg
.- Other bots may have something similar. Please refer to their documentation for further information.
- If
- Example URLs:
- Nightbot: https://decapi.me/twitch/help/$(querystring)
- StreamLabs Chatbot: https://decapi.me/twitch/help/$msg
- https://decapi.me/twitch/highlight?channel={CHANNEL}
- Description: Retrieves the latest highlight title and URL to the highlight for the specified channel (if they have any available highlights).
- Example: https://decapi.me/twitch/highlight?channel=twitch
- https://decapi.me/twitch/subcount/{CHANNEL}
- Description: Gets the subscriber count of the specified channel (if they are partnered/affiliated with subscribers).
- Notes:
- This requires authentication by the partnered/affiliated channel to work properly.
- Keep in mind that this counts your actual subscribed users, not subscriber points.
- Channels with Nightbot can use this instead, and achieve the same result:
$(twitch $(channel) "")
- Example:
- https://decapi.me/twitch/subcount?channel=decicus
decicus
is the channel name in the example.
- https://decapi.me/twitch/subscriber_emotes?channel={CHANNEL}
- Description: Gets the subscriber emotes for the specified channel and puts them into chat.
- Notes: If the bot isn’t subscribed to your channel in one way or another, it will just put the emote name (as text) into chat. However, if it is subscribed, it will display the emotes as images instead of text.
- Example: https://decapi.me/twitch/subscriber_emotes?channel=lirik
- https://decapi.me/twitch/uptime?channel={CHANNEL}
- Description: Says how long it has been since the stream started, or if the channel is offline.
- Optional parameters:
offline_msg
- Will replace the default offline message (channel is offline
) with the specified value.- Make sure to URL encode your offline message to prevent any errors.
- Example: https://decapi.me/twitch/uptime?channel=decicus&offline_msg=Decicus+is+currently+not+streaming
- https://decapi.me/twitch/followage/:channel/:user
- Description: Checks the specified user’s “follow age” (how long it has been since the user followed the channel).
- Optional parameters:
precision
– How precise the calculation of the “follow age” is. Defaults to 2.- While there is technically no limit on the precision, this will not require anything higher than “7” as the precision is calculated in this order:
- years, months, weeks, days, hours, minutes, seconds
- While there is technically no limit on the precision, this will not require anything higher than “7” as the precision is calculated in this order:
- Notes:
- This calculates the time between the last time the user followed and now, if the user has been following for a while, then unfollows and refollows, it will be reset.
- Example:
- With default precision (nothing specified): https://decapi.me/twitch/followage/joshua/decicus
- With precision set to 4 (stops at the amount of days): https://decapi.me/twitch/followage/joshua/decicus?precision=4
- With precision set to 10 (the actual amount of precision is 7): https://decapi.me/twitch/followage/joshua/decicus?precision=10
- Nightbot example:
- Command:
$(touser) has been following Joshua for $(urlfetch https://decapi.me/twitch/followage/joshua/$(touser)?precision=7)
- Example usage:
!followage decicus
- Example response:
decicus has been following Joshua for 9 months, 3 weeks, 1 day, 11 hours, 15 minutes, 25 seconds
- Command:
- https://decapi.me/twitter/latest?name={USERNAME}
- Description: Gets the latest tweet of the specified user.
- Optional parameters:
no_rts
– Ignores retweets and gets the latest normal tweet.url
– Appends the direct URL of the tweet. Looks like this:This is a tweet - TWEET_URL_HERE
howlong
– Appends how long it has been since the tweet was tweeted out. Looks like this:This is a tweet - 12 hours, 4 minutes ago
- Notes: Your Twitter profile (and tweets) needs to available to the public for this to function properly.
- Example: https://decapi.me/twitter/latest?name=Decicus&no_rts&howlong&url
- https://decapi.me/twitter/latest_url?name={USERNAME}
- Description: Gets the direct URL of the latest tweet for the specified user.
- Optional parameters:
howlong
– Appends how long it has been since the tweet was tweeted out. Looks like this:https://twitter.com/Decicus/status/745039600473767941 - 12 hours, 4 minutes ago
include_replies
– Gets the latest URL of the latest tweet, regardless if it was a normal tweet or a reply to another tweet.
- Example: https://decapi.me/twitter/latest_url?name=Decicus
YouTube
- https://decapi.me/youtube/latest_video
- Description: Gets the latest YouTube video of the specified YouTube channel.
- Notes:
- If you have a YouTube channel URL in the /channel/ format, add
?id=CHANNEL_ID_HERE
at the end of the URL - If you have a channel URL in the /c/ format, go to this page: https://www.youtube.com/account_advanced and copy the “YouTube channel ID”. Then use the channel ID at the end of the URL:
?id=CHANNEL_ID_HERE
- See this screenshot for reference.
- If you have a channel URL in the /user/ format, use
?user=USERNAME_HERE
at the end of the URL - If you wish to skip a specific amount of videos (starting from the very latest one), you can add
&skip=15
where15
can be a number between 1 and 49.
- If you have a YouTube channel URL in the /channel/ format, add
- Example:
- https://decapi.me/youtube/latest_video?id=UCHVbuwA78fcrsESJtKGz7dg (YouTube channel: Rhymesayers)
- https://decapi.me/youtube/latest_video?user=MonstercatMedia (YouTube channel: Monstercat Media)
Other
- https://decapi.me/bttv/emotes?channel={CHANNEL}
- Description: Gets all the available BetterTTV emote codes for the specified channel.
- Example: https://decapi.me/bttv/emotes?channel=decicus
- https://decapi.me/misc/currency?value={AMOUNT}&from={FROM}&to={TO}
- Description: Converts the
{AMOUNT}
in the specified{FROM}
currency to the{TO}
currency.An - Notes:
- You can utilize bot variables if you wish to accept user input, such as
$(1), $(2) & $(3)
for Nightbot. - This relies on the fixer.io API.
- You can utilize bot variables if you wish to accept user input, such as
- Example:
- Converting 20 US dollars to Euro: https://decapi.me/misc/currency?from=USD&to=EUR&value=20
- Converting 300 Norwegian Krone to US dollars: https://decapi.me/misc/currency?from=NOK&to=USD&value=300
- Converting 12.34 Euro to British Pounds: https://decapi.me/misc/currency?from=EUR&to=GBP&value=12.34
- A Nightbot example with variables: https://decapi.me/misc/currency?value=$(1)&from=$(2)&to=$(3)
- Usage (100 US dollars to British Pounds):
!commandname 100 USD GBP
- Usage (100 US dollars to British Pounds):
- Description: Converts the
- https://decapi.me/misc/time?timezone={TIMEZONE}
- Description: Shows the current time (using 12-hour clock) for the specified timezone.’
- Notes:
- You can get a full list of available timezones by not specifying one at all: https://decapi.me/misc/time
- Example:
- Time in Oslo, Norway (Central European Time): https://decapi.me/misc/time?timezone=Europe/Oslo
- https://decapi.me/dayz/status-report
- Description: For those interested in DayZ Standalone, this custom API provides a link to the latest “Status Report” on their website.
- Example: https://decapi.me/dayz/status-report
- https://decapi.me/dayz/steam-status-report
- Description: Similar to the previous one, this custom API provides a link to the latest “Status Report” on their Steam ‘news’ page.
- Example: https://decapi.me/dayz/steam-status-report
- https://decapi.me/steam/hours?id={STEAM64}&appid={APP_ID}
- Description: Gets the amount of hours of a game (APP_ID) for the specified Steam ID.
- Notes:
- If the custom API doesn’t work, then you either have to put your Steam profile to public or use your own Steam API key (check “Optional parameters” for this method).
- Your Steam64 ID can be found using several tools, such as steamid.co.
- The app ID is the ID of the Steam game. This is relatively easy to find in the store page URL. For example, the Steam store page URL for Counter-Strike: Global Offensive is https://store.steampowered.com/app/730/ where the number “730” is the app ID.
- Optional parameters:
round
– The number of decimals to round the number of hours down to. Defaults to 2.key
– *Only recommended if you need to keep your Steam profile set to private.**- This parameter needs to be the account owner’s Steam API key for it to have an effect.
- You can sign up and get your Steam API key here: https://steamcommunity.com/dev/apikey
- If you decide to use this, please make sure to not add your command directly through chat as exposing your API key to the public is not recommended!
- Example:
- My profile – Game: Counter-Strike: Global Offensive – 1 decimal
- https://decapi.me/steam/hours?id=76561197997719567&appid=730&round=1
- https://decapi.me/br/player/{STEAM64}
- Description: Retrieves player information about the specified player from the Arma 3 Battle Royale leaderboards, where {ID} is either your STEAM64 ID or your unique ID from Arma 3 Battle Royale.
- Notes:
- By default, this will retrieve from the regular ranked games. If you want hardcore, add
/hardcore
at the end of the URL.- Please keep in mind that if you add
/hardcore
to the URL, all options parameters must come after the/hardcore
part.
- Please keep in mind that if you add
- Alternatively, you can add
/regular
at the end of the URL, but this generally doesn’t change anything asregular
is the default.
- By default, this will retrieve from the regular ranked games. If you want hardcore, add
- Optional parameters:
options
– You can see what it retrieves by default by specifyingdefault
. You can specify list to see alist
of available options.- Remember to comma-separate all options you wish to use.
separator
– By default, this is the|
(pipe) character. A space will be added before and after the separator, between each value.
- Example:
- https://decapi.me/br/player/76561197984642533 – Regular stats for the streamer Halifax
- https://decapi.me/br/player/76561197984642533/hardcore – Hardcore stats for the streamer Halifax
End notes:
Congratulations! You have reached the end of my post. Hopefully you’ll find some use out of these custom APIs I’ve developed.
If you have any questions or other concerns, please join the Discord server for these custom APIs or check out my contact page.
If you would like to help with any financial costs I have (hosting isn’t free!), you can send a one-time “tip” via this link or support me through Patreon.
Thanks for reading!