API Reference
The Share Zip API lets you engage with Share Zip from your application or system through developer friendly designed endpoints. It uses standard HTTP methods (POST, GET, etc.) and responds with JSON content.
The Share Zip API works without authentication.
This reference is organized by core parts of the Share Zip system, such as files.
Base URL
For API updates that would break existing applications, the next version will be released. The previous versions remain valid.
Upload a file
When you upload a file to Share Zip via the API, more information about the file is returned, such as the url or the id, which you can then save.
To upload a file, first, extract the file's metadata (filename and size) and send a POST request to https://share.zip/api/fileupload
<?php
$url = "https://share.zip/api/fileupload";
$file_path = "accordion.png";
$filename = basename($file_path);
$size = filesize($file_path);
$hash = md5_file($file_path);
$data = [
"filename" => $filename,
"size" => $size,
"hash" => $hash,
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Accept: application/json",
]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
$responseData = json_decode($response, true);
if (curl_errno($ch)) {
echo "cURL error: " . curl_error($ch);
} else {
$responseData = json_decode($response, true);
if (!$responseData["success"]) {
echo "Error: " . $responseData["error"];
}
}
if (!empty($responseData["signedUrl"])) {
curl_close($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $responseData["signedUrl"]);
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_INFILE, fopen($file_path, "rb"));
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$checkData = [
"fileName" => $responseData["fileName"],
"mimeType" => $responseData["mimeType"],
"size" => $data["size"],
"hash" => $data["hash"],
];
$ch = curl_init("https://share.zip/api/filecheck");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($checkData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Accept: application/json",
]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$responseCheck = curl_exec($ch);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
}
echo $responseCheck;
curl_close($ch);
}