Skip to content

Instantly share code, notes, and snippets.

@rebeccastandig
Last active January 4, 2016 07:29
Show Gist options
  • Select an option

  • Save rebeccastandig/8589004 to your computer and use it in GitHub Desktop.

Select an option

Save rebeccastandig/8589004 to your computer and use it in GitHub Desktop.
Quick Python script to delete all of your Keen IO event collections. Note: I have the script print out the response when you run a delete so you can see if it returns a 204. If not, something's wrong :) I'd just put some print statements in there and check to make sure it's on the project you want, etc, before actually deleting.
# -*- coding: utf-8 -*-
import requests, json
master_key = 'your_keen_master_key'
def get_events():
return requests.get("https://api.keen.io/3.0/projects?api_key=your_keen_master_key").json()
def del_events():
json_data = get_events()
json_data = json_data[0]
events = json_data['events']
urls_to_del = []
for item in events:
# print item['name']
api_url = "https://api.keen.io%s?api_key=%s" %(item['url'], master_key)
urls_to_del.append(api_url)
for url in urls_to_del:
# print url
delete = requests.delete(url)
print delete
del_events()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment