Skip to main content

'GoatCounter' analytics for the CLI, written in Python

Project description

GoatPie

Build

"GoatCounter" analytics for the CLI, written in Python - get it?

Screenshot

Installation

It's available from PyPi using pip:

pip install goatpie

Getting started

Using this library is straightforward.

Commandline

Pretty much self-explanatory - otherwise, --help is your friend:

$ goatpie --help
Usage: goatpie [OPTIONS] URL

  Provides 'Goatcounter' statistics for URL

Options:
  -u, --update         Forces update of local database
  -l, --limit INTEGER  Shows visits & pageviews for the last XY days
  --version            Show the version and exit.
  --help               Show this message and exit.

Package

The underlying module may also be used directly:

from goatpie import GoatPie

# Initialize it
obj = GoatPie(url, token)

# Optionally with `data_dir` (SQLite database, config, etc)
obj = GoatPie(url, token, data_dir)

# Update database
# (1) Last update not before one hour (in seconds)
obj.update(3600)

# (2) Force database update
obj.update(0)

# Get pageviews as `pandas.DataFrame` (last seven days)
print(obj.get_pageviews(7))

#           Day  Pageviews
# 0  2022-08-28          1
# 1  2022-08-27         13
# 2  2022-08-26         20
# 3  2022-08-25         35
# 4  2022-08-24         84
# 5  2022-08-23         64
# 6  2022-08-22         23

Configuration

Besides CLI options (see goatpie --help) you may also configure options (currently only minimum update interval) inside ~/.config/goatpie/config.ini like so:

[DEFAULT]
interval = 3600

[stats.example.com]
interval = 0  # force updates

When first connecting to a 'GoatCounter' domain (such as stats.example.com), you are asked to store your token, in which case your configuration might look like this:

[DEFAULT]
interval = 3600

[stats.example.com]
interval = 0  # force updates
token = my-s3cr3t-t0k3n

[stats.another-example.com]
interval = 1800  # half hour
token = my-0th3r-s3cr3t-t0k3n

Note: Section headers are named after the GoatCounter API endpoints you are using, NOT the pages you are tracking!

Roadmap

  • Add tests
  • Add more tests
  • Add logger
  • Config file
  • Explain configuration

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goatpie-0.3.0.tar.gz (118.3 kB view details)

Uploaded Source

Built Distribution

goatpie-0.3.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file goatpie-0.3.0.tar.gz.

File metadata

  • Download URL: goatpie-0.3.0.tar.gz
  • Upload date:
  • Size: 118.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for goatpie-0.3.0.tar.gz
Algorithm Hash digest
SHA256 ee792569a4243689f551779881cbe88d43732781b1734022762fc97496c9044a
MD5 fc73866a8427ecde43ca106943eed11e
BLAKE2b-256 31cf43acdfce9dd0b72e2f9f9564445e489758bde99af8a15503ae6f953c2c0d

See more details on using hashes here.

File details

Details for the file goatpie-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: goatpie-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.1

File hashes

Hashes for goatpie-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4e7c3b14a3ff1909016f90eee1ad472859219a8f46f9706bf79fdf73f8a9699
MD5 0fcfaadd897566680cdd180e05c12cc4
BLAKE2b-256 1efce430e8a915c0ca1de59a987004b3066d2e5a61d43322af7783c805c304f7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page