0.0.20250606 • Published 6 months ago

@maxim_mazurok/gapi.client.homegraph-v1 v0.0.20250606

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

TypeScript typings for HomeGraph API v1

For detailed description please check documentation.

Installing

Install typings for HomeGraph API:

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

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 = [
    // Private Service: https://www.googleapis.com/auth/homegraph
    'https://www.googleapis.com/auth/homegraph',
  ],
  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 HomeGraph API resources:

/*
Unlinks the given third-party user from your smart home Action. All data related to this user will be deleted. For more details on how users link their accounts, see [fulfillment and authentication](https://developers.home.google.com/cloud-to-cloud/primer/fulfillment). The third-party user's identity is passed in via the `agent_user_id` (see DeleteAgentUserRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.agentUsers.delete({agentUserId: 'agentUserId'});

/*
Gets the current states in Home Graph for the given set of the third-party user's devices. The third-party user's identity is passed in via the `agent_user_id` (see QueryRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.query({});

/*
Reports device state and optionally sends device notifications. Called by your smart home Action when the state of a third-party device changes or you need to send a notification about the device. See [Implement Report State](https://developers.home.google.com/cloud-to-cloud/integration/report-state) for more information. This method updates the device state according to its declared [traits](https://developers.home.google.com/cloud-to-cloud/primer/device-types-and-traits). Publishing a new state value outside of these traits will result in an `INVALID_ARGUMENT` error response. The third-party user's identity is passed in via the `agent_user_id` (see ReportStateAndNotificationRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.reportStateAndNotification({});

/*
Requests Google to send an `action.devices.SYNC` [intent](https://developers.home.google.com/cloud-to-cloud/intents/sync) to your smart home Action to update device metadata for the given user. The third-party user's identity is passed via the `agent_user_id` (see RequestSyncDevicesRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.requestSync({});

/*
Gets all the devices associated with the given third-party user. The third-party user's identity is passed in via the `agent_user_id` (see SyncRequest). This request must be authorized using service account credentials from your Actions console project.
*/
await gapi.client.homegraph.devices.sync({});
0.0.20250527

6 months ago

0.0.20250404

8 months ago

0.0.20250124

10 months ago

0.0.20250131

10 months ago

0.0.20250418

7 months ago

0.0.20250531

6 months ago

0.0.20250410

7 months ago

0.0.20241202

12 months ago

0.0.20250429

7 months ago

0.0.20250307

9 months ago

0.0.20250424

7 months ago

0.0.20241213

11 months ago

0.0.20241210

12 months ago

0.0.20250314

8 months ago

0.0.20250321

8 months ago

0.0.20241205

12 months ago

0.0.20241101

1 year ago

0.0.20250606

6 months ago

0.0.20250208

10 months ago

0.0.20250204

10 months ago

0.0.20250331

8 months ago

0.0.20250211

10 months ago

0.0.20241219

11 months ago

0.0.20241111

1 year ago

0.0.20250214

9 months ago

0.0.20250221

9 months ago

0.0.20250509

7 months ago

0.0.20241122

12 months ago

0.0.20250228

9 months ago

0.0.20250501

7 months ago

0.0.20250110

11 months ago

0.0.20241115

1 year ago

0.0.20250515

6 months ago

0.0.20250117

10 months ago

0.0.20241025

1 year ago

0.0.20241018

1 year ago

0.0.20240927

1 year ago

0.0.20241004

1 year ago

0.0.20241011

1 year ago

0.0.20240913

1 year ago

0.0.20240920

1 year ago

0.0.20240906

1 year ago

0.0.20240830

1 year ago

0.0.20240826

1 year ago

0.0.20240530

1 year ago

0.0.20240809

1 year ago

0.0.20240529

1 year ago

0.0.20240607

1 year ago

0.0.20240802

1 year ago

0.0.20240726

1 year ago

0.0.20240605

1 year ago

0.0.20240523

2 years ago

0.0.20240524

1 year ago

0.0.20240816

1 year ago

0.0.20240614

1 year ago

0.0.20240621

1 year ago

0.0.20240719

1 year ago

0.0.20240712

1 year ago

0.0.20240517

2 years ago

0.0.20240503

2 years ago

0.0.20240427

2 years ago

0.0.20240419

2 years ago

0.0.20240417

2 years ago

0.0.20240412

2 years ago

0.0.20240409

2 years ago

0.0.20240405

2 years ago

0.0.20240329

2 years ago

0.0.20240322

2 years ago

0.0.20240315

2 years ago

0.0.20240311

2 years ago

0.0.20240226

2 years ago

0.0.20240220

2 years ago

0.0.20240213

2 years ago

0.0.20240211

2 years ago

0.0.20240207

2 years ago

0.0.20240206

2 years ago

0.0.20240201

2 years ago

0.0.20240126

2 years ago

0.0.20240119

2 years ago

0.0.20240111

2 years ago

0.0.20240105

2 years ago

0.0.20231208

2 years ago

0.0.20231130

2 years ago

0.0.20230818

2 years ago

0.0.20230811

2 years ago

0.0.20231107

2 years ago

0.0.20231110

2 years ago

0.0.20230728

2 years ago

0.0.20230920

2 years ago

0.0.20230721

2 years ago

0.0.20230804

2 years ago

0.0.20231020

2 years ago

0.0.20230915

2 years ago

0.0.20231006

2 years ago

0.0.20230831

2 years ago

0.0.20230714

2 years ago

0.0.20231013

2 years ago

0.0.20230829

2 years ago

0.0.20230707

2 years ago

0.0.20230908

2 years ago

0.0.20231123

2 years ago

0.0.20230623

2 years ago

0.0.20230519

3 years ago

0.0.20230516

3 years ago

0.0.20230526

2 years ago

0.0.20230428

3 years ago

0.0.20230414

3 years ago

0.0.20230317

3 years ago

0.0.20230421

3 years ago

0.0.20230324

3 years ago

0.0.20230225

3 years ago

0.0.20230303

3 years ago

0.0.20230405

3 years ago

0.0.20230331

3 years ago

0.0.20230310

3 years ago

0.0.20230216

3 years ago

0.0.20230203

3 years ago

0.0.20230127

3 years ago

0.0.20230210

3 years ago

0.0.20230106

3 years ago

0.0.20221214

3 years ago

0.0.20221115

3 years ago

0.0.20221221

3 years ago

0.0.20230113

3 years ago

0.0.20221109

3 years ago

0.0.20221206

3 years ago

0.0.20221118

3 years ago

0.0.20221018

3 years ago

0.0.20221007

3 years ago

0.0.20221028

3 years ago

0.0.20221004

3 years ago

0.0.20221021

3 years ago

0.0.20220909

3 years ago

0.0.20220921

3 years ago

0.0.20220823

3 years ago

0.0.20220812

3 years ago

0.0.20220805

3 years ago