Eph API and SDK are now open to the public

We’re delighted to announce that Eph API and SDK are now open to the public! This is a significant milestone that involved building:

  • Eph API with a fairly complex (and absolutely watertight) permissions model; some routes require no authentication (demo tracks on our website), some routes are only for Licensees’ application users (not Licensees or Publishers) and some routes return tracks or contributors with varying sets of properties (you can’t see the ‘internal name’ of contributors which aren’t under your control, but you can see all contributors when publishing a track)
  • 44 automated API tests
  • Eph SDK in Universal JavaScript with build process
  • 10 automated SDK tests
  • Extensive documentation, walkthrough and specification for Eph API and Eph SDK
  • A public sign up flow which is simple and compliant (Terms of Service/Disclosure agreements), automating API key provisioning and Euphoria access

As a Licensee, you can now bring all of Eph’s content to your application users. Use the SDK to get the track list and execute track Smart Contracts, which return a streamable URL you can play with HTML5 Audio. You could rebuild Euphoria from scratch and provide even better functionality and features.

As a Publisher, you can also now publish tracks on Eph. We are working on a visual interface for defining Smart Contracts (a JavaScript generator in one way or another), publishing tracks and managing contributors — publishers won’t need to use Eph API at all by February.

Eph has two short tracks that don’t require any authentication to play, so you can even use Eph API and SDK without signing up. Below, we’ve written a short guide on getting this working. Sign up to enjoy all of the content on Eph.

Try out Eph without signing up

For this guide, we presume you can know some basic JavaScript and HTML. If you’re not a developer, please read on; we’ve tried to make it easy as possible to see what’s happening.

We’re going to start out with some really basic HTML. This could be a website that already exists or an application which you want to play content on Eph:

<!DOCTYPE html>
<html>
<head>
<title>My Cool Application</title>
</head>
<body>
<p>Hello, World.</p>
</body>
</html>

Let’s add the Eph SDK. You can download the SDK and include it or just link to our hosted copy (easier and you’ll always have the latest version). Let’s add this into the <head> section:

<script src="https://euphoricadventur.es/sdk.js"></script>
To make sure this is working, open up your browser’s “DevTools” and check for a console message from the SDK.

After the SDK has loaded (window onload event), we’ll get the tracks on Eph. Remember, only the demo tracks will be returned because we haven’t signed up and provided an API key. Add this in to the <head> section:

<script>
window.onload = function () {
window.euphoricAdventuresSDK.getTracks()
.then(function (tracks) {
console.log('tracks', tracks)
})
}
</script>
Open up your browser’s “DevTools” to see the tracks.

Let’s play the first track (tracks[0] ). Add this below the console.log('tracks', tracks) line:

var result = window.euphoricAdventuresSDK.executeSmartContract(tracks[0].trackId, 'SoundAAC', tracks[0].compiledSmartContractCode, false)
var element = document.createElement('audio')
element.src = result.url
element.controls = true
document.body.appendChild(element)
element.play()

What’s going on here? Firstly, we’re running executeSmartContract with the track’s ID, desired format (AAC) and the Smart Contract’s code (the last argument false tells the SDK to actually execute the Smart Contract instead of simulating it).

Secondly, we (line by line):

  • create a HTML5 Audio element
  • set its source to the streamable URL returned by the Smart Contract execution
  • make it show some controls (play/pause)
  • append it to the HTML body element
  • play the track automatically

Can you hear the track? Amazing! If you think you made a mistake, here’s the full example:

<!DOCTYPE html>
<html>
<head>
<script src="https://euphoricadventur.es/sdk.js"></script>
<script>
window.onload = function () {
window.euphoricAdventuresSDK.setApiEndpointLocal()
window.euphoricAdventuresSDK.getTracks()
.then(function (tracks) {
var result = window.euphoricAdventuresSDK.executeSmartContract(tracks[0].trackId, 'SoundAAC', tracks[0].compiledSmartContractCode, false)
var element = document.createElement('audio')
element.src = result.url
element.controls = true
document.body.appendChild(element)
element.play()
})
}
</script>
</head>
<body>
</body>
</html>

For an in-depth explanation of how Eph works, and to see the full function and API docs, read our Integration Guide. Good luck — and make it count.