# Software Licensing API - Example using Ruby

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 an example of code that showcases how to implement these features with Ruby.

### Request

```
require &#039;net/http&#039;&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;uri = URI(&#039;https://domain.com/&#039;)&lt;br&gt;&lt;/br&gt;req = Net::HTTP::Post.new(uri)&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;edd_action = &#039;check_license&#039; # Valid actions are activate_license, deactivate_license, get_version, check_license&lt;br&gt;&lt;/br&gt;license    = &#039;&#039;&lt;br&gt;&lt;/br&gt;item_id  = &#039;&#039; # The ID of the product on your store&lt;br&gt;&lt;/br&gt;url        = &#039;example.org&#039; # If you have disabled URL chaecking in the settings, you do not need this&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;req.set_form_data(&#039;edd_action&#039; =&gt; edd_action, &#039;license&#039; =&gt; license, &#039;item_id&#039; =&gt; item_id, &#039;url&#039; =&gt; url)&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;res = Net::HTTP.start(uri.hostname, uri.port) do |http|&lt;br&gt;&lt;/br&gt;  http.request(req)&lt;br&gt;&lt;/br&gt;end&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;case res&lt;br&gt;&lt;/br&gt;when Net::HTTPSuccess, Net::HTTPRedirection&lt;br&gt;&lt;/br&gt;  # check res.code for a 200 response, and then the response from the Software Licenseing API&lt;br&gt;&lt;/br&gt;  # will be located in res.body as a string of JSON&lt;br&gt;&lt;/br&gt;  puts res.body&lt;br&gt;&lt;/br&gt;else&lt;br&gt;&lt;/br&gt;  res.value&lt;br&gt;&lt;/br&gt;end&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;
}
```