API Documentation: Code Examples

To speed up development, we've provided some examples of uploading with the API. Are we missing something that seems obvious? Tell us! support@wellcomemat.com.
curl: Upload
curl -F "key=$KEY" -F "secret=$SECRET" -F "media=@/tmp/filename.mp4" https://stage.wellcomemat.com/api/media/upload.php

PHP: Upload

$params = array(
    'key'           => $KEY,
    'secret'        => $SECRET,
    'title'         => $TITLE,
    'description'   => $DESCRIPTION,
    'media'         => '@/tmp/filename.mp4'

$json = post('media/upload', $params);
$obj = json_decode($json);

function post($path, $params) {
    $url = "https://stage.wellcomemat.com/api/$path.php";

    // Initiate url request and options.
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

    // Make request and get response.
    $r = curl_exec($ch);

    return $r;


Python: Query
import requests
import json

api_url = "https://stage.wellcomemat.com/api/media/query.php"
payload = {
    'key': KEY,
    'secret': SECRET
response = requests.post(api_url, data = payload)
content = json.loads(response.text)
print content