Skip to main content
c.Apps.Network works on web apps only. Every method takes ctx and the app id first. Each snippet below runs on its own inside this program: paste one at a time into main and run goimports (see Running the examples).

Time windows

Analytics, Errors, Logs and Performance take a start and an end, each a time.Time (sent as RFC 3339 in UTC). The program above sets them to the last 24 hours. A window is at most 7 days, and start is clamped to the app’s creation date. An invalid window is 400 INVALID_TIME_RANGE. Results are cached in 5-minute buckets. Cache misses of these four methods share a limit of 20 requests per 60 seconds per account: going over it is 429 RATE_LIMITED.

Analytics

Network.Analytics(ctx, appID, start, end, filters) returns traffic totals and breakdowns as a *NetworkAnalytics. It returns nil (and a nil error) for a window with no traffic. Pass an empty squarecloud.AnalyticsFilters{} for no filters.
The breakdowns are Countries, Devices, OS, Browsers, Protocols, Methods, Paths, Referers, Providers, IPs, StatusCodes, Bots and ContentTypes (JSON countries, …, status_codes, bots, content_types). Each bucket has Type, Visits, Requests and Bytes (int64).

Filters

Filters narrow every breakdown. Each takes the exact Type value of its breakdown. An empty field is not sent:
An invalid filter is 400 INVALID_FILTER.

Errors

Network.Errors(ctx, appID, start, end, include4xx) returns the 5xx responses of the window, plus 4xx when include4xx is true. It returns nil for an empty window.

Request logs

Network.Logs(ctx, appID, start, end) returns individual requests with client, request and response details. Available on Pro and Enterprise plans (403 UPGRADE_REQUIRED otherwise).
Fields the API may send as null are pointers (Client.IP, Client.Country, Request.Query, Request.Referer, Response.Cache, …).

Performance

Network.Performance(ctx, appID, start, end) returns latency percentiles (P50, P95, P99, in ms) at the edge and at the origin, by country, by location and for the slowest paths. It returns nil for an empty window. Available on Pro and Enterprise plans. Each percentile is a *float64, nil when there were no requests to measure:

DNS

Network.DNS(ctx, appID) returns the DNS records your custom domain needs, with their status. Without a custom domain it is 400 NO_CUSTOM_DOMAIN.

Custom domain

Network.SetDomain(ctx, appID, domain) attaches a custom domain (Standard plan and up). Pass "@" to remove it.

Purging the cache

Network.PurgeCache(ctx, appID) clears the app’s edge cache. It is limited to one purge every 60 seconds (429 KEEP_CALM).

Errors of the analytics methods

Next steps

Realtime

Stream live logs and status.

Network API reference

The REST endpoints behind these methods.

Edge analytics from the CLI

The same actions from the terminal.