LoginLogin

SmileBASIC API

Root / Submissions / [.]

MasterR3C0RDCreated:

Announcement (10/06/2020):

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: News Introduction Usage Examples SiteJS plugin Credits WebSocket Query API

NEWS:

  • 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.
  • 01/31/2020: SBAPI 4 has launched! If you're using the SBAPI SiteJS, please update it to support SB4 keys.
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
  • code - only TXTs, highlights code using 12Me21's SBHighlight library (use ?wrap=1 to enable word-wrapping)
  • png - only GRPs, converts the GRP to a PNG
  • 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
  • Jaku - helped with SB4 support

Replying to:HTV04
I 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.
I'll have to take a look.

Replying to:HTV04
I 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.
Restarting 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

S Bapi Ess Boppy

Replying to:Midnight
S Bapi Ess Boppy
Here's what the S Bapi reminded me of: Suh-boppie

Replying to:Midnight
S Bapi Ess Boppy
I designed the logo (record when are you adding that to the credits lol)

Replying to:Midnight
S Bapi Ess Boppy
never that logo is awful and will probably be replaced one day also Ess Bappy

There'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.

Replying to:CyberYoshi64
There'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.
var 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,

Replying to:Midnight
S Bapi Ess Boppy
bold words from someone that didn't realize that's the joke

Replying to:Midnight
S Bapi Ess Boppy
S Bapi Will never be replaced. But I won't give 12 credit, I'm not into negotiating with terrorists

Replying to:CyberYoshi64
There'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.
Oh 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 joke

Replying to:CyberYoshi64
There'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.
I 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 few

Replying to:CyberYoshi64
There'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.
Alright, 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!

Replying to:CyberYoshi64
There'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.
Well, unless you're lazy enough to make a loader with document.appendChild like I did, lol

ใ‚จใ‚นใƒใƒ” Esbapi

Replying to:HTV04
ใ‚จใ‚นใƒใƒ” Esbapi
Es uh bah pee It's the official pronunciation for SBAPI You're welcome :)

Replying to:HTV04
ใ‚จใ‚นใƒใƒ” Esbapi
Wait, that's how it's pronounced? I always thought it was pronounced by letter, S-B-A-P-I. Good to know.

Replying to:HTV04
ใ‚จใ‚นใƒใƒ” Esbapi
I thought it would be es ba pee not es uh bah pee

Replying to:HTV04
ใ‚จใ‚นใƒใƒ” Esbapi
The uh is just a remanent if you're saying it in proper Japanese. The actual English pronunciation IS ess-bah-pee. Sorry for the confusion

Replying to:HTV04
ใ‚จใ‚นใƒใƒ” Esbapi
I think ใ‚จใ‚นใƒใƒ” is pronounced like Es-sue-bah-pee in Japanese