API Documentation

Use our robust API to upload and manage your images

Quick Start

Upload an Image

curl -F "[email protected]" https://img.mrbean.dev/api/upload.php

Create Text Paste

curl -F "api_paste_code=Hello World" https://img.mrbean.dev/api/pastebin.php

API Reference

POST /api/upload.php

Upload files directly to the server.

Parameters

Name Description Required
file The file to upload Required

Example Request

curl -F "[email protected]" https://img.mrbean.dev/api/upload.php

Example Response

{
  "status": "ok",
  "hash": "y1b6hr.jpg",
  "url": "https://img.mrbean.dev/y1b6hr.jpg",
  "delete_code": "z0e1mdo8szxnauspxp2f080e4wd4ycf2",
  "delete_url": "https://img.mrbean.dev/delete_z0e1mdo8szxnauspxp2f080e4wd4ycf2/y1b6hr.jpg"
}

Error Response

{
  "status": "err",
  "reason": "Unsupported filetype"
}

GET /api/geturl.php

Upload content by providing a link to the content. If the URL is a webpage, it will save the HTML content as a text file.

Parameters

Name Description Required
url URL of the content to upload Required

Example Request

curl -s "https://img.mrbean.dev/api/geturl.php?url=https://xkcd.com"

Example Response (HTML Content)

{
  "status": "ok",
  "hash": "2mr2va.txt",
  "url": "https://img.mrbean.dev/2mr2va.txt",
  "filetype": "text",
  "delete_code": "aqxqlv3kqokxd15xpkqp8zjljpqerveu",
  "delete_url": "https://img.mrbean.dev/delete_aqxqlv3kqokxd15xpkqp8zjljpqerveu/2mr2va.txt"
}

Example Request (Media File)

curl "https://img.mrbean.dev/api/geturl.php?url=https://i.imgur.com/qQstLQt.mp4"

Example Response

{
  "status": "ok",
  "hash": "u0ni1m.mp4",
  "url": "https://img.mrbean.dev/u0ni1m.mp4",
  "filetype": "mp4",
  "delete_code": "aqxqlv3kqokxd15xpkqp8zjljpqerveu",
  "delete_url": "https://img.mrbean.dev/delete_aqxqlv3kqokxd15xpkqp8zjljpqerveu/u0ni1m.mp4"
}

Error Response

{
  "status": "err",
  "reason": "Unsupported filetype"
}

POST/GET /api/pastebin.php

This API can be used to directly post text. Server responds with the URL to the bin or with an error message.

Parameters

Name Description Required
api_paste_code The text content to paste Required

Example Request

curl -F "api_paste_code=Hello World" https://img.mrbean.dev/api/pastebin.php

Example Response

https://img.mrbean.dev/vekjy4e5rr.txt

GET /api/info.php

This API will get information about any given hash.

Parameters

Name Description Required
hash Hash of the file to get information about Required

Example Request

curl "https://img.mrbean.dev/api/info.php?hash=9k3rbw.mp4"

Example Response

{
  "status": "ok",
  "hash": "9k3rbw.mp4",
  "size_bytes": 2513225,
  "size_interpreted": "2.4 MB",
  "type": "video/mp4",
  "type_interpreted": "mp4"
}

POST /api/base64.php

Upload base64 encoded images to the server.

Parameters

Name Description Required
base64 The base64 encoded image data Required

Example Request

(echo -n "base64="; echo -n "data:image/jpeg;base64,$(base64 -w 0 test.jpg)") | \
curl --data @- https://img.mrbean.dev/api/base64.php

Example Response

{
  "status": "ok",
  "hash": "lpl119.jpg",
  "url": "https://img.mrbean.dev/lpl119.jpg",
  "filetype": "jpeg",
  "delete_code": "z0e1mdo8szxnauspxp2f080e4wd4ycf2",
  "delete_url": "https://img.mrbean.dev/delete_z0e1mdo8szxnauspxp2f080e4wd4ycf2/lpl119.jpg"
}

Code Samples

Upload an Image with PHP

function uploadImage($imagePath) {
    if (!file_exists($imagePath)) return false;
    
    $ch = curl_init('https://img.mrbean.dev/api/upload.php');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'file' => curl_file_create($imagePath)
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

$result = uploadImage('test.jpg');
echo $result['url']; // Outputs: https://img.mrbean.dev/y1b6hr.jpg

Create a Text Paste with PHP

function createTextPaste($text) {
    $ch = curl_init('https://img.mrbean.dev/api/pastebin.php');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'api_paste_code' => $text
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return $response;
}

$pasteUrl = createTextPaste('Hello World from PHP!');
echo $pasteUrl; // Outputs: https://img.mrbean.dev/vekjy4e5rr.txt

Upload from URL with PHP

function uploadFromUrl($url) {
    $encodedUrl = urlencode($url);
    $requestUrl = "https://img.mrbean.dev/api/geturl.php?url={$encodedUrl}";
    
    $ch = curl_init($requestUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

$result = uploadFromUrl('https://i.imgur.com/qQstLQt.mp4');
echo $result['url']; // Outputs: https://img.mrbean.dev/u0ni1m.mp4