Skip to content

Instantly share code, notes, and snippets.

@jamstooks
Created May 29, 2013 20:50
Show Gist options
  • Save jamstooks/5673734 to your computer and use it in GitHub Desktop.
Save jamstooks/5673734 to your computer and use it in GitHub Desktop.
Just a quick tool I put together to output the number of people on a site using the chartbeat api and the python requests library. Useful for GeekTool and other visualization tools.
#!/usr/bin/env python
"""
A quick tool to output the number of people on a site
using the chartbeat api and the python requests library
Useful for GeekTool and other visualization tools
"""
import requests
ENDPOINT_PREFIX = "http://api.chartbeat.com"
API_KEY = ""
HOST = ""
ENDPOINT = "/live/quickstats/v3/"
uri = "%s%s?apikey=%s&host=%s" % (
ENDPOINT_PREFIX, ENDPOINT, API_KEY, HOST)
r = requests.get(uri)
print "%s visitors" % r.json()['people']
@jamstooks
Copy link
Author

Note, you may need to use the full path to python when you are inserting the command into GeekTool because it may not be in the PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment