Skip to content

Instantly share code, notes, and snippets.

Last active July 5, 2022 01:18
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alexwlchan/4502860fd9ff014dc178 to your computer and use it in GitHub Desktop.
A Python script for finding untagged posts on Tumblr. See
#!/usr/bin/env python
import urllib2
import json
API_KEY = "abcdefg"
URL = "{host}/posts?api_key={key}".format(host=HOSTNAME, key=API_KEY)
def api_response(URL):
req = urllib2.urlopen(URL)
return json.loads(
# The Tumblr API returns posts in batches of 20, so first we need to
# work out how many such batches are required.
jsonresponse = api_response(URL)
post_count = jsonresponse["response"]["total_posts"]
increments = (post_count + 20) / 20
# For each batch of 20, get the results from the Tumblr API, get the
# posts and look for any which are untagged.
for i in range(increments):
jsonresponse = api_response("{url}&offset={count}".format(url=URL, count=i * 20))
posts = jsonresponse["response"]["posts"]
for post in posts:
if not post["tags"]:
print post["post_url"]
print "All finished!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment