0.0.20240509 • Published 11 days ago

@maxim_mazurok/gapi.client.docs-v1 v0.0.20240509

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

TypeScript typings for Google Docs API v1

Reads and writes Google Docs documents. For detailed description please check documentation.

Installing

Install typings for Google Docs API:

npm install @types/gapi.client.docs-v1 --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://docs.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.docs
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('docs', 'v1', () => {
  // now we can use:
  // gapi.client.docs
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // See, edit, create, and delete all your Google Docs documents
    'https://www.googleapis.com/auth/documents',

    // See all your Google Docs documents
    'https://www.googleapis.com/auth/documents.readonly',

    // See, edit, create, and delete all of your Google Drive files
    'https://www.googleapis.com/auth/drive',

    // See, edit, create, and delete only the specific Google Drive files you use with this app
    'https://www.googleapis.com/auth/drive.file',

    // See and download all your Google Drive files
    'https://www.googleapis.com/auth/drive.readonly',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Google Docs API resources:

/*
Applies one or more updates to the document. Each request is validated before being applied. If any request is not valid, then the entire request will fail and nothing will be applied. Some requests have replies to give you some information about how they are applied. Other requests do not need to return information; these each return an empty reply. The order of replies matches that of the requests. For example, suppose you call batchUpdate with four updates, and only the third one returns information. The response would have two empty replies, the reply to the third request, and another empty reply, in that order. Because other users may be editing the document, the document might not exactly reflect your changes: your changes may be altered with respect to collaborator changes. If there are no collaborators, the document should reflect your changes. In any case, the updates in your request are guaranteed to be applied together atomically.
*/
await gapi.client.docs.documents.batchUpdate({documentId: 'documentId'});

/*
Creates a blank document using the title given in the request. Other fields in the request, including any provided content, are ignored. Returns the created document.
*/
await gapi.client.docs.documents.create({});

/*
Gets the latest version of the specified document.
*/
await gapi.client.docs.documents.get({documentId: 'documentId'});
0.0.20240509

11 days ago

0.0.20240430

13 days ago

0.0.20240423

15 days ago

0.0.20240416

28 days ago

0.0.20240415

1 month ago

0.0.20240411

1 month ago

0.0.20240326

2 months ago

0.0.20240319

2 months ago

0.0.20240312

2 months ago

0.0.20240305

2 months ago

0.0.20240304

3 months ago

0.0.20240229

3 months ago

0.0.20240220

3 months ago

0.0.20240213

3 months ago

0.0.20240209

3 months ago

0.0.20240130

4 months ago

0.0.20240129

4 months ago

0.0.20240116

4 months ago

0.0.20240102

4 months ago

0.0.20231218

5 months ago

0.0.20231214

5 months ago

0.0.20231205

5 months ago

0.0.20231128

6 months ago

0.0.20230811

9 months ago

0.0.20231108

6 months ago

0.0.20231031

7 months ago

0.0.20231115

6 months ago

0.0.20230807

10 months ago

0.0.20230929

8 months ago

0.0.20230920

8 months ago

0.0.20231017

7 months ago

0.0.20230922

8 months ago

0.0.20230725

10 months ago

0.0.20231024

7 months ago

0.0.20230718

10 months ago

0.0.20230711

10 months ago

0.0.20230831

9 months ago

0.0.20230710

10 months ago

0.0.20231010

7 months ago

0.0.20231011

7 months ago

0.0.20230829

9 months ago

0.0.20230905

9 months ago

0.0.20230707

11 months ago

0.0.20230821

9 months ago

0.0.20230822

9 months ago

0.0.20230705

11 months ago

0.0.20231120

6 months ago

0.0.20230620

11 months ago

0.0.20230613

11 months ago

0.0.20230516

12 months ago

0.0.20230509

1 year ago

0.0.20230502

1 year ago

0.0.20230425

1 year ago

0.0.20230606

11 months ago

0.0.20230526

12 months ago

0.0.20230531

12 months ago

0.0.20230412

1 year ago

0.0.20230314

1 year ago

0.0.20230418

1 year ago

0.0.20230227

1 year ago

0.0.20230228

1 year ago

0.0.20230324

1 year ago

0.0.20230407

1 year ago

0.0.20230307

1 year ago

0.0.20230330

1 year ago

0.0.20230124

1 year ago

0.0.20230221

1 year ago

0.0.20230207

1 year ago

0.0.20230131

1 year ago

0.0.20221116

1 year ago

0.0.20221213

1 year ago

0.0.20221111

2 years ago

0.0.20230119

1 year ago

0.0.20230103

1 year ago

0.0.20221207

1 year ago

0.0.20221107

2 years ago

0.0.20221201

1 year ago

0.0.20221219

1 year ago

0.0.20230112

1 year ago

0.0.20221031

2 years ago

0.0.20221020

2 years ago

0.0.20220830

2 years ago

0.0.20221004

2 years ago

0.0.20221013

2 years ago

0.0.20220927

2 years ago

0.0.20220829

2 years ago

0.0.20220920

2 years ago

0.0.20220913

2 years ago

0.0.20220825

2 years ago

0.0.20220915

2 years ago

0.0.20220816

2 years ago

0.0.20220815

2 years ago

0.0.20220802

2 years ago