API version 1

  • We provide REST API to upload and delete models. To work with our API you will need an Api Token, which you can request using the support form (please select support as a subject), specifying your user email.

First API request

  • Before uploading or deleting models, you should check your API endpoint connection and set up your response handler with a simple GET request:
  • GET https://www.3dvieweronline.com/api/v1/models/?token={your-api-token}

  • CURL example:
  • curl "https://www.3dvieweronline.com/api/v1/models/?token={your-api-token}"
  • PHP example:
  • $token = 'your-api-token';
    $url = 'https://www.3dvieweronline.com/api/v1/models/?token=' . $token;

    //Set up the curl connection
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_CAINFO, 'Absolute/path/to/cacert.pem'); //absolute path to local certification file
    $result = curl_exec($ch);
    $err = curl_error($ch);
    curl_close($ch);
    if($err){
    echo 'cURL Error: ' . $err;
    } else {
    print_r(json_decode($result, true));
    }
  • Successful response:
  • { "success" : true, 
    "url" : "https://www.3dvieweronline.com/members/Id9bf31c7ff062936a96d3c8bd1f8f2ff3/3VCKJVxOIM45tzr",
    "modelID" : 1234 }
  • Response with errors:
  • { "success" : false, 
    "error" : "Error message" }
  • When you are establishing a SSL connection with curl, please be sure you have a valid CA certificate in your server or CURLOPT_SSL_VERIFYPEER will return an error. If not, you can download a mozilla certificate from here: http://curl.haxx.se/docs/caextract.html.

  • Even though not advisable for security reasons, you can disable all SSL checks using the following options:

  • curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    // no need to specify CURLOPT_CAINFO

Upload a model

  • Uploading a model requires a POST API request:
  • CURL example uploading a local file
  • curl -F userFile="@/path/to/your-model.stp" "https://www.3dvieweronline.com/api/v1/models/?token={your-api-token}"
  • CURL example uploading a file from URL
  • curl -F fileUrl="http://yoursite.com/your-model.stp" "https://www.3dvieweronline.com/api/v1/models/?token={your-api-token}"
  • PHP example uploading a local file
  • $token = 'your-api-token';
    $url = 'https://www.3dvieweronline.com/api/v1/models/?token=' . $token;
    $cFile = curl_file_create(realpath('./local/path/to/your-model.stp'));
    $post = array(
    "userFile" => $cFile
    );
    //Set up the curl connection
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_CAINFO, 'Absolute/path/to/cacert.pem'); //absolute path to local certification file
    curl_setopt($ch, CURLOPT_POST,true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    $result = curl_exec($ch);
    $err = curl_error($ch);
    curl_close($ch);
    if($err){
    echo 'cURL Error: ' . $err;
    } else {
    print_r(json_decode($result, true));
    }
  • PHP example uploading a a file from URL
  • $token = 'your-api-token';
    $url = 'https://www.3dvieweronline.com/api/v1/models/?token=' . $token;
    $fileUrl = 'http://yoursite.com/your-model.stp';
    $post = array(
    "fileUrl" => $fileUrl
    );
    //Set up the curl connection
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_CAINFO, 'Absolute/path/to/cacert.pem'); //absolute path to local certification file
    curl_setopt($ch, CURLOPT_POST,true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    $result = curl_exec($ch);
    $err = curl_error($ch);
    curl_close($ch);
    if($err){
    echo 'cURL Error: ' . $err;
    } else {
    print_r(json_decode($result, true));
    }
  • Successful response:
  • { "success" : true, 
    "url" : "https://www.3dvieweronline.com/members/Id9bf31c7ff062936a96d3c8bd1f8f2ff3/3VCKJVxOIM45tzr",
    "modelID" : 1234 }
  • Response with errors:
  • { "success" : false, 
    "error" : "Error message" }

Delete a model

  • You can delete a model with a DELETE API request knowing the modelID:
  • CURL example:
  • curl -X DELETE "https://www.3dvieweronline.com/api/v1/models/?token={your-api-token}&modelID={model-ID}"
  • PHP example deleting a model
  • $token = 'your-api-token';
    $modelID = 'your-model-ID';
    $url = 'https://www.3dvieweronline.com/api/v1/models/?token=' . $token . '&modelID=' . $modelID;

    //Set up the curl connection
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_CAINFO, 'Absolute/path/to/cacert.pem'); //absolute path to local certification file
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
    $result = curl_exec($ch);
    $err = curl_error($ch);
    curl_close($ch);
    if($err){
    echo 'cURL Error: ' . $err;
    } else {
    print_r(json_decode($result, true));
    }
  • Successful response:
  • { "success" : true, 
    "message" : "Model 1234 deleted"}
  • Response with errors:
  • { "success" : false, 
    "error" : "Error message" }