KosmoKrator

analytics

Google Search Console Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Google Search Console KosmoKrator integration.

7 functions 7 read 0 write Manual OAuth token auth

Lua Namespace

Agents call this integration through app.integrations.google_search_console.*. Use lua_read_doc("integrations.google-search-console") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Google Search Console — Lua API Reference

list_sites

List sites the authenticated user has access to in Google Search Console.

Parameters

NameTypeRequiredDescription
pageSizeintegernoMaximum number of results per page
pageTokenstringnoToken for the next page of results

Examples

local result = app.integrations["google-search-console"].list_sites({})

for _, site in ipairs(result.sites) do
  print(site.siteUrl .. " — " .. site.permissionLevel)
end

get_site

Get details for a specific site.

Parameters

NameTypeRequiredDescription
idstringyesThe site URL (e.g., "https://example.com/")

Examples

local result = app.integrations["google-search-console"].get_site({
  id = "https://example.com/"
})

print(result.siteUrl .. " — " .. result.permissionLevel)

list_sitemaps

List sitemaps submitted for a site.

Parameters

NameTypeRequiredDescription
site_urlstringyesThe site URL
pageSizeintegernoMaximum number of results per page
pageTokenstringnoToken for the next page of results
shortUrlsbooleannoWhether to return short URLs

Examples

local result = app.integrations["google-search-console"].list_sitemaps({
  site_url = "https://example.com/"
})

for _, sitemap in ipairs(result.sitemaps) do
  print(sitemap.path .. " — " .. (sitemap.lastSubmitted or "N/A"))
end

get_sitemap

Get details for a specific sitemap.

Parameters

NameTypeRequiredDescription
site_urlstringyesThe site URL
idstringyesThe sitemap URL or ID

Examples

local result = app.integrations["google-search-console"].get_sitemap({
  site_url = "https://example.com/",
  id = "https://example.com/sitemap.xml"
})

print(result.path .. " — Errors: " .. (result.errors or 0))

list_search_analytics

Query search performance data — clicks, impressions, CTR, and average position.

Parameters

NameTypeRequiredDescription
site_urlstringyesThe site URL
startDatestringyesStart date (YYYY-MM-DD)
endDatestringyesEnd date (YYYY-MM-DD)
dimensionsarraynoDimensions to group by: "query", "page", "country", "device", "searchAppearance"
typestringnoSearch type: "web", "image", "video", "news"

Examples

Top queries by clicks

local result = app.integrations["google-search-console"].list_search_analytics({
  site_url = "https://example.com/",
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  dimensions = {"query"}
})

for _, row in ipairs(result.rows) do
  print(row.keys[1] .. ": " .. row.clicks .. " clicks, position " .. row.position)
end

Top pages with device breakdown

local result = app.integrations["google-search-console"].list_search_analytics({
  site_url = "https://example.com/",
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  dimensions = {"page", "device"}
})

Image search performance

local result = app.integrations["google-search-console"].list_search_analytics({
  site_url = "https://example.com/",
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  dimensions = {"query"},
  type = "image"
})

list_url_inspection

Inspect URLs for indexing status and issues.

Parameters

NameTypeRequiredDescription
site_urlstringyesThe site URL
pageTokenstringnoToken for the next page of results
limitintegernoMaximum number of results
inspectionResultstringnoFilter by status: "PASS", "FAIL", "WARNING"

Examples

local result = app.integrations["google-search-console"].list_url_inspection({
  site_url = "https://example.com/"
})

for _, item in ipairs(result.results or {}) do
  print(item.url .. " — " .. item.inspectionResult)
end

get_current_user

Get the authenticated user’s profile.

Parameters

None.

Examples

local result = app.integrations["google-search-console"].get_current_user({})
print("Authenticated as: " .. result.email)

Multi-Account Usage

If you have multiple Google Search Console accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations["google-search-console"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["google-search-console"].default.function_name({...})

-- Named accounts
app.integrations["google-search-console"].work.function_name({...})
app.integrations["google-search-console"].client.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Google Search Console — Lua API Reference

## list_sites

List sites the authenticated user has access to in Google Search Console.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pageSize` | integer | no | Maximum number of results per page |
| `pageToken` | string | no | Token for the next page of results |

### Examples

```lua
local result = app.integrations["google-search-console"].list_sites({})

for _, site in ipairs(result.sites) do
  print(site.siteUrl .. " — " .. site.permissionLevel)
end
```

---

## get_site

Get details for a specific site.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The site URL (e.g., `"https://example.com/"`) |

### Examples

```lua
local result = app.integrations["google-search-console"].get_site({
  id = "https://example.com/"
})

print(result.siteUrl .. " — " .. result.permissionLevel)
```

---

## list_sitemaps

List sitemaps submitted for a site.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_url` | string | yes | The site URL |
| `pageSize` | integer | no | Maximum number of results per page |
| `pageToken` | string | no | Token for the next page of results |
| `shortUrls` | boolean | no | Whether to return short URLs |

### Examples

```lua
local result = app.integrations["google-search-console"].list_sitemaps({
  site_url = "https://example.com/"
})

for _, sitemap in ipairs(result.sitemaps) do
  print(sitemap.path .. " — " .. (sitemap.lastSubmitted or "N/A"))
end
```

---

## get_sitemap

Get details for a specific sitemap.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_url` | string | yes | The site URL |
| `id` | string | yes | The sitemap URL or ID |

### Examples

```lua
local result = app.integrations["google-search-console"].get_sitemap({
  site_url = "https://example.com/",
  id = "https://example.com/sitemap.xml"
})

print(result.path .. " — Errors: " .. (result.errors or 0))
```

---

## list_search_analytics

Query search performance data — clicks, impressions, CTR, and average position.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_url` | string | yes | The site URL |
| `startDate` | string | yes | Start date (YYYY-MM-DD) |
| `endDate` | string | yes | End date (YYYY-MM-DD) |
| `dimensions` | array | no | Dimensions to group by: `"query"`, `"page"`, `"country"`, `"device"`, `"searchAppearance"` |
| `type` | string | no | Search type: `"web"`, `"image"`, `"video"`, `"news"` |

### Examples

#### Top queries by clicks

```lua
local result = app.integrations["google-search-console"].list_search_analytics({
  site_url = "https://example.com/",
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  dimensions = {"query"}
})

for _, row in ipairs(result.rows) do
  print(row.keys[1] .. ": " .. row.clicks .. " clicks, position " .. row.position)
end
```

#### Top pages with device breakdown

```lua
local result = app.integrations["google-search-console"].list_search_analytics({
  site_url = "https://example.com/",
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  dimensions = {"page", "device"}
})
```

#### Image search performance

```lua
local result = app.integrations["google-search-console"].list_search_analytics({
  site_url = "https://example.com/",
  startDate = "2025-01-01",
  endDate = "2025-01-31",
  dimensions = {"query"},
  type = "image"
})
```

---

## list_url_inspection

Inspect URLs for indexing status and issues.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `site_url` | string | yes | The site URL |
| `pageToken` | string | no | Token for the next page of results |
| `limit` | integer | no | Maximum number of results |
| `inspectionResult` | string | no | Filter by status: `"PASS"`, `"FAIL"`, `"WARNING"` |

### Examples

```lua
local result = app.integrations["google-search-console"].list_url_inspection({
  site_url = "https://example.com/"
})

for _, item in ipairs(result.results or {}) do
  print(item.url .. " — " .. item.inspectionResult)
end
```

---

## get_current_user

Get the authenticated user's profile.

### Parameters

None.

### Examples

```lua
local result = app.integrations["google-search-console"].get_current_user({})
print("Authenticated as: " .. result.email)
```

---

## Multi-Account Usage

If you have multiple Google Search Console accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations["google-search-console"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["google-search-console"].default.function_name({...})

-- Named accounts
app.integrations["google-search-console"].work.function_name({...})
app.integrations["google-search-console"].client.function_name({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.google_search_console.gsc_list_sites({
  pageSize = 1,
  pageToken = "example_pageToken"
})
print(result)

Functions

gsc_list_sites

List all sites the authenticated user has access to in Google Search Console. Returns site URLs and permission levels.

Operation
Read read
Full name
google-search-console.gsc_list_sites
ParameterTypeRequiredDescription
pageSize integer no Maximum number of results per page.
pageToken string no Token for the next page of results, from a previous response.

gsc_get_site

Get details for a specific site in Google Search Console, including permission level.

Operation
Read read
Full name
google-search-console.gsc_get_site
ParameterTypeRequiredDescription
id string yes The site URL (e.g., "https://example.com/").

gsc_list_sitemaps

List sitemaps submitted for a site in Google Search Console. Returns sitemap URLs, types, and indexing status.

Operation
Read read
Full name
google-search-console.gsc_list_sitemaps
ParameterTypeRequiredDescription
site_url string yes The site URL (e.g., "https://example.com/").
pageSize integer no Maximum number of results per page.
pageToken string no Token for the next page of results, from a previous response.
shortUrls boolean no Whether to return short URLs for sitemaps.

gsc_get_sitemap

Get details for a specific sitemap in Google Search Console, including indexing status and any errors.

Operation
Read read
Full name
google-search-console.gsc_get_sitemap
ParameterTypeRequiredDescription
site_url string yes The site URL (e.g., "https://example.com/").
id string yes The sitemap URL or ID (e.g., "https://example.com/sitemap.xml").

gsc_list_search_analytics

Query search performance data from Google Search Console — clicks, impressions, CTR, and average position. Group by dimensions like query, page, country, or device.

Operation
Read read
Full name
google-search-console.gsc_list_search_analytics
ParameterTypeRequiredDescription
site_url string yes The site URL (e.g., "https://example.com/").
startDate string yes Start date in YYYY-MM-DD format (e.g., "2025-01-01").
endDate string yes End date in YYYY-MM-DD format (e.g., "2025-01-31").
dimensions array no Dimensions to group results by: "query", "page", "country", "device", "searchAppearance".
type string no Search type filter: "web", "image", "video", or "news". Defaults to "web".

gsc_list_url_inspection

Inspect URLs for a site in Google Search Console. Returns indexing status, crawl information, and any detected issues.

Operation
Read read
Full name
google-search-console.gsc_list_url_inspection
ParameterTypeRequiredDescription
site_url string yes The site URL (e.g., "https://example.com/").
pageToken string no Token for the next page of results, from a previous response.
limit integer no Maximum number of URL inspection results to return.
inspectionResult string no Filter by inspection result status (e.g., "PASS", "FAIL", "WARNING").

gsc_get_current_user

Get the authenticated user's profile from Google Search Console. Returns email and account information.

Operation
Read read
Full name
google-search-console.gsc_get_current_user
ParameterTypeRequiredDescription
No parameters.