Tuesday, June 23, 2026
HomeEveryday WordPressAutomate client reporting with Kinsta API and Google AI

Automate client reporting with Kinsta API and Google AI


For modern agencies, a high-quality, consistent reporting system is essential for maintaining client trust and building long-term loyalty. A clear, informative report allows you to monitor sales trends, demonstrate campaign effectiveness, calculate return on investment (ROI), and much more.

However, for an agency managing dozens or even hundreds of sites, generating these periodic reports can become a major bottleneck, compromising the scalability of your operations.

That is why optimizing and automating data retrieval is crucial. It restores efficiency and frees up your team to focus on high-value activities—like developing new projects.

In this article, you will learn how to leverage the Kinsta API to automatically fetch your hosting data and generate strategic reports with the power of AI.

Are you ready to scale your reporting system? Read on.

Accessing Kinsta Analytics via MyKinsta and Kinsta API

Kinsta customers have access to a wealth of data through the MyKinsta hosting dashboard. You can access your plan data in the Analytics section of your dashboard.

Overview of the MyKinsta Analytics section.

The Analytics page is divided into several tabs, each focusing on a specific aspect of your site’s activity:

  • Plan usage: Displays your plan’s resource consumption, both cumulatively and broken down by individual site.
  • Top requests: Allows you to identify the primary requests to your site, categorized by bandwidth and views.
  • Cache: Provides a breakdown of cache usage, including Cache breakdown, Server cache components, and Server cache bypasses.
  • CDN & edge: Offers data on CDN bandwidth consumption, Edge cache bandwidth, and lists of the top files served from the CDN cache.
  • Dispersion: Shows the percentage of visits from desktop, tablet, and mobile.
  • Performance: Includes various performance metrics such as Average PHP + MySQL response time, PHP throughput, PHP thread limit, and more.
  • Response: Provides statistics on response codes, including a detailed breakdown of error codes.
  • Geo & IP: Displays lists of the Top Countries, Top Cities, and Top Client IPs from which requests to your site originate.

You can access these same analytics at the site level by navigating to Sites > sitename > Analytics.

Site analytics in MyKinsta.
Site analytics in MyKinsta.

Kinsta Analytics provides a staggering dataset; simply navigating your MyKinsta dashboard gives you a very clear picture of your site’s resource consumption, efficiency, and performance. You will know exactly where most requests come from and which ones consume the most resources.

Combined with our Kinsta APM tool, Kinsta Analytics enables you to optimize the performance of your WordPress sites.

What not everyone knows is that Kinsta Analytics data is also accessible via the Kinsta API. This allows you to programmatically retrieve data and build hosting metrics, which you can then use to generate automated reports to share with your clients.

Let’s explore the Kinsta API endpoints.

The Analytics endpoint of the Kinsta API

With the Analytics endpoint of the Kinsta API, you can access raw data on your website’s resource usage and health.

  • Visits usage, server bandwidth usage, and CDN bandwidth usage: These metrics track your resource usage relative to your hosting plan during the current billing period.
  • Visits: Provides the total number of visits to a given environment within a specified time period.
  • Disk space: Provides the total disk space used by a given environment over a specified time period.
  • Server bandwidth: Provides the bandwidth consumed by a given environment over a specified time period.
  • CDN bandwidth: Provides the CDN bandwidth consumed by a given environment over a specified time period.
  • Top Countries: Provides a list of the main countries from which requests to the site originate within a specified time period.
  • Top Cities: Provides a list of the main cities from which requests to the site originated during a specified time period.
  • Top Client IPs: Provides a list of the main client IP addresses from which requests to the site originated during a specified time period.
  • Visit Dispersion: It provides data on the distribution of visits across desktop, tablet, and mobile devices over a specified time period.
  • Response Code Breakdown: Provides a breakdown of the HTTP status codes returned by the server within a specified time period.

Below are some examples of how to use the analytics endpoint.

Visits

The following request provides the total number of visits to your site and the number of unique IP addresses that have accessed it in the last 30 days:

https://api.kinsta.com/v2/sites/environments/{KINSTA_ENV_ID}/analytics/visits?time_span=30_days&company_id={KINSTA_COMPANY_ID}

The response will be structured as follows:

{
	"analytics": {
		"analytics_response": {
			"key": "uniqueip",
			"data": [
				{
					"name": "uniqueip",
					"total": 1000,
					"dataset": [
						{
							"key": "2025-10-28T00:00:00.000Z",
							"value": "1000"
						},
						{
							"key": "2025-10-28T00:00:00.000Z",
							"value": "900"
						},
						{
							"key": "2025-10-28T00:00:00.000Z",
							"value": "820"
						},
						...
					]
				}
			]
		}
	}
}

Bandwidth

The following example shows how to query the Kinsta API to retrieve the server’s bandwidth usage over the past 30 days:

https://api.kinsta.com/v2/sites/environments/{KINSTA_ENV_ID}/analytics/bandwidth?time_span=30_days&company_id={KINSTA_COMPANY_ID}

The response from the Kinsta server provides the daily bandwidth usage for the past 30 days:

{
	"analytics": {
		"analytics_response": {
			"key": "bandwidth",
			"data": [
				{
					"name": "bandwidth",
					"total": 1000,
					"dataset": [
						{
							"key": "2026-03-11T00:00:00.000Z",
							"value": "37347250"
						},
						{
							"key": "2026-03-12T00:00:00.000Z",
							"value": "9276458"
						},
						...
					]
				}
			]
		}
	}
}

CDN bandwidth

In this other example, we query the Kinsta API to find out the CDN bandwidth usage for the past 7 days:

https://api.kinsta.com/v2/sites/environments/{KINSTA_ENV_ID}/analytics/cdn-bandwidth?time_span=7_days&company_id={KINSTA_COMPANY_ID}

The server will provide the following data:

{
	"analytics": {
		"analytics_response": {
			"key": "cdn-bandwidth",
			"data": [
				{
					"name": "cdn-bandwidth",
					"total": 1000,
					"dataset": [
						{
							"key": "2026-04-02T00:00:00.000Z",
							"value": "753447"
						},
						{
							"key": "2026-04-03T00:00:00.000Z",
							"value": "16911"
						},
						...
					]
				}
			]
		}
	}
}

You can try it yourself by entering your Kinsta API key (bearer token), environment ID, and company ID in the API playground.

Test the Kinsta API in the API playground.
Test the Kinsta API in the API playground.

Now that you know how to access your site’s analytics data on Kinsta, you can use it to automate your operations. This also includes automating the reporting system.

The following sections will show you how to automate your agency’s reporting system using the Kinsta API. We will build a Python script and leverage GitHub Actions to automate the build and run. This will transform the raw data returned by the API into tables and charts, and query Google AI to generate a final report.

It’s time to get your hands dirty.



Source link

RELATED ARTICLES
Continue to the category

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Most Popular

Recent Comments