I just wanted to let anyone who wanted to use this API know that this is pretty safe to use. All downloaded files are cached, and as such it avoids sending more than the required amount of requests to SmileBASIC servers.
If you're doing a large amount of automated queries at one time, please check out the WebSocket Query API, as it provides less overhead on the server and adds additional features like queueing requests.
Also, there might be a new feature soon :)
Quick jump:
NewsIntroductionUsageExamplesSiteJS pluginCreditsWebSocket Query API
03/26/2020: Fixed a bug that was causing long load times. I don't know if anyone noticed this, but it was taking like 3 seconds per request. Not any more!
03/16/2020: Added English tag support! When using the `info` endpoint, add ?en=1 for the official English tags. They haven't been updated but should give a better idea of what each tag is. This also works with ?json=1 and the WebSocket Query API!
02/29/2020: Added tags to the info page! Only Japanese tags for now because official tag data for English is not very good right now, but will be updated in the future!
02/04/2020: WebSocket query API implemented! Read more details below.
Introduction
SmileBASIC API (SBAPI) is a service created by me (MasterR3C0RD) and triangle, with help from Yttria, 12Me21, and snail_, that allows you to get info for and download programs directly from SmileBASIC 3 servers. Not only is this useful for moderators to check if a key is still available, it also allows users to post GRPs to the forums as a PNG.
Usage:
Everything in SBAPI is simply a URL. The basic URL format for keys is http://sbapi.me/get/(key)[/(filename)]/(encoding), where anything in [] is optional and anything in () is required. key should be replaced with the public key, and filename allows you to choose a specific file if the key is a project. The encoding is required and can be one of the following:
info - all files, shows information about the file provided (use ?json=1 if you're writing a program to get information as JSON, add en=1 for English tags)
list - only projects, lists all files (use ?json=1 if you're writing a program to get information as JSON)
zip - only projects, download all files from the project as a ZIP file. If you want to convert files to their preferred format (ex, GRP -> PNG, TXT -> Text), add ?nice=1
raw - all files, downloads the raw file.
text - only TXTs, returns the text content of the file
json - only DATs, returns the DAT information as a JSON array of arrays.
csv - only 2D DATs, converts the data to a CSV (comma-separated values) file
icon - only META files, returns the icon as a PNG file.
downloads - all files, returns a PNG with the download count (download count is only updated every 24 hours). You can also control the PNG using query parameters: ?color=#BADA55&stroke=#A55A55&strokewidth=3&padding=3&bgcolor=rgba(0,0,0,0.5)
encodings - all files, returns JSON array with all possible encodings for the file given
Other encodings may be added in the future.
Examples:Disclaimer: Authors of projects or assets displayed on this page are not associated with and have not contributed to the SmileBASIC API project.
This can be used when asking people to debug code on the forums. Posting a public key and a link to the code could make debugging much easier.
Example:http://sbapi.me/get/CKANY53Y/TN_SHARP/code (Phil's N# compiler)
Output:
Wanting to show off your sprites is another possible use. Simply use the PNG endpoint.
Example:http://sbapi.me/get/4DH5P4K3/BBG_TIKI/png (sprites from cujo1992's Tiki Descent)
Output:
You can also back up your project as a ZIP file if you need to be sure you'll always have it.
Example:http://sbapi.me/get/P3T43E3V/zip (kantackistan's Virtual Buffalo)
Output:
Don't forget a download counter to gauge how popular your programs are! Note that the download count is not real time, and only updates every 24 hours.
Example:http://sbapi.me/get/QK4N3PZF/downloads (calc84maniac's Spooky Maze Raycaster demo)
Output:Optional SiteJS:
If you think it's too much of a hassle to have to go through the API to check out information about programs, you have a similar mindset to I. That's why me and 12Me21 wrote a SiteJS, available at http://sbapi.me/sbapi-sbs.js that adds an extra section to pages that looks something like this:
Simply copy and paste the contents into your SiteJS and load up a program page. After a few seconds, the information will load and be shown on the page.
WebSocket Query API
If you're doing multiple requests, the best way to accomplish this is using the WebSocket Query API. Simply connect to ws[s]://sbapi.me/get and send a request, and you'll get something back.
You can either do:
Request: (key[/version[/filename]]) info [prop1,prop2.subprop2] - Gets information about a program.
Response: (key[/version[/filename]]) (value) - Value will either be the entire JSON-encoded info object (if no properties are provided), a single JSON-encoded value (if one property is provided), or a JSON-encoded object of all properties requested and their values (if multiple properties are provided). This info object uses a different format than the `info` encoding, test it first by not providing any property arguments.
OR
Request: (key[/version[/filename]]) download [encoding[?options]] - Gets the file as a specified encoding (or the raw file if none is specified). Any encodings that allow options work exactly the same as if options were provided
Response: (key[/version[/filename]]) (filename) (datalength) (data) - Datalength will be the ASCII representation of the size of the data returned, and data will be the response of the encoding.
If a request fails, you will get a response similar to such: (key[/version[/filename]]) FAIL
If you get this and you're sure you're not doing anything wrong, send me a DM and I'll take a look.
NOTE: Send multiple requests separated by \n, eg, `KEY1 info\nKEY2 info` or otherwise you will end up never getting a response in the end. Some requests async are fine, but not all.
Credits
triangle - file format guru, wrote the file parser used for SB files and other parts of code, and most of reverse engineering of SmileBASIC's servers, donated 3DS information for the server
MasterR3C0RD - hosting, wrote the server communication libraries and helped with reverse engineering of SmileBASIC's servers
12Me21 - wrote sbhighlight and rewrote the SiteJS plugin to work with more browsers
snail_ - working on proper documentation for API
Yttria - word of reason, helped with multiple things internally
227 Comment(s)AliceCEMinecraft Is Awesome!I love Minecraft!Express YourselfVideo GamesI like to play video games!HobbiesGardeningI like to garden!HobbiesDid this die? it's giving me a not found erroranswerGreat PageHiddenAchievementsThird YearMy account is over 3 years oldWebsiteDeep SleepHiddenWebsitehttps://www.reddit.com/r/SmileBASIC/comments/qwdipt/sbapi_developer_here_and_i_have_some_updates/AliceCEMinecraft Is Awesome!I love Minecraft!Express YourselfVideo GamesI like to play video games!HobbiesGardeningI like to garden!HobbiesMuch obliged. I guess all i can do is play the waiting game, but i won't grovel about it beyond that.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfJust in case people start freaking out, I'm migrating SBAPI to a dedicated server for improved performance. It'll be back before you know it.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfIt's back up!randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteSo SBAPI seems kind of unsure whether or not Wonderflonium is available. When I checked just barely, it thought that Wonderflonium wasn't available, even though when I checked it was. And the last time I reported it thinking that Wonderflonium was unavailable, I went back and checked and it changed it's mind.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfNah, it's a bug with the way I'm generating 3DS tokens. Give me a few minutes, getting the fly swatter outMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express Yourself:crab: BUG IS DEAD :crab:randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteOk coolNa_trium
The uploaded date is broken...randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteSBAPI thinks that Wonderflonium isn’t available even though it is. It’s causing the page on the new website to break.
EDIT: It works now. I wonder what was going on.RGamesOfficalTouhou Project Is Awesome!I love Touhou Project!Express YourselfMinecraft Is Awesome!I love Minecraft!Express YourselfVideo GamesI like to play video games!HobbiesI'm getting an error (An internal error occurred while trying to complete this request.) when using /get/.../downloads.cypherpunkshow do i download programs to my 3ds with smilebasic apiphotonegativemickeyMinecraft Is Awesome!I love Minecraft!Express YourselfIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!Hobbieswhat.HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthUhh
SBAPI just caches projects from SmileBoom's servers. It doesn't host anything else.niconiiPower UserVideo GamesI like to play video games!HobbiesExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthDrawingI like to draw!HobbiesYou don't need SBAPI if you have a 3DS, you can just download them with SmileBASIC. The point of SBAPI is to access projects without a 3DS.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfAs nico said, the point of SBAPI is that you don't need your 3DS to access things uploaded to the SmileBASIC Servers. However, it does allow access to download files, so you could download the raw files from SBAPI and copy them over with SBFM. Na_triumThe sender of this mail is Tawake Shigatsu...
Tawake(戯け) means fool, and Shigatsu(4月) means April...
And the date is April 1st...
Is this the real request from Nintendo?photonegativemickeyMinecraft Is Awesome!I love Minecraft!Express YourselfIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesBig Brain! I knew something was up when it was taken down. ON APRIL FOOLS DAY.Na_triumI also searched the zip code 491-1101 and the phone number (+81)051-270-1860, and I found they don't exist.photonegativemickeyMinecraft Is Awesome!I love Minecraft!Express YourselfIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!Hobbiesconfirmed april fools day prank?HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthLMAO I can't believe I fell for this
I should've known something was up when Record left most of the documentation on the page.thou_fatGAMER12Avatar TabooI didn't change my avatar for 180 daysWebsiteVideo GamesI like to play video games!HobbiesNight PersonI like the quiet night and sleep late.Express YourselfDamn I actually fell for this
Good April Foolsthe_squat1115Second YearMy account is over 2 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteForum ContributorHiddenAchievementsWhat happened? Any April Fools joke?Na_triumI was very surprised because SBAPI was taken down just when I was using it.
the fake request:HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThis fucking sucks. SBAPI had a lot of potential, but of course copyright laws have to shit on everything. I feel really sorry for you Record, and everyone else who's worked really hard on this.photonegativemickeyMinecraft Is Awesome!I love Minecraft!Express YourselfIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesU may have gotten fooled.HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthI didChatterThis news is so shitty. I feel so bad for you, trinitro, and everyone else who spent countless hours reverse-engineering the SmileBASIC file format and servers, just for this to happen.
Will the already-present programs still be available?MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfThere was a long email chain and multiple phone calls about that very subject. I was told that since I had gotten the files by unauthorized use of their private APIs, that I would have to delete everything. This was honestly the worst part of this entire experience. The whole point of SBAPI was to provide a useful service while caching every program on SmileBASIC in case the official servers were taken down at some point. That goal has been completely ruined.ChatterYou got me good. Good job.Na_triumhttp://sbapi.me/get/444EDZEQD/TORIGINAL.OHD/downloads
It says "undefined downloads"MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express Yourselfdownloads should not be used on a file, only the actual key. That doesn't matter now though.TarudahatQSP Contest 2 Contest ParticipantI participated in the second SmileBASIC Source QSP Contest!OSP Contest 3 Contest ParticipantI participated in the third SmileBASIC Source OSP Contest!Avatar TabooI didn't change my avatar for 180 daysWebsiteI found a bug in Sbapi. For some SB3 programs (sb4 prog. don't seem to have this.) the download count is 0 eventough it has been downloaded multiple times example https://sbapi.me/get/QRNPX3V3/info, https://sbapi.me/get/PE33D2AE/info, https://sbapi.me/get/WR3XX3RJ/info, https://sbapi.me/get/5374EW4E/info...
Spooky maze and maybe some others (I didn't check that many proj except these and some others) do have a correct download amount.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfAHHH I know the issue. I forgot to update download count :(MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfFixed! Please remember to keep sending me these bugs :)snail_Power UserQSP Contest 1 Contest ParticipantI participated in the first SmileBASIC Source QSP Contest!HelperReceived for being very helpful around SmileBASIC SourceAchievementsAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsI've gone key crazy! SBAPI has now cached over 2000 keys!the_squat1115Second YearMy account is over 2 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteForum ContributorHiddenAchievementsWowNa_triumhttp://sbapi.me/get/4483DEF/T--NEW_OMOCHI/info
It says "An internal error occurred while trying to complete this request." and I can't get information.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfFixed. Thanks for reporting!HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthSBapi seems to have been down since this morning.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfFixed, just had to restart the serverthe_squat1115Second YearMy account is over 2 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteForum ContributorHiddenAchievementsSBAPI is broken again...
HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthIt's working fine for me. Are you using the latest SiteJS?YolkaiHead Admin(it was resolved quietly between the time of these two posts)HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming Strengthエスバピ
EsbapiMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfEs uh bah pee
It's the official pronunciation for SBAPI
You're welcome :)HTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthWait, that's how it's pronounced? I always thought it was pronounced by letter, S-B-A-P-I. Good to know.randoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteI thought it would be es ba pee not es uh bah peeMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfThe uh is just a remanent if you're saying it in proper Japanese. The actual English pronunciation IS ess-bah-pee. Sorry for the confusionNa_triumI think エスバピ is pronounced like Es-sue-bah-pee in JapaneseMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfYou're right... it's been a while since I reviewed my katakana pronunciations... That's what I meant to say in the very beginning, thanks for the call out lolrandoIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthThird YearMy account is over 3 years oldWebsiteAvatar TabooI didn't change my avatar for 180 daysWebsiteCoolCyberYoshi64Expert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthGreat PageHiddenAchievementsNight PersonI like the quiet night and sleep late.Express YourselfThere's a weird bug relating the SiteJS:
I was opening atmOS's SB page and SBAPI was trying to get info for key 4J5XA3 but the actual key is 433J5XA3.
SBAPI using the actual site .../get/433J5XA3/info works fine.
Is it cuz the 4 accidentally signifies it being a SB4 key and therefore the 3s being omitted as it thinks that's the start of the key? (my speculation). I might and perhaps will be wrong here though.12Me21Syntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express Yourselfvar keyregex = /\b(4?)3*([A-HJ-NP-TV-Z1-9]{1,8})\b/g;
this is supposed to strip leading 3s but it thought the key was for sb4 since it starts with 4, CyberYoshi64Expert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthGreat PageHiddenAchievementsNight PersonI like the quiet night and sleep late.Express YourselfOh cool, my speculation is right for the first time in my life. lol
This was also my first bugreport to that weird scripting language, Python JavaScript.
Okay, that mismatch was a bad jokeMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfI kinda gave up trying to trim SB4 keys server side, it's impossible enough that I have decided not to bother with it. I'll fix the bug though, give me a fewMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfAlright, here's the fix. I ended up a tad busy so I couldn't get the change done as soon as I thought I would be able to.
If you don't have the SiteJS installed yet, the latest version installed fixes this problem.
If you already have it installed, there's no need to change everything.
Replace var keyregex = /\b(4?)3*([A-HJ-NP-TV-Z1-9]{1,8})\b/g;
with var keyregex = /\b(4|3*)([A-HJ-NP-TV-Z1-9]{1,8})\b/g;
Save and reload and you're all set!CyberYoshi64Expert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthGreat PageHiddenAchievementsNight PersonI like the quiet night and sleep late.Express YourselfWell, unless you're lazy enough to make a loader with document.appendChild like I did, lolMidnightDeep SleepHiddenWebsiteS Bapi
Ess BoppyKunaitoSoftForum ContributorHiddenAchievementsAvatar TabooI didn't change my avatar for 180 daysWebsiteFirst YearMy account is over 1 year oldWebsiteHere's what the S Bapi reminded me of:
Suh-boppie12Me21Syntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express YourselfI designed the logo
(record when are you adding that to the credits lol)IAmRalseiForum LeaderHiddenAchievementsSecond YearMy account is over 2 years oldWebsiteExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming Strengthnever that logo is awful and will probably be replaced one day
also Ess BappyYolkaiHead Adminbold words from someone that didn't realize that's the jokeMasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfS
Bapi
Will never be replaced.
But I won't give 12 credit, I'm not into negotiating with terroristsHTV04Forum LeaderHiddenAchievementsThird YearMy account is over 3 years oldWebsiteIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthI keep getting this error: "An internal error occurred while trying to complete this request."
SBAPI throws this error on several SB4 projects. I've tested it on my projects and on popular ones like Solid Gunner Vertika. Some work though, like Versus Buffalo.MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfI'll have to take a look.
MasterR3C0RDPower UserAmazing ContributorSomeone thinks I'm an awesome person who has done so much for the community!AchievementsThird YearMy account is over 3 years oldWebsiteosu! Is Awesome!I love osu!Express YourselfRestarting SBAPI fixed the problem, it seems to be an issue with updating tokens. I've added more debugging so I'll see when the problem pops up again but that shouldn't be for another few hours. The reason some games worked and others didn't was because of caching.
EDIT: I fixed the issue. It was as simple as changing an < to an > lol
1
2
3
4
PythonJavaScript. Okay, that mismatch was a bad jokevar keyregex = /\b(4?)3*([A-HJ-NP-TV-Z1-9]{1,8})\b/g;
withvar keyregex = /\b(4|3*)([A-HJ-NP-TV-Z1-9]{1,8})\b/g;
Save and reload and you're all set!