0.0.20240430 • Published 14 days ago

@maxim_mazurok/gapi.client.forms-v1 v0.0.20240430

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

TypeScript typings for Google Forms API v1

Reads and writes Google Forms and responses. For detailed description please check documentation.

Installing

Install typings for Google Forms API:

npm install @types/gapi.client.forms-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://forms.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.forms
  }
);
// 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('forms', 'v1', () => {
  // now we can use:
  // gapi.client.forms
});

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 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',

    // See, edit, create, and delete all your Google Forms forms
    'https://www.googleapis.com/auth/forms.body',

    // See all your Google Forms forms
    'https://www.googleapis.com/auth/forms.body.readonly',

    // See all responses to your Google Forms forms
    'https://www.googleapis.com/auth/forms.responses.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 Forms API resources:

/*
Change the form with a batch of updates.
*/
await gapi.client.forms.forms.batchUpdate({formId: 'formId'});

/*
Create a new form using the title given in the provided form message in the request. *Important:* Only the form.info.title and form.info.document_title fields are copied to the new form. All other fields including the form description, items and settings are disallowed. To create a new form and add items, you must first call forms.create to create an empty form with a title and (optional) document title, and then call forms.update to add the items.
*/
await gapi.client.forms.forms.create({});

/*
Get a form.
*/
await gapi.client.forms.forms.get({formId: 'formId'});
0.0.20240430

14 days ago

0.0.20240425

26 days ago

0.0.20240416

28 days ago

0.0.20240402

1 month ago

0.0.20240326

2 months ago

0.0.20240321

2 months ago

0.0.20240305

2 months ago

0.0.20240227

3 months ago

0.0.20240220

3 months ago

0.0.20240214

3 months ago

0.0.20240130

4 months ago

0.0.20240118

4 months ago

0.0.20240109

4 months ago

0.0.20231212

5 months ago

0.0.20231128

6 months ago

0.0.20231107

6 months ago

0.0.20230815

9 months ago

0.0.20231031

7 months ago

0.0.20231114

6 months ago

0.0.20230808

9 months ago

0.0.20230926

8 months ago

0.0.20230920

8 months ago

0.0.20231017

7 months ago

0.0.20230720

10 months ago

0.0.20230727

10 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.20230713

10 months ago

0.0.20230912

8 months ago

0.0.20230829

9 months ago

0.0.20230706

11 months ago

0.0.20230905

8 months ago

0.0.20230822

9 months ago

0.0.20230704

11 months ago

0.0.20231003

7 months ago

0.0.20230622

11 months ago

0.0.20230613

11 months ago

0.0.20230620

11 months ago

0.0.20230608

11 months ago

0.0.20230601

12 months ago

0.0.20230523

12 months ago

0.0.20230606

12 months ago

0.0.20230530

12 months ago

0.0.20230518

1 year ago

0.0.20230516

1 year ago

0.0.20230502

1 year ago

0.0.20230504

1 year ago

0.0.20230418

1 year ago

0.0.20230420

1 year ago

0.0.20230328

1 year ago

0.0.20230406

1 year ago

0.0.20230330

1 year ago

0.0.20230314

1 year ago

0.0.20230323

1 year ago

0.0.20230321

1 year ago

0.0.20230425

1 year ago

0.0.20230228

1 year ago

0.0.20230309

1 year ago

0.0.20230307

1 year ago

0.0.20230214

1 year ago

0.0.20230202

1 year ago

0.0.20230221

1 year ago

0.0.20230126

1 year ago

0.0.20230209

1 year ago

0.0.20230207

1 year ago

0.0.20230131

1 year ago

0.0.20230117

1 year ago

0.0.20221115

2 years ago

0.0.20230119

1 year ago

0.0.20221110

2 years ago

0.0.20230124

1 year ago

0.0.20221208

1 year ago

0.0.20230103

1 year ago

0.0.20221108

2 years ago

0.0.20221206

1 year ago

0.0.20221129

1 year ago

0.0.20221103

2 years ago

0.0.20230105

1 year ago

0.0.20221201

1 year ago

0.0.20230110

1 year ago

0.0.20221117

1 year ago

0.0.20221020

2 years ago

0.0.20221006

2 years ago

0.0.20221027

2 years ago

0.0.20221025

2 years ago

0.0.20221101

2 years ago

0.0.20221013

2 years ago

0.0.20221011

2 years ago

0.0.20220927

2 years ago

0.0.20221018

2 years ago

0.0.20220906

2 years ago

0.0.20220829

2 years ago

0.0.20220818

2 years ago

0.0.20220908

2 years ago

0.0.20220920

2 years ago

0.0.20220921

2 years ago

0.0.20220823

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.20220811

2 years ago

0.0.20220808

2 years ago