Using CKAN API I can delete a package (which marks it as inactive). But how can I purge it (delete it from the database) using API and NOT the admin interface?
The CKAN API doesn't currently support purging trash, but you can automate the admin trash purge form submission with a POST to /ckan-admin/trash with a payload of "purge-packages=purge", as an admin. Here's how in Python:
import urllib2
admin_api_key = '<my_admin_api_key>'
ckan_base = 'http://my_site.net'
request = urllib2.Request('{0}/ckan-admin/trash'.format(ckan_base))
request.add_header('Authorization', admin_api_key)
response = urllib2.urlopen(request, 'purge-packages=purge')
assert response.code == 200