Log In  

I would love to have the ability to make API requests from PICO-8, and I think it would open up loads of opportunities for projects such as home automation controllers, carts that retrieve information from publicly available APIs such as weather information, etc.

The only example of networking functionality that I've seen in PICO-8 so far is using WebSockets in browser-based carts, and while HTTP requests would also technically be possible in web-based carts I would love to have this be a feature on local carts.

I can understand that some users may not want the carts they download to be able to make HTTP requests, so perhaps this could be an optional feature that you enable in the config or via a command-line argument.

Anyone else have thoughts on this?

P#61716 2019-02-10 14:51

One year later, we are still waiting for this…
Google brings me here, and I was pretty sure it was implemented since then but it looks I'm wrong :(

P#72985 2020-02-11 13:17 ( Edited 2021-12-27 07:39)

gpio in html is the only solution so far.
it leverages browser ‘sandbox’ security, while admittedly reducing the ease of programming.
I certainly wouldn’t like any pico8 game to be able to fiddle with network or my hard drive (remember ActiveX, Flash...?).

P#72986 2020-02-11 13:48 ( Edited 2020-02-11 13:48)

API support would be a security hole, as @freds72 said.

P#72987 2020-02-11 16:35

I think the original request was not about system calls or anything to access the host computer, but rather HTTP requests, to retrieve data or perform actions. I don’t see the security hole then, but I don’t think the idea fits with the aesthetic of Pico-8.

P#72988 2020-02-11 17:40

Ok - https access might be ok (but then how do you distribute credentials?)

P#72999 2020-02-11 21:25 ( Edited 2020-02-11 21:25)

Depends on the use case!

If it's a local cart mean to connect to a home server to display things or control for example a media player, then embed credentials and no worry.

If we take the example of using newgrounds API to integrate medals and leaderboard: the game API key will have to be in the game code, and anyone could take it and send fake scores, no different than current HTML games have to do.

For something more delicate, I suppose you'd have to ask the player to enter an API key, using real or emulated on-screen keyboard!

P#73000 2020-02-11 22:38

Very cool to see that I'm not the only one interested in this, even if it has been a year! Thanks for reviving the thread @crazyrems.

@merwok I think you're pretty much spot on regarding API credentials. For a private project that you never intend to publish you could hard-code creds. If it is something you plan on publishing, I think the two simplest options would be EITHER to require to user to load the cart and edit their API key into the code, or to build a simple on-screen method for the user to enter their own API key, as to support consoles such as the Gameshell that just run Splore and don't present an easy way to edit carts.

Of course I understand that this feature may not be for everyone as I mentioned in the original post - for those who do not like this feature, it could be disabled in config (this may even be the default state), or they may just choose not to use it themselves.

It's been a while since I played around with PICO-8, mostly due to time limitations, but I for one know I would have a lot of fun messing around with HTTP requests were it implemented down the line.

P#73001 2020-02-11 23:32

Just got the Pico-8 yesterday and I'm also looking forward to doing interesting things with HTTP!

What would it take to make this happen?

P#84197 2020-11-13 18:08

ngl I would like a way to create games while in a browser sometime. Though, it's been years since that's been requested.

P#84285 2020-11-15 19:53

coetry: in HTML exports of games, there is a bit of memory shared between the pico8 runtime and the browser javascript environment, so you can send data back n forth and then do what you want with javascript code. See https://www.lexaloffle.com/bbs/?tid=40334 for more info!

For something equivalent with the regular pico8 program, you could use stdin/stdout for communication, or the '-i file' / '-o file' parameters added in a recent version. See the section "Serial I/O" in https://www.lexaloffle.com/bbs/?tid=38665

scorchware: an HTML version of pico8 itself is a whole another thing than the topic of this thread :)

P#84303 2020-11-16 02:10

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2022-12-04 22:46:24 | 0.034s | Q:24