If Hopscotch had HTTP Requests (Concept)

requests
updates
update_ideas
hopscotchers

#1

Hello! I have gotten a cool idea recently which I wanted to share with you, the Hopscotch community. Me, myself, doesn´t know too much about HTTP requests, but I have used them before and I will do my best to tell you what it is.

What is HTTP Requests?

An HTTP request is basically data you send to a server or ask for from a server. There are many services based on this. Sending a request from a device to a server will make it interact with the server you do the HTTP request to. There are different types of requests, but the two main ones I think that Hopscotch should have (for simplicity) is GET and POST which basically means (Get data from a server or Post data from a server).

Every request sends some values to a server. Let´s say that you are fetching the weather from the Weather Underground API. By the way, an API is a service publicly available, often used to get or send data to interact with a service. An example HTTP request could be like this (don´t worry, these are all example codes for
the Weather Underground API, no personal API keys are used): http://api.wunderground.com/api/5756683d9b100348/conditions/q/CA/San_Francisco.json
As you see, we get lots of useful information, and if Hopscotch only could offer to extract a value from this file (like the value “weather”), we could make so much cool things with this!

How would this work in Hopscotch?

I know, I wrote lots of things above, but it´s worth to read in order to understand everything.

First, I think that we should have a request loop where you enter all the data to send to the server, like this:

In the blank space in the loop, it would be cool if you could choose between “GET” and “POST” as the request type.

In the loop, I think that there should be different blocks depending on the request type that you have chosen.

For Get and Post requests, I think that you should have the ability to send variables to a server, probably with a block saying “Send variable __________ = ___________” because you might need it for GET requests as well.

For Post requests, I think that we should have the ability to send more values to the server.

Somewhere, the HTTP request URL should also be mentioned. It would probably have to support variables in the URL as well.

Moderation and restrictions:

Many services do require an API key, an account and some even require payments. To make it fair for everyone, I think that those shouldn´t be allowed unless THT makes an API key for the whole community to use. Because someone can easily access your API account using the API key which would be publicly displayed in the code, unless The Hopscotch Team gave you the option to hide the API key which probably would make those allowed.

As HTTP requests can be made using a variety of services, all projects should be moderated before they get published in my opinion so that everyone is safe using the project. You should probably be given the ability to send a note to The Hopscotch Team so they know what API you´re using and in that way speed up the moderation.

Moderating HTTP Requests is a task that probably will be a little more complicated than images.

Thank you for reading this topic!

Remember, this is just a concept and I know what a huge task this is to implement. HTTP Requests is something that I think is cool though. I don´t know everything about HTTP requests and I might have gotten some things wrong. In that case, just tell me. Also, feel free to reply and ask me any questions or to say something else :slight_smile:

Tags: @OMTL


If you controlled Hopscotch, what would you add to the app?
#2

First!


#3

This is a great idea!(sorry about the first post lol)


#4

This would be awesome.


#5

Sounds good… could you work this into a profile system? Atm you can’t really add progression system to your games since it resets right. So if you could make a profile and send the info to the server with a password and an username and return it this way? You have to do your own API ofc if that is how it works😂


#6

Yes, it would be possible. If you just could set up a server that stores a unique ID for each user and maybe a password.

Although, to make it fair for everyone, you might want to use a free server. If this will be implemented, I would use Heroku for that (Google it).


#7

That would be really cool! I love how well you explained it for not smart people like me to easily comprehend!

Nice topic! I actually really like the idea of HTTP Requests


#8

That you so much! I also think that this would be super cool, although is would probably be hard to implement in Hopscotch.


#9

THis is a cool concept!

Is it kind of like the import function in python?


#10

No, but I have also thought of suggesting that as a new Hopscotch feature.
Import is for importing packages or modules in Python (external packages are also available).
Requests are data sent to or received from a web server. If we had this in Hopscotch, you could get live weather, live time, live currency exchange rates and much more embedded into your project.


#11

Ah cool!

I guess it just reminded me of importing libraries (i think you call them that?)


#12

Yes, they are called libaries/packages or modules and there is actually a package in Python for HTTP requests. It’s called “requests”.


#13

Ohh cool. I didn’t know requests came in a python library.

To be fair i am less than an amateur at python/programming


#14

There are lots of Python libraries out there :slight_smile:
You should check them out. Start with “turtle”, then “random” and then install an external module.


#15

Sure, maybe in a bit :wink:


#16

THT haven’t made a Load game/Save game feature for the app, so it’s very highly unlikely HHTP requests will ever be added to the app.
A cloud variable would be similar to HTTP request, but only 1 value would be needed to send/receive from a server.

Still your WISH is a good idea.


#17

YYYYYYAAAAAAAAAAAAAAAAAASSSSSSSSSSSSSS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I’ve been wanting this feature recently and theoretically it could allow for some amazing online gameplay!
Imagine this:
A slither.io with other online snakes!
A first person shooter with online players!
A tapper game that saved your score!


#18

That’s what I mean. It’s a wish, it’s really hard to implement.


#19

Uhhh…hahaha I’m so du.mb I can’t understand this very well, but from what I have understood, this seems like a cool idea!


#20

Yeah, it is really cool. If you’d like, I can explain this further.

And as want to do it anyways, I will explain it below. If you want to read it, the do it.

Okay, so what HTTP (or HTTPS) requests are is pretty simple. There are lots of APIs around the world that you can use in your projects to make them better. An API is basically a service, often based on HTTP requests, that you can send data to. You can also receive data from the server.

Sending data is called a POST requests and recieving data is called a GET requests. Those are the main two request types.

To make a request, the device (like your iPad or your computer) sends data to the server or servers providing the API. A GET requests would typically return data (in different formats (or layouts basically)) and a POST request would make the server you send data to send it even further.

This is basically what HTTP (and HTTPS) requests are. The great thing with them is that you can make lots of cool things like getting the current weather and even the data for a Hopscotch Forum user without being an admin (which means that Discource has an API that allows the usage of some commands without authentication, which some APIs require.)

I hope that this explains it more and that it is helpful! Feel free to ask any questions if you are wondering something else! :slight_smile: