What is an API?
An API is an easy way for developers to interact with web platforms and services across the internet. Our API enables developers to interface directly with the Playwire Platform via code to accomplish tasks such as:
- Get videos from a Publisher
- Create, update and delete videos
- Get playlists from a particular publisher
- Interact with the Playwire Sandbox

1
Find Your API Token:
To get started, you will need some programming experience and an understanding of how to interact with an API. You will also need to find your API Token located in the Playwire Dashboard.
- Click the “Account” menu on the top right
- Click “Edit User” from the dropdown (A)
- Click the “Details” tab (B)
- Your “API Token” should appear as a long string of letters and numbers (C)
- Copy and paste your API Token in a safe and secure location

2
Make a Test API Call:
- Visit our API Explorer page or use the API Client* of your choice
- Find the API Endpoint you want to use. For our example, we will be using the “/videos/count.json” API Endpoint
- Paste your API token into either the “Intergi-Access-Token” or “token” field
- Click the “Try it out!” button
- If you enter an invalid API Token, you will receive a 401 Response Code
- If you enter a valid API Token, you will receive a 200 Response Code and a Response Body showing the count of how many videos have been uploaded to your account
API Client*
Use your browser, an API Client such as Postman or the Playwire API Explorer to make requests with the programming language of your choice using the examples below to make calls to our API.

Simple Code Examples
Follow the code examples below to make a simple HTTP request to our API with the programming language you are most comfortable with. When you are done looking over example, scroll down to the API Explorer to more advanced information about the Playwire Platform API.
Requests using cURL
Open up your command line tool such as Command Prompt in Windows or Terminal for Mac and Linux
- Form a URL call starting with the endpoint of your choice
- In our example we are using the /videos.json API endpoint
- Visit our API Explorer page to find the endpoint and parameters you need
Code Example
# GET request, response will return all videos for a publisher curl --request GET 'http://phoenix.playwire.com/api/videos.json?token=**YOUR_TOKEN_HERE**' # POST request, add video object to a publishers account curl --request POST 'http://phoenix.playwire.com/api/videos.json?token=**YOUR_TOKEN_HERE**&video[name]=test&video[source_url]=**SOURCE_VIDEO_URL**&video[category_id]=2' # PUT request, update the record of a previously uploaded video object to a publishers account curl --request PUT 'http://phoenix.playwire.com/api/videos.json?token=**YOUR_TOKEN_HERE**&video[name]=test&video[source_url]=**SOURCE_VIDEO_URL**&video[category_id]=2' # DELETE request, deletes the record of a previously uploaded video object to a publishers account curl --request DELETE 'http://phoenix.playwire.com/api/videos.json?token=**YOUR_TOKEN_HERE**&**ID_OF_VIDEO**'
Requests with Javascript
Open up your favorite text editor or IDE and create a new HTML document.
- Form a URL call starting with the endpoint of your choice
- In our example we are using the /videos/count.json API endpoint
- Visit our API Explorer page to find the endpoint and parameters you need
Code Example
<!DOCTYPE html> <html> <head> <title>Playwire API Example - Javascript</title> </head> <body> <h2>Playwire API Example - Javascript</h2> <button type="button" onclick="getVideos()">Get Video Count</button> <div id="resultsDiv" style="margin-top:40px;"></div> <script type="text/javascript"> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("resultsDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","http://phoenix.playwire.com/api/videos/count.json?token=**YOUR_API_TOKEN_HERE**",true); xmlhttp.send(); } </script> </body> </html>
Requests with jQuery
Open up your favorite text editor or IDE and create a new HTML document.
- Form a URL call starting with the endpoint of your choice
- In our example we are using the /videos/count.json API endpoint
- Visit our API Explorer page to find the endpoint and parameters you need
Code Example
<!DOCTYPE html> <html> <head> <title>Playwire API Example - jQuery</title> </head> <body> <h2>Playwire API Example - jQuery</h2> <button type="button" id="getVideos">Get Video Count</button> <div id="resultsDiv" style="margin-top:40px;"></div> <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script type="text/javascript"> var $ = jQuery; $('#getVideos').click(function(){ var json = $.getJSON("http://phoenix.playwire.com/api/videos/count.json?token=**YOUR_API_TOKEN_HERE**", function(response, status, jqXHR){ console.log(jqXHR.responseText); $('#resultsDiv').html(jqXHR.responseText); } ); }); </script> </body> </html>
Requests with PHP
Open up your favorite text editor or IDE and create a new PHP file.
- Form a URL call starting with the endpoint of your choice
- In our example we are using the /videos/count.json API endpoint
- Visit our API Explorer page to find the endpoint and parameters you need
- Try the Playwire PHP Client for an easy way interact with the Playwire API.
Code Example
<?php $jsonurl = "http://phoenix.playwire.com/api/videos/count.json?token=**YOUR_API_TOKEN_HERE**"; $json = file_get_contents($jsonurl); var_dump(json_decode($json)); ?>
Requests with Ruby
Open up your favorite text editor or IDE and create a new Ruby file. You can also use the Interactive Ruby Shell via the command line interface of your choices.
- Form a URL call starting with the endpoint of your choice
- In our example we are using the /videos/count.json API endpoint
- Visit our API Explorer page to find the endpoint and parameters you need
Important
You MUST have Rails Server running if you are not using the Rails Interactive Shell
Code Example
url = URI.parse('http://phoenix.playwire.com/api/videos/count.json?token=**YOUR_API_TOKEN_HERE**') req = Net::HTTP::Get.new(url.to_s) res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } puts res.body
Using the Playwire API Explorer
Click the operation of your choice to explore it’s model and model schema. There is also a built in API Client in each operation to make test API calls with your API Token. GET, POST, PUT and DELETE HTTP Methods are availabe with the API Playwire.
Get
Method
Used to retrieve information. For example, if you want to GET back a list of videos from a publisher.
Post
Method
Used to create information. For example, if you want to POST a new video to a publishers account.
Put
Method
Used to update information. For example, if you want to PUT an updated video to a publisher.
Delete
Method
Used to remove information. For example, if you want to DELETE a video from a publisher account.