General
Integrations
How to
Configuration
APIBeta
Sites
The Site resource represents a website tracked by Panelbear. You can optionally add the analytics snippet to multiple websites, and Panelbear will aggregate the metrics across them (eg. example.com
and docs.example.com
).
How you group your analytics is completely up to you. Panelbear will anonymize visitors per Site ID (incl. all websites you add under the same ID), but never across multiple unrelated sites.
Available endpoints
- List: List all Sites owned by you.
- Create: Create a new Site.
- Retrieve: Retrieve the data for a Site.
- Update: Update a the data for a Site.
- Delete: Delete a Site, and all of it's analytics data.
The Site object
Field | Type | Description |
---|---|---|
site_id | string | Unique identifier for this site. |
name | string | Display name for this site. |
allowed_origins | string | A list of allowed origins for this site. |
share_access | enum | Controls if the analytics for this site are publicly accessible. Possible values: public , private . |
share_id | string | The ID for public dashboard access. The share_access field must be set to public . |
date_created | datetime | Date and time when this site was created (ISO 8601 format). |
date_modified | datetime | Date and time when this site was last modified (ISO 8601 format). |
List all Sites
GET /v1/sites
Register a new Site on your account. This endpoint responds with 200 - Success if successful, and will include a paginated list of Sites as a JSON body.
Query Parameters
Field | Type | Description |
---|---|---|
search | string | A search string to filter the list of sites by name. optional |
page | integer | The page number. Default: 1 . optional |
page_size | integer | The number of items to include per page. Min. value: 5 , max. value: 100 . Default: 10 . optional |
Examples
List all sites. Note this response is paginated to avoid very large responses. You can request more pages via query parameters. For example: ?page=2
for the second page of results, if available. The page_count
field in the response metadata tells you how many result pages are available.
$ curl -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites" < HTTP/1.1 200 OK < Content-Type: application/json { "page": 1, "page_size": 10, "page_count": 1, "event_count": 2, "data": [ { "site_id": "ABC-xxx-xxx", "name": "The Honeyjar", "allowed_origins": [], "share_access": "private", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" }, { "site_id": "ABC-xxx-xxx", "name": "ACME Website", "allowed_origins": [], "share_access": "private", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" } ] }
Create a Site
POST /v1/sites
Register a new Site on your account. This endpoint responds with 201 - Created if successful, and will include the newly created Site as a JSON body.
JSON Parameters
Field | Type | Description |
---|---|---|
name | string | Display name for this site. required |
allowed_origins | string | A list of allowed origins for this site. optional |
share_access | enum | Controls if the analytics for this site are publicly accessible. Possible values: public , private . Default: private . optional |
Examples
The following request creates a site with the display name "The Honeyjar".
$ curl -X POST -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites" -d '{ "name": "The Honeyjar" }' < HTTP/1.1 201 Created < Content-Type: application/json { "site_id": "ABC-xxx-xxx", "name": "The Honeyjar", "allowed_origins": [], "share_access": "private", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" }
Creating a site with publicly accessible stats.
$ curl -X POST -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites" -d '{ "name": "The Honeyjar", "share_access": "public" }' < HTTP/1.1 201 Created < Content-Type: application/json { "site_id": "ABC-xxx-xxx", "name": "The Honeyjar", "allowed_origins": [], "share_access": "public", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" }
Retrieve a Site
GET /v1/sites/<SITE_ID>
Get the data for a specific Site. This endpoint responds with 200 - Success if successful.
Examples
Retrieve one Site by its ID.
$ curl -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites/<SITE_ID>" < HTTP/1.1 200 OK < Content-Type: application/json { "site_id": "ABC-xxx-xxx", "name": "The Honeyjar", "allowed_origins": [], "share_access": "private", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" }
Update a Site
PATCH /v1/sites/<SITE_ID>
Updates one or more fields on a Site. This endpoint responds with 200 - Success if successful, and will include the updated Site as a JSON body.
JSON Parameters
Field | Type | Description |
---|---|---|
name | string | Display name for this site. optional |
allowed_origins | string | A list of allowed origins for this site. optional |
share_access | enum | Controls if the analytics for this site are publicly accessible. Possible values: public , private . Default: private . optional |
Examples
Update a Site's display name to "ACME Website":
$ curl -X PATCH -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites/<SITE_ID>" -d '{ "name": "ACME Website" }' < HTTP/1.1 200 OK < Content-Type: application/json { "site_id": "ABC-xxx-xxx", "name": "ACME Website", "allowed_origins": [], "share_access": "private", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" }
Update the list of allowed origins for a site:
$ curl -X PATCH -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites/<SITE_ID>" -d '{ "allowed_origins": ["example.panelbear.com", "panelbear.com"] }' < HTTP/1.1 200 OK < Content-Type: application/json { "site_id": "ABC-xxx-xxx", "name": "ACME Website", "allowed_origins": [ "example.panelbear.com", "panelbear.com" ], "share_access": "private", "share_id": "xxx-xxxx-xxxx-xxx", "date_created": "2021-01-01T00:00:00Z", "date_modified": "2021-01-01T00:00:00Z" }
Delete a Site
DELETE /v1/sites/<SITE_ID>
Request to delete a Site and all of its data. This endpoint responds with 204 - No Content if successful.
Important: the analytics data for this site will be destroyed too. If you made this operation by mistake, please contact support as soon as possible, we might be able to undo this operation if you reach out within 24 hours.
Examples
Retrieve one Site by its ID.
$ curl -X DELETE -H "Authorization: Bearer <TOKEN>" \ -H "Content-type: application/json" \ "https://api.panelbear.com/v1/sites/<SITE_ID>" < HTTP/1.1 204 No Content < Content-Type: application/json # Response body is empty