Using HttpService with Google Sheets

[quote] [quote=“MrNicNac” post=138423]This is great and all, but what is the down-to-efficient point? SQL databases have way more durability, can be queried faster and in multiple ways, and can be exported into spreadsheets for viewability purposes.

May be cool, but I feel SQL database management is much more… modern… [/quote]

The point is that it serves it’s purpose of storing data, doesn’t need to be exported because it already is there for you to view and can retrieve data from it. I don’t know what you mean by durability, but this has also zero downtime and no need to worry for SQL injection. Also it requires little to no knowledge of scripting and can be done almost instantaneous.[/quote]

Fair enough, but if you are even worrying about SQL injection… then you might be 8 years behind modern web standards.[/quote]

While I agree with you that an SQL database is a much smoother and more flexible option…

This allows you to write JS (without node.js) instead of PHP/Java/C-Derivative. Which is great for this simple purpose of just simply moving data back and forth.
The major factor of why I’m considering this alternative is just purely the fact that it’s free hosting. I don’t have a purpose for a website outside of ROBLOX, and I don’t see a point in paying ~5$ a month on top of BC costs.

Question, how would one go about recording the chat history with this?

[strike]Not sure where you got hsKey from what certain group of characters? I felt this part wasn’t explained very well :emo-angst:[/strike]

Googled and found it if anyone found that a puzzle
https://productforums.google.com/forum/#!topic/docs/Vx0rggpH9nQ

Anyone interested, here is a chat log script

[spoiler][code]
local hs = game:GetService(“HttpService”)

local hsEntry1 = “”
local hsEntry2 = “”
local hsKey = “”
local hsForm = “”
local hsHost = “https://docs.google.com/

local function logSheet(var1, var2)
local hsLink = hsHost…“forms/d/”…hsForm…"/formResponse?entry."
…hsEntry1…"="…var1…"&submit=Submit&formkey="
…hsKey…"&entry."…hsEntry2…"="…var2…"&ifq"
– Upload onto Google Sheets!
– print(hsLink)
hs:PostAsync(hsLink, “”, 2)
end

function onChatted(msg, recipient, speaker)

logSheet(speaker.Name, msg)

end

function onPlayerEntered(newPlayer)
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
end

game.Players.ChildAdded:connect(onPlayerEntered)

[/code][/spoiler]

How would one go about updating a certain cell and not adding a new line?

Assuming we are maintaining a table, and the table consists of a name followed by a number, and is always ordered by name. When put into google sheets all of the current cells would just be replaced with the new values.

Hope you like my visualization

Has anyone figured out if there is a way to read from spreadsheets using HttpService:GetAsync? I looked around some google APIs but I couldn’t get anything going.

Yeah, I’ll be providing some details on that (unless someone wants to go ahead)

[quote] How would one go about updating a certain cell and not adding a new line?

Assuming we are maintaining a table, and the table consists of a name followed by a number, and is always ordered by name. When put into google sheets all of the current cells would just be replaced with the new values.

Hope you like my visualization
[/quote]

There is indeed a way to update cells, however I’m not exactly sure if it works in your case.

Does Google Sheets have automatic data organization for things like average, max, min, current position in rankings (a function of row after ordering, I suppose), highest/lowest n number of values, and the keys for these values. (e.g. who are the top 10 players, where is suchandsuch in the leaderboard, what is the average score, etc.)

Yeah, you would just need to create another spreadsheet and refer it off the spreadsheet that receives the values.

More details on the function stuff: https://support.google.com/docs/table/25273?hl=en

I don’t know much about the internet or HTTP.

How would you format the hsLink string for three entries instead of two? Or four? I’m not sure what the pattern is. I’m trying to submit 13 entries.

Using URL parameters? If I understand correctly, you would use a “?” for the first param and a “&” for everything after that.

But why is there a
.."&submit=Submit&formkey=" ..hsKey..
between the two entries?

Can you give an example of what, say, four entries would look like?

There is no particular order to how params can be specified. You can put more entries after the end of the string, in the middle, or in the beginning- it doesn’t matter. All the params get sent to the server at the same time, so as long as its present the server won’t care what order it’s in.

Now I’m not entirely sure about the format of Google Sheets, but you should be able to copy and paste the one from either entries and have no problem.

Why don’t you do it directly? There’s a tutorial I did a while ago that’s a bit more complex but in the long run it’s perhaps a better option.

Ah, I figured it out, thanks!

Because I’m very new to anything with HTTP and I just want to fill in some barebones example code and make a thing that works. Functionality!

2 Likes

Been messing around with this code and the Google API.

I can’t seem to find a working way to perform a GetAsync request for the entries in the excel sheet. :confused:

Has anyone managed?

What’s your code? I’d recommend snipping sensitive data

It’s all good.

This beautiful person made a helpful tutorial :slight_smile:

Sadly i think this method is outdated or else i did something wrong. If any of you know a similar method please let me know

This still works. I managed to do it a few weeks ago. Chances are the URL is slightly incorrectly formatted. I had to play around for a few minutes for it to work.

1 Like

Thanks alot man you have saved a life

Thx Again