@maxim_mazurok/gapi.client.marketingplatformadmin-v1alpha
v0.1.20260318
Published
TypeScript typings for Google Marketing Platform Admin API v1alpha
Readme
TypeScript typings for Google Marketing Platform Admin API v1alpha
The Google Marketing Platform Admin API allows for programmatic access to the Google Marketing Platform configuration data. You can use the Google Marketing Platform Admin API to manage links between your Google Marketing Platform organization and Google Analytics accounts, and to set the service level of your GA4 properties. For detailed description please check documentation.
Installing
Install typings for Google Marketing Platform Admin API:
npm install @types/gapi.client.marketingplatformadmin-v1alpha --save-devUsage
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://marketingplatformadmin.googleapis.com/$discovery/rest?version=v1alpha',
() => {
// now we can use:
// gapi.client.marketingplatformadmin
},
);// 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('marketingplatformadmin', 'v1alpha', () => {
// now we can use:
// gapi.client.marketingplatformadmin
});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 = [
// View your Google Analytics product account data in GMP home
'https://www.googleapis.com/auth/marketingplatformadmin.analytics.read',
// Manage your Google Analytics product account data in GMP home
'https://www.googleapis.com/auth/marketingplatformadmin.analytics.update',
],
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 Marketing Platform Admin API resources:
/*
Returns a list of clients managed by the sales partner organization. User needs to be an OrgAdmin/BillingAdmin on the sales partner organization in order to view the end clients.
*/
await gapi.client.marketingplatformadmin.organizations.findSalesPartnerManagedClients(
{organization: 'organization'},
);
/*
Looks up a single organization.
*/
await gapi.client.marketingplatformadmin.organizations.get({name: 'name'});
/*
Returns a list of organizations that the user has access to.
*/
await gapi.client.marketingplatformadmin.organizations.list({});
/*
Gets the usage and billing data for properties within the organization for the specified month. Per direct client org, user needs to be OrgAdmin/BillingAdmin on the organization in order to view the billing and usage data. Per sales partner client org, user needs to be OrgAdmin/BillingAdmin on the sales partner org in order to view the billing and usage data, or OrgAdmin/BillingAdmin on the sales partner client org in order to view the usage data only.
*/
await gapi.client.marketingplatformadmin.organizations.reportPropertyUsage({
organization: 'organization',
});For provenance information see Provenance section on NPM
