Gmail Postmaster Tools API
googleapis · Analytics
The Postmaster Tools API is a RESTful API that provides programmatic access to email traffic metrics (like spam reports, delivery errors etc) otherwise available through the Gmail Postmaster Tools UI currently.
Authentication
Sample Requests
Lists the domains that have been registered by the client. The order of domains in the response is unspecified and non-deterministic. Newly created domains will not necessarily be added to the end of this list.
Hover any highlighted part to learn what it does
curl -X GET "https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/domains?alt=json&key=YOUR_API_KEY&fields=example&$.xgafv=1&callback=example&pageSize=1&pageToken=example"aUser=example&uploadType=example&oauth_token=example&prettyPrint=true&access_token=example&upload_protocol=example"
import requests
params = {
"alt": "json",
"key": "YOUR_API_KEY",
"fields": "example",
"$.xgafv": "1",
"callback": "example",
"pageSize": "1",
"pageToken": "example",
"quotaUser": "example",
"uploadType": "example",
"oauth_token": "example",
"prettyPrint": "true",
"access_token": "example",
"upload_protocol": "example"
}
response = requests.get(
"https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/domains",
params=params,
)
print(response.json())const url = new URL('https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/domains');
url.searchParams.set('alt', 'json');
url.searchParams.set('key', 'YOUR_API_KEY');
url.searchParams.set('fields', 'example');
url.searchParams.set('$.xgafv', '1');
url.searchParams.set('callback', 'example');
url.searchParams.set('pageSize', '1');
url.searchParams.set('pageToken', 'example');
url.searchParams.set('quotaUser', 'example');
url.searchParams.set('uploadType', 'example');
url.searchParams.set('oauth_token', 'example');
url.searchParams.set('prettyPrint', 'true');
url.searchParams.set('access_token', 'example');
url.searchParams.set('upload_protocol', 'example');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/domains")
q := baseURL.Query()
q.Set("alt", "json")
q.Set("key", "YOUR_API_KEY")
q.Set("fields", "example")
q.Set("$.xgafv", "1")
q.Set("callback", "example")
q.Set("pageSize", "1")
q.Set("pageToken", "example")
q.Set("quotaUser", "example")
q.Set("uploadType", "example")
q.Set("oauth_token", "example")
q.Set("prettyPrint", "true")
q.Set("access_token", "example")
q.Set("upload_protocol", "example")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/domains")
uri.query = URI.encode_www_form({
"alt" => "json",
"key" => "YOUR_API_KEY",
"fields" => "example",
"$.xgafv" => "1",
"callback" => "example",
"pageSize" => "1",
"pageToken" => "example",
"quotaUser" => "example",
"uploadType" => "example",
"oauth_token" => "example",
"prettyPrint" => "true",
"access_token" => "example",
"upload_protocol" => "example"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/domains?" . http_build_query([
"alt" => "json",
"key" => "YOUR_API_KEY",
"fields" => "example",
"$.xgafv" => "1",
"callback" => "example",
"pageSize" => "1",
"pageToken" => "example",
"quotaUser" => "example",
"uploadType" => "example",
"oauth_token" => "example",
"prettyPrint" => "true",
"access_token" => "example",
"upload_protocol" => "example"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));List traffic statistics for all available days. Returns PERMISSION_DENIED if user does not have permission to access TrafficStats for the domain.
Hover any highlighted part to learn what it does
curl -X GET "https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{parent}/trafficStats?alt=json&key=YOUR_API_KEY&fields=example&$.xgafv=1&callback=example&pageSize=1&pageToken=example"aUser=example&uploadType=example&endDate.day=1&oauth_token=example&prettyPrint=true&access_token=example&endDate.year=1&endDate.month=1&startDate.day=1&startDate.year=1&startDate.month=1&upload_protocol=example"import requests
params = {
"alt": "json",
"key": "YOUR_API_KEY",
"fields": "example",
"$.xgafv": "1",
"callback": "example",
"pageSize": "1",
"pageToken": "example",
"quotaUser": "example",
"uploadType": "example",
"endDate.day": "1",
"oauth_token": "example",
"prettyPrint": "true",
"access_token": "example",
"endDate.year": "1",
"endDate.month": "1",
"startDate.day": "1",
"startDate.year": "1",
"startDate.month": "1",
"upload_protocol": "example"
}
response = requests.get(
"https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{parent}/trafficStats",
params=params,
)
print(response.json())const url = new URL('https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{parent}/trafficStats');
url.searchParams.set('alt', 'json');
url.searchParams.set('key', 'YOUR_API_KEY');
url.searchParams.set('fields', 'example');
url.searchParams.set('$.xgafv', '1');
url.searchParams.set('callback', 'example');
url.searchParams.set('pageSize', '1');
url.searchParams.set('pageToken', 'example');
url.searchParams.set('quotaUser', 'example');
url.searchParams.set('uploadType', 'example');
url.searchParams.set('endDate.day', '1');
url.searchParams.set('oauth_token', 'example');
url.searchParams.set('prettyPrint', 'true');
url.searchParams.set('access_token', 'example');
url.searchParams.set('endDate.year', '1');
url.searchParams.set('endDate.month', '1');
url.searchParams.set('startDate.day', '1');
url.searchParams.set('startDate.year', '1');
url.searchParams.set('startDate.month', '1');
url.searchParams.set('upload_protocol', 'example');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{parent}/trafficStats")
q := baseURL.Query()
q.Set("alt", "json")
q.Set("key", "YOUR_API_KEY")
q.Set("fields", "example")
q.Set("$.xgafv", "1")
q.Set("callback", "example")
q.Set("pageSize", "1")
q.Set("pageToken", "example")
q.Set("quotaUser", "example")
q.Set("uploadType", "example")
q.Set("endDate.day", "1")
q.Set("oauth_token", "example")
q.Set("prettyPrint", "true")
q.Set("access_token", "example")
q.Set("endDate.year", "1")
q.Set("endDate.month", "1")
q.Set("startDate.day", "1")
q.Set("startDate.year", "1")
q.Set("startDate.month", "1")
q.Set("upload_protocol", "example")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{parent}/trafficStats")
uri.query = URI.encode_www_form({
"alt" => "json",
"key" => "YOUR_API_KEY",
"fields" => "example",
"$.xgafv" => "1",
"callback" => "example",
"pageSize" => "1",
"pageToken" => "example",
"quotaUser" => "example",
"uploadType" => "example",
"endDate.day" => "1",
"oauth_token" => "example",
"prettyPrint" => "true",
"access_token" => "example",
"endDate.year" => "1",
"endDate.month" => "1",
"startDate.day" => "1",
"startDate.year" => "1",
"startDate.month" => "1",
"upload_protocol" => "example"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{parent}/trafficStats?" . http_build_query([
"alt" => "json",
"key" => "YOUR_API_KEY",
"fields" => "example",
"$.xgafv" => "1",
"callback" => "example",
"pageSize" => "1",
"pageToken" => "example",
"quotaUser" => "example",
"uploadType" => "example",
"endDate.day" => "1",
"oauth_token" => "example",
"prettyPrint" => "true",
"access_token" => "example",
"endDate.year" => "1",
"endDate.month" => "1",
"startDate.day" => "1",
"startDate.year" => "1",
"startDate.month" => "1",
"upload_protocol" => "example"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get traffic statistics for a domain on a specific date. Returns PERMISSION_DENIED if user does not have permission to access TrafficStats for the domain.
Hover any highlighted part to learn what it does
curl -X GET "https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{name}?alt=json&key=YOUR_API_KEY&fields=example&$.xgafv=1&callback=example"aUser=example&uploadType=example&oauth_token=example&prettyPrint=true&access_token=example&upload_protocol=example"import requests
params = {
"alt": "json",
"key": "YOUR_API_KEY",
"fields": "example",
"$.xgafv": "1",
"callback": "example",
"quotaUser": "example",
"uploadType": "example",
"oauth_token": "example",
"prettyPrint": "true",
"access_token": "example",
"upload_protocol": "example"
}
response = requests.get(
"https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{name}",
params=params,
)
print(response.json())const url = new URL('https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{name}');
url.searchParams.set('alt', 'json');
url.searchParams.set('key', 'YOUR_API_KEY');
url.searchParams.set('fields', 'example');
url.searchParams.set('$.xgafv', '1');
url.searchParams.set('callback', 'example');
url.searchParams.set('quotaUser', 'example');
url.searchParams.set('uploadType', 'example');
url.searchParams.set('oauth_token', 'example');
url.searchParams.set('prettyPrint', 'true');
url.searchParams.set('access_token', 'example');
url.searchParams.set('upload_protocol', 'example');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{name}")
q := baseURL.Query()
q.Set("alt", "json")
q.Set("key", "YOUR_API_KEY")
q.Set("fields", "example")
q.Set("$.xgafv", "1")
q.Set("callback", "example")
q.Set("quotaUser", "example")
q.Set("uploadType", "example")
q.Set("oauth_token", "example")
q.Set("prettyPrint", "true")
q.Set("access_token", "example")
q.Set("upload_protocol", "example")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{name}")
uri.query = URI.encode_www_form({
"alt" => "json",
"key" => "YOUR_API_KEY",
"fields" => "example",
"$.xgafv" => "1",
"callback" => "example",
"quotaUser" => "example",
"uploadType" => "example",
"oauth_token" => "example",
"prettyPrint" => "true",
"access_token" => "example",
"upload_protocol" => "example"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.apis.guru/v2/specs/googleapis.com/gmailpostmastertools/v1beta1/v1beta1/{name}?" . http_build_query([
"alt" => "json",
"key" => "YOUR_API_KEY",
"fields" => "example",
"$.xgafv" => "1",
"callback" => "example",
"quotaUser" => "example",
"uploadType" => "example",
"oauth_token" => "example",
"prettyPrint" => "true",
"access_token" => "example",
"upload_protocol" => "example"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- See official documentation for authentication and setup.
What can you build with Gmail Postmaster Tools API?
Gmail Postmaster Tools API is a Analytics API. Developers commonly use analytics APIs for:
- tracking product usage and user behaviour
- building custom reporting and BI dashboards
- measuring marketing and campaign performance
- running funnel, retention, and cohort analysis
- aggregating metrics from multiple data sources
No authentication required. This API is open — no signup or key needed. Ideal for quick prototypes and public-facing features. Gmail Postmaster Tools API is free to use, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide · Learn about API keys · What is REST?