API Fetch a Splatoon schedule?

I’ve seen some streamers use various !schedule commands for Splatoon schedules and I was wondering if there’s a way to set it up. I’ve been trying to figure it out but I don’t really know how to do it with Nightbot.

Ideally want to fetch the current info from splatoon3.ink with 5-6 commands for the various modes (a 5th pvp mode will be released down the line) and an addition “next” option to fetch the next rotation. (Rotation changes every 2 hours for PVP and for the PVE mode it’s every 40 hours)

!turf to fetch the current regular, !turf next to fetch the next regular, etc. (“Turf war” is the name for the “Regular” battle mode displayed on the website)

I know nintendo is a bit… yeah… with API but i checked this website and they listed endpoints here but idk how to incorporate those into a command? I know i’ll be needing to fetch the current/next map data, time left/until rotation change and for pve the current & next map and weapons.

Example responses: “Current Turf War: [Map 1] and [Map 2]. [Time left].” and “Current Salmon Run: [Map]. [Weapons]. [Time left].”

Kinda just need like an example of how to do it and then i might be able to work the rest out myself (hopefully)… anyone got any ideas?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hey @konfusion!

Sorry about the delay, I had to take a much needed break.

The data comes in JSON, so it’s pretty easy to extract the data you want, the hardest part is to figure out which names are used to get the data, for example maps appear to be called stages, Turf war appears to be called regular, and Salmon run appears to be called coopGrouping, then you can see that rotations are stored in an array (table) called nodes, from there it’s relatively easy to do what you want.

However, since there’s a lot of data to treat, we’ll need to use a Pastebin to store the code that doesn’t rely on Nightbot’s variables… Create an account if you don’t have one already, then create a paste, copy/paste the code I wrote for it below, save the paste (be careful not to save it as private), and finally replace the paste ID (XXXXXXXX) in the command’s code.

const now = Date.now();
const turf = data.regularSchedules.nodes[nodeId];
const turfMaps = turf.regularMatchSetting.vsStages.map((stage) => stage.name);
const turfStartTime = new Date(turf.startTime).valueOf();
const turfEndTime = new Date(turf.endTime).valueOf();
const turfTimeLeft = turfEndTime - now;
const turfTimeUntil = turfStartTime - now;
const turfTimeRemaining = [turfTimeLeft, turfTimeUntil][nodeId];
const turfHoursRemaining = Math.floor(turfTimeRemaining/3600000)%24;
const turfMinutesRemaining = Math.floor(turfTimeRemaining/60000)%60;
const salmon = data.coopGroupingSchedule.regularSchedules.nodes[nodeId];
const salmonMap = salmon.setting.coopStage.name;
const salmonWeapons = salmon.setting.weapons.map((weapon) => weapon.name);
const salmonStartTime = new Date(salmon.startTime).valueOf();
const salmonEndTime = new Date(salmon.endTime).valueOf();
const salmonTimeLeft = salmonEndTime - now;
const salmonTimeUntil = salmonStartTime - now;
const salmonTimeRemaining = [salmonTimeLeft, salmonTimeUntil][nodeId];
const salmonDaysRemaining = Math.floor(salmonTimeRemaining/86400000)%365;
const salmonHoursRemaining = Math.floor(salmonTimeRemaining/3600000)%24;
const salmonMinutesRemaining = Math.floor(salmonTimeRemaining/60000)%60;
`${nodeId ? 'Next' : 'Current'} Turf War: ${turfMaps.join(' and ')}; ${nodeId ? 'starts in' : 'ends in'} ${turfHoursRemaining} hours ${turfMinutesRemaining} minutes. | ${nodeId ? 'Next' : 'Current'} Salmon Run: ${salmonMap}; weapons: ${salmonWeapons.join(', ')}; ${nodeId ? 'starts in' : 'ends in'} ${salmonDaysRemaining} days ${salmonHoursRemaining} hours ${salmonMinutesRemaining} minutes. | Data from https://splatoon3.ink`
!addcom !schedule $(eval const data = $(urlfetch json https://splatoon3.ink/data/schedules.json).data; const nodeId = '$(query)' === 'next' ? 1 : 0; $(urlfetch json https://pastebin.com/raw/XXXXXXXX))

Response examples:
User: !schedule
Nightbot: Current Turf War: Mincemeat Metalworks and Inkblot Art Academy; ends in 0 hours 48 minutes. | Current Salmon Run: Gone Fission Hydroplant; weapons: Splattershot, Glooga Dualies, Classic Squiffer, Random; ends in 0 days 16 hours 48 minutes.
User: !schedule next
Nightbot: Next Turf War: Hammerhead Bridge and Mahi-Mahi Resort; starts in 0 hours 48 minutes. | Next Salmon Run: Marooner’s Bay; weapons: Splash-o-matic, Luna Blaster, Goo Tuber, Tri-Stringer; starts in 0 days 16 hours 48 minutes.

1 Like

This worked!!! Thank you so much :smiley:

1 Like