Application programming interface (API)

Commands in different content-types

The content of is available in a variety of different formats for you to do what you like with. Any page which contains a list of commands (such as the listings by tag, function or user) can be returned in a format of your choice through a simple change to the request URL.

For example, Use a URL of the form<command-set>/<format>/ Here, <command-set> is the URL component which specifies which set of commands to return. Possible values are:

  • browse/sort-by-votes - All commands sorted by votes
  • tagged/163/grep - Commands tagged with 'grep', sorted by date (the default sort order)
  • matching/ssh/c3No - Search results for the query 'ssh' (note that the final segment is a base64-encoding of the search query)

Also, <format> is one of the following:

plaintext Returns the content as plain text (Content-type: text/plain). Eg:
# by David Winterbottom

# coloured tail
tail -f FILE | perl -pe 's/KEYWORD/\e[1;31;43m$&\e[0m/g'

# Check version of DNS Server
nslookup -q=txt -class=CHAOS version.bind NS.PHX5.NEARLYFREESPEECH.NET

# Archive every file in /var/logs
find /var/logs -name * | xargs tar -jcpf logs_`date +%Y-%m-%e`.tar.bz2

# Search for all files that begin with . and delete them.
find ~/Desktop/ \( -regex '.*/\..*' \) -print -exec rm -Rf {} \;

# Uncompress a CSS file
cat somefile.css | awk '{gsub(/{|}|;/,"&\n"); print}' >> uncompressed.css

# resolve hostname to IP our vice versa with less output
resolveip -s

This content-type is best for working from the command-line. The format of the returned commands has also been chosen to be easily grep-able. Example commands for retrieving a set of commands are:

lynx -dump ""


curl ""
json Returns the content Javascript object notation (JSON). This is useful for writing javascript widgets (see the instructions on how to embed your commands on your blog or homepage).
[{ "id":"13", "command":"sudo !!", "summary":"Run the last command as root", "votes":"334", "url":"" }, { "id":"71", "command":"python -m SimpleHTTPServer", "summary":"Serve current directory tree at http://$HOSTNAME:8000/", "votes":"250", "url":"" }, { "id":"51", "command":"cd -", "summary":"change to the previous working directory", "votes":"179", "url":"" }, { "id":"1204", "command":":w !sudo tee %", "summary":"Save a file you edited in vim without the needed permissions", "votes":"151", "url":"" }, ... ]
rss Returns the content using the web feed format RSS XML (content-type: application/rss+xml).
<?xml version="1.0" encoding="utf-8"?> <rss xmlns:content="" version="2.0"> <channel> <title><![CDATA[All commands sorted by votes]]></title> <link></link> <description><![CDATA[A repository for the most elegant and useful UNIX commands. Great commands can be shared, discussed and voted on to provide a comprehensive resource for working from the command-line]]></description> <pubDate>Sat, 11 Jul 2009 16:09:33 +0000</pubDate> <generator>Zend Framework Zend_Feed</generator> <language>en-us</language> <docs></docs> <item> <title><![CDATA[Run the last command as root]]></title> <link></link> <guid></guid> <description><![CDATA[<code style="padding:5px; font-family:monospace; font-size:12pt">$ sudo !!</code> <div style=""><p>Useful when you forget to use sudo for a command. "!!" grabs the last run command.</p> (by <strong>root</strong>)</div> <ul style="list-style:none; padding: 0; margin: 0"> <li><a href="">View this command to comment, vote or add to favourites</a></li> <li><a href="/commands/by/root">View all commands by <strong>root</strong></a></li> </ul> <p><a href=""><img src="" alt=""/></a></p> <p>by David Winterbottom (<a href=""></a>)</p> ]]></description> <pubDate>Sat, 11 Jul 2009 16:09:33 +0000</pubDate> </item> ... </channel> </rss>

If you have any suggestions for how this API could be improved, please get in touch or suggest an improvement using the uservoice forums.