Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Google Sites API

I know the current Google Sites API only supports Classic Sites.

Does this API exist now? and How to manage(create and etc) New Google Sites though API?

like image 401
Stepan Avatar asked Nov 17 '25 19:11

Stepan


2 Answers

Though Google Sites API is still not available, I discovered some good news (for my use case, at least). I can confirm there are some minimal Google Sites abilities available through the Google Drive API. Specifically, I was able to add a user to the my site as viewer to a published site, using the Drive API permissions. Here is the Python code.

# get boilerplate creds= code from here https://developers.google.com/drive/api/quickstart/python

drive = build('drive', 'v3', credentials=creds)

new_permission = {
    'type':'user', 
    'role':'reader',
    'view':'published', 
    'emailAddress':USER_EMAIL
    }

# you can get the SITE_FILEID from the site url
res = drive.permissions().create(fileId=SITE_FILEID, body=new_permission).execute()

Since the OP specifically asked about create, that works like so:

new_file = {
    'name':'test site2',
    'mimeType':'application/vnd.google-apps.site',
    }

res = drive.files().create(body=new_file).execute()

Hope this can help some folks.

like image 71
Erock618 Avatar answered Nov 19 '25 07:11

Erock618


No, an API doesn't exist.

There are several feature requests in the issuetracker.google.com site, so they are aware it is needed. You would think they have some of the framework developed, since there is currently some access to sites (and I don't mean for editing) through the existing drive API. It would be worth adding your comments to those requests in the issue tracker website.

  • https://issuetracker.google.com/issues/36761330

  • https://issuetracker.google.com/issues/7324991

  • https://issuetracker.google.com/issues/120462223

  • https://issuetracker.google.com/issues/205856782

like image 38
Chris Avatar answered Nov 19 '25 09:11

Chris