This should be a useful snippet for anyone that needs to do a lookup for a WordPress plugin’s latest available version number. I will be using this snippet to create a function in a larger WordPress environment operations script I have been developing for work.

#!/usr/bin/python
# Alex Rydzak - <[email protected]>
# import necessary libraries
import requests
#==========================================================================
# set plugin name (usually something-something- no extension on the end)
plugin = "akismet"
# hit the WordPress plugin information API for our plugin
wpquery = "http://api.wordpress.org/plugins/info/1.0/%s" % (plugin)
result = requests.get(wpquery)

# if the query was sucessful...
if str("200") in str(result):
	print "[*] Request to WordPress API worked..."
	# grab the first line of the result from the query
	grabfirst = result.content.splitlines()[0]
	# split the returned string on the " character
	grabcell = grabfirst.split('"')
	# print the plugin version
	print "[*] Latest plugin version for %s: %s" % (plugin,grabcell[13])
	
else:
	print "[*] Something bad happened. Maybe you didn't spell the plugin name right?"

Scroll to Top