Last active
December 23, 2015 23:19
-
-
Save punkdata/6708739 to your computer and use it in GitHub Desktop.
Here is some python sample code that uses point.io api calls to list of the files & folders in the root of all storage sites configured for an account. Get your account here http://point.io/hack and make sure you pip install requests - Check it:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
#Defines the api's core URL | |
URL ='https://api.point.io/api/v2' | |
#Validate User's Creds and Return a SessionKey | |
header = {"Authorization": ""} | |
#Change the email, password and apikey values to your credentials | |
authInfo = {"email":<your email>, "password":<your password>, "apikey":<your api key>} | |
#Submit Authorization request | |
skey = requests.post(URL+'/auth.json', data=authInfo) | |
#Set the Session Key variable | |
SessionKey = skey.json() | |
sskey =SessionKey["RESULT"].get("SESSIONKEY") | |
authHeader = {"Authorization":sskey} | |
#List the Access Rules | |
acRule = requests.get(URL + '/accessrules/list.json', headers=authHeader) | |
AccessRule = acRule.json() | |
total = 0 | |
#for each Access Rule get the ShareID which equals a FolderID key when listing | |
for ar in AccessRule["RESULT"].get("DATA"): | |
folderID = {"folderid": ar[1]} | |
resp = requests.get(URL+'/folders/list.json', headers=authHeader, data=folderID) | |
#Now list all the File names | |
file = resp.json() | |
#Print all of the file & folder names in the Root directory | |
for f in file["RESULT"].get("DATA"): | |
print "Storage type: "+ ar[4] +" --- Item Name: " + f[1] + " ---- Type: " + f[2] | |
total += 1 | |
print "The total # of items is: %s" % str(total) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment