GoatCounter API documentation 0.1

Endpoints

count

POST /api/v0/count Count pageviews.

This can count one or more pageviews. Pageviews are not persisted immediatly, but persisted in the background every 10 seconds.

The maximum amount of pageviews per request is 100.

Errors will have the key set to the index of the pageview. Any pageviews not listed have been processed and shouldn't be sent again.

The response header has the X-Goatcounter-Memstore header set to the time of the last time pageviews were persisted to the database. This is useful if you want to (roughly) sync up with this.

Request body

Responses

export

GET /api/v0/export/{id} Get details about an export.

Responses

GET /api/v0/export/{id}/download Download an export file.

Responses

POST /api/v0/export Start a new export in the background.

This starts a new export in the background.

Request body

Responses

sites

GET /api/v0/sites List the current site and all additional sites.

Responses

GET /api/v0/sites/{id} Get information about a site.

Get all information about one site.

Responses

PATCH /api/v0/sites/{id} Update a site.

A POST request will *replace* the entire site with what's sent, blanking out any existing fields that may exist. A PATCH request will only update the fields that are sent.

Request body

Responses

POST /api/v0/sites/{id} Update a site.

A POST request will *replace* the entire site with what's sent, blanking out any existing fields that may exist. A PATCH request will only update the fields that are sent.

Request body

Responses

PUT /api/v0/sites Create a new site.

Request body

Responses

user

GET /api/v0/me Get information about the current user and API key.

Responses

Models

goatcounter.APIToken

name string

permissions

goatcounter.APITokenPermissions

count boolean

export boolean

site_read boolean

site_create boolean

site_update boolean

goatcounter.Export

id integer [readonly]

site_id integer [readonly]

start_from_hit_id integer

The hit ID this export was started from.

last_hit_id integer [readonly]

Last hit ID that was exported; can be used as start_from_hit_id.

created_at string [format: date-time] [readonly]

finished_at string [format: date-time] [readonly]

num_rows integer [readonly]

size string [readonly]

File size in MB.

hash string [readonly]

SHA256 hash.

error string [readonly]

Any errors that may have occured.

goatcounter.Site

id integer [readonly]

parent integer [readonly]

cname string

Custom domain, e.g. "stats.example.com"

cname_setup_at string [format: date-time] [readonly]

When the CNAME was verified.

code string

Domain code (arp242, which makes arp242.goatcounter.com)

link_domain string

Site domain for linking (www.arp242.net).

plan string

setttings

received_data boolean

Whether this site has received any data; will be true after the first pageview.

state string

created_at string [format: date-time]

updated_at string [format: date-time]

goatcounter.SiteSettings

public boolean

allow_counter boolean

twenty_four_hours boolean

sunday_starts_week boolean

date_format string

number_format string

data_retention integer

ignore_ips array [type: string]

timezone

campaigns array [type: string]

allow_admin boolean

limits

goatcounter.User

User entry.

id integer [readonly]

site integer [readonly]

email string

email_verified boolean [readonly]

totp_enabled boolean [readonly]

role string [readonly]

login_at string [format: date-time] [readonly]

reset_at string [format: date-time] [readonly]

created_at string [format: date-time] [readonly]

updated_at string [format: date-time] [readonly]

handlers.APICountRequest

no_sessions boolean

Don't try to count unique visitors; every pageview will be considered a "visit".

hits array [type: handlers.APICountRequestHit]

handlers.APICountRequestHit

path string [required]

Path of the pageview, or the event name.

title string

Page title, or some descriptive event title.

event boolean

Is this an event?

ref string

Referrer value, can be an URL (i.e. the Referal: header) or any string.

size array [type: number]

Screen size as "x,y,scaling"

query string

Query parameters for this pageview, used to get campaign parameters.

bot integer

Hint if this should be considered a bot; should be one of the JSBot*` constants from isbot; note the backend may override this if it detects a bot using another method. https://github.com/zgoat/isbot/blob/master/isbot.go#L28

user_agent string

User-Agent header.

location string

Location as ISO-3166-1 alpha2 string (e.g. NL, ID, etc.)

ip string

IP to get location from; not used if location is set. Also used for session generation.

created_at string [format: date-time]

Time this pageview should be recorded at; this can be in the past, but not in the future.

session string

Normally a session is based on hash(User-Agent+IP+salt), but if you don't send the IP address then we can't determine the session.

In those cases, you can store your own session identifiers and send them along. Note these will not be stored in the database as the sessionID (just as the hashes aren't), they're just used as a unique grouping identifier.

You can also just disable sessions entirely with NoSessions.

handlers.apiError

Error string

Errors

handlers.apiExportRequest

start_from_hit_id integer

Pagination cursor; only export hits with an ID greater than this.

handlers.apiSiteUpdateRequest

settings

cname string

link_domain string

handlers.apiSitesResponse

sites array [type: goatcounter.Site]

handlers.authError

Error string

handlers.meResponse

user

token

time.Location

A Location maps time instants to the zone in use at that time. Typically, the Location represents the collection of time offsets in use in a geographical area. For many Locations the time offset varies depending on whether daylight savings time is in use at the time instant.

tz.Zone

Zone represents a time zone.

CountryCode string

ID

Zone string

Asia/Makassar

Abbr string

WITA

CountryName string

Indonesia

Comments string

Borneo (east, south); Sulawesi/Celebes, Bali, Nusa Tengarra; Timor (west)