# Software Licensing API - Example using Python

This document is a subset of the
[Software Licensing API document](https://easydigitaldownloads.com/docs/software-licensing-api/), which lists all features available via the API. The following is example code showcasing how to implement those features with Perl.

Request
-------

### Python 3:

```
import requests&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;payload = {&lt;br&gt;&lt;/br&gt;    &#039;edd_action&#039;: &#039;activate_license&#039;,  # Valid actions are activate_license, deactivate_license, get_version, check_license&lt;br&gt;&lt;/br&gt;    &#039;license&#039;: &#039;&#039;, &lt;br&gt;&lt;/br&gt;    &#039;item_id&#039;: &#039;&#039;, # The ID of the download on your store&lt;br&gt;&lt;/br&gt;    &#039;url&#039;: &#039;domain.com&#039; # If you have disabled URL checking in the settings, you do not need this&lt;br&gt;&lt;/br&gt;}&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;# Domain to send the request to.&lt;br&gt;&lt;/br&gt;r = requests.post(&quot;https://yoursite.com/&quot;, data=payload)&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;# Response JSON available via r.json()&lt;br&gt;&lt;/br&gt;print(r.json())&lt;br&gt;&lt;/br&gt;
```

### Python 2:

```
import httplib, urllib&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;params = urllib.urlencode({&lt;br&gt;&lt;/br&gt;    &#039;edd_action&#039; : &#039;activate_license&#039;, # Valid actions are activate_license, deactivate_license, get_version, check_license&lt;br&gt;&lt;/br&gt;    &#039;license&#039; : &#039;&#039;,&lt;br&gt;&lt;/br&gt;    &#039;item_id&#039; : &#039;&#039;, # The ID of the download on your store&lt;br&gt;&lt;/br&gt;    &#039;url&#039; : &#039;domain.com&#039; # If you have disabled URL checking in the settings, you do not need this&lt;br&gt;&lt;/br&gt;    })&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;headers = {&quot;Content-type&quot;: &quot;application/x-www-form-urlencoded&quot;, &quot;Accept&quot;: &quot;text/plain&quot;}&lt;br&gt;&lt;/br&gt;conn = httplib.HTTPConnection(&quot;domain.com:80&quot;) # You can use 80 (http) or 443 (https)&lt;br&gt;&lt;/br&gt;conn.request(&quot;POST&quot;, &quot;/&quot;, params, headers) # /edd-sl is the Software Licensing API endpoint&lt;br&gt;&lt;/br&gt;response = conn.getresponse()&lt;br&gt;&lt;/br&gt;# You should check response.status for a `200` before proceeding with parsing the data for&lt;br&gt;&lt;/br&gt;# a Software Licensing response&lt;br&gt;&lt;/br&gt;slData = response.read()&lt;br&gt;&lt;/br&gt;# slData now contains a string in JSON format, to handle with however prefer&lt;br&gt;&lt;/br&gt;print slData&lt;br&gt;&lt;/br&gt;conn.close()&lt;br&gt;&lt;/br&gt;
```

Response
--------

A response to the above query would be a JSON formatted string that would look something like this:

```
{
	&quot;license&quot;: &quot;valid&quot;,
	&quot;item_name&quot;: &quot;EDD Product name&quot;,
	&quot;expires&quot;: &quot;2014-10-23 00:00:00&quot;,
	&quot;payment_id&quot;: 54224,
	&quot;customer_name&quot;: &quot;John Doe&quot;,
	&quot;customer_email&quot;: &quot;john@sample.com&quot;
}
```