Skip to main content

API-dokumentation

Ladda upp bilder programmatiskt med vårt API

The ImageUpload.app API enables you to integrate image upload functionality into your web applications, mobile apps, or backend systems. With our RESTful API, you can upload images in seconds and integrate quickly using our JavaScript SDK. Create your API key and start using it right away!

Kom igång

1. Hämta din API-nyckel

Först måste du skapa ett konto och generera en API-token från din kontosida.

2. Gör API-förfrågningar

Inkludera din API-nyckel på något av följande sätt:

  • Authorization-header: Authorization: Bearer YOUR_API_KEY
  • Begärandekropp: key=YOUR_API_KEY
  • Frågeparameter: ?key=YOUR_API_KEY

Ladda upp bild

POST https://imageupload.app/api/1/upload
Parametrar
Parameter Typ Obligatorisk Beskrivning
key string Yes Din API-nyckel
images file Yes Bildfil(er) att ladda upp (max 15 filer, 32MB var)
Exempelbegäran (cURL)
curl -X POST "https://imageupload.app/api/1/upload" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "images=@/path/to/your/image.jpg"
Exempelbegäran (JavaScript)
const formData = new FormData();
formData.append('images', fileInput.files[0]);
formData.append('key', 'YOUR_API_KEY');

fetch('https://imageupload.app/api/1/upload', {
  method: 'POST',
  body: formData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Svar (en bild)
{
  "status": 200,
  "success": true,
  "data": {
    "id": "abc123def456",
    "title": "image.jpg",
    "url_viewer": "https://imageupload.app/i/abc123def456",
    "url": "https://i.imageupload.app/abc123def456.jpg",
    "display_url": "https://i.imageupload.app/abc123def456.jpg",
    "size": 102400,
    "time": 1698765432,
    "image": {
      "filename": "abc123def456.jpg",
      "name": "abc123def456",
      "mime": "image/jpeg",
      "extension": "jpg",
      "url": "https://i.imageupload.app/abc123def456.jpg"
    }
  }
}
Svar (flera bilder)
{
  "status": 200,
  "success": true,
  "data": {
    "images": [
      {
        "id": "abc123def456",
        "url": "https://i.imageupload.app/abc123def456.jpg",
        ...
      },
      {
        "id": "xyz789uvw012",
        "url": "https://i.imageupload.app/xyz789uvw012.jpg",
        ...
      }
    ],
    "count": 2
  }
}

Webbplatsskärmdump

POST https://imageupload.app/api/1/screenshot
Parametrar
Parameter Typ Obligatorisk Beskrivning
key string Yes Din API-nyckel
url string Yes The target website URL to capture.
preset string No Viewport preset identifier (e.g., desktop-1080p, iphone-14-pro, ipad-mini).
format string No png, jpeg (Default: png)
fullPage boolean No Set to true to capture the entire scrollable height of the webpage.
noAds boolean No Set to true to automatically hide common ad containers.
noCookie boolean No Set to true to automatically hide common cookie banner overlays.
colorScheme string No default, light, dark
zoom number No 0.5, 0.75, 1.0, 1.25, 1.5, 2.0
share boolean No Set to false to bypass host saving and receive a base64 encoded data URI instead.
Exempelbegäran (cURL)
curl -X POST "https://imageupload.app/api/1/screenshot" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://google.com",
    "preset": "desktop-1080p",
    "fullPage": true
  }'
Svar (delat)
{
  "status": 200,
  "success": true,
  "data": {
    "id": "abc123def456",
    "url_viewer": "https://imageupload.app/i/abc123def456",
    "url": "https://i.imageupload.app/abc123def456.png",
    "display_url": "https://i.imageupload.app/abc123def456.png",
    "shared": true
  }
}
Svar (privat/Base64)
{
  "status": 200,
  "success": true,
  "data": {
    "shared": false,
    "display_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
  }
}

JavaScript SDK

Vi tillhandahåller ett enkelt JavaScript-bibliotek för enkel integration på din webbplats.

Installation (CDN)
<script src="https://imageupload.app/imageupload-sdk.min.js"></script>
Installation (npm)

To install our upload widget as an npm package for module bundlers (like Webpack, Vite, or Rollup): image-uploader-widget

npm install image-uploader-widget
Grundläggande användning
// Initialize the SDK
const uploader = new ImageUploadApp('YOUR_API_KEY');

// Upload a single file
uploader.upload(fileInput.files[0])
  .then(response => {
    console.log('Upload successful:', response.url);
  })
  .catch(error => {
    console.error('Upload failed:', error);
  });
Ladda upp flera filer
const uploader = new ImageUploadApp('YOUR_API_KEY');

uploader.uploadMultiple(fileInput.files)
  .then(response => {
    console.log('Uploads successful:', response);
  })
  .catch(error => {
    console.error('Upload failed:', error);
  });
Skapa uppladdningswidget
const uploader = new ImageUploadApp('YOUR_API_KEY');

uploader.createUploadWidget({
  multiple: true,
  onStart: (files) => {
    console.log('Starting upload:', files.length, 'files');
  },
  onProgress: (percent) => {
    console.log('Upload progress:', percent + '%');
  },
  onSuccess: (response, files) => {
    console.log('Upload successful:', response);
  },
  onError: (error, files) => {
    console.error('Upload failed:', error);
  }
});
Fullständigt exempel
<!DOCTYPE html>
<html>
<head>
    <title>Image Upload Example</title>
    <script src="https://imageupload.app/imageupload-sdk.min.js"></script>
</head>
<body>
    <button id="uploadBtn">Upload Image</button>
    <div id="result"></div>

    <script>
        const uploader = new ImageUploadApp('YOUR_API_KEY');
        
        document.getElementById('uploadBtn').addEventListener('click', function() {
            uploader.createUploadWidget({
                multiple: false,
                onSuccess: (response) => {
                    document.getElementById('result').innerHTML = 
                        '<img src="' + response.url + '" style="max-width: 300px;">';
                },
                onError: (error) => {
                    alert('Upload failed: ' + error.message);
                }
            });
        });
    </script>
</body>
</html>

Felkoder

Kod Meddelande Beskrivning
100 No API key provided API-nyckel saknas i begäran
110 Invalid API key Den angivna API-nyckeln är inte giltig
120 User not found Användaren kopplad till API-nyckeln hittades inte
130 File size too large Filen överskrider den maximala storleksgränsen på 32MB
131 Too many files Maximalt 5 filer kan laddas upp samtidigt
140 No image file provided Ingen bildfil inkluderades i begäran
150 No files could be uploaded Alla filer misslyckades att ladda upp

Why Use ImageUpload.app API?

🚀 Fast & Reliable

Your images are uploaded instantly with our high-performance servers and remain accessible at all times.

🔒 Secure

Your API keys are stored securely and all requests are encrypted over HTTPS.

📱 Easy Integration

Easily integrate into any platform with our RESTful API and JavaScript SDK. Getting started is easy with detailed documentation and examples!