Skip to content

Cloud API

Ankit_Anmol edited this page Dec 14, 2021 · 25 revisions

PAGE WIP

Cloud:

You can request Cloud data from Scratch API only.

Scratch:

from ScraGet import ScraGet #import the package 
data = ScraGet.get_cloud_data() #create a class
data.updateScratch("431041540",limit="10",offset="0") #update data
print(data.cloud_data) #print required info

*Data:

data.cloud_data #yes. That's it. 

ScratchDB:

ScratchDB doesn't support/return Cloud data.

Cloud scanner:

This is a feature where the package continuously scans the cloud for changes. If any, it runs your code that you specified it. (It's in form of a python decorator). it might be a bit complex to use but is a great tool!

Sample code:

from ScraGet import ScraGet
Cloud = ScraGet.cloud()
@Cloud.scan(ID="612229554",delay=1,NewThread=False) #params explained below
def hello(change): #change parameter is automatically passed.
  print(change.var)

Parameters:

ID - (str) here, you need to enter the project ID of the project you want to scan. It's mandatory delay - (int) You need to set the delay between 2 scans. Note that it's better to set a high delay if this code is going to run for a long time. Better set it to 1 second or more. You will not lose data until 100 people change cloud variables.

Data:

Cloud.change_log #list of all changes. Max len = 100

#all the below is related to the 1st item of change_log
Cloud.recent #1st item of the change
Cloud.user #person who changed the cloud most recently
Cloud.type #the action of cloud change (set,delete, etc...)
Cloud.var #variable name
Cloud.value #the cloud value
Cloud.time #time when the change happened

Cloud.thread #given when NewThread = True. This contains the thread object
Cloud.stop #this is used to check whether the scanner is running or stopped

Clone this wiki locally