API Documentation for Imageurl.dev
Introduction
Welcome to the Imageurl.dev API documentation. This API provides a streamlined, secure, and scalable solution for uploading, saving, and processing images from various sources. It simplifies image management for web applications, providing both Base64 image support and URL-based uploads.
- Supported Image Formats:
jpeg
,jpg
,png
,gif
,bmp
,webp
,tiff
- You can pass image URLs or Base64 strings in these supported file formats.
Why Use Imageurl.dev API?
- Web-Optimized: Reduce image sizes by up to 90% while preserving quality, ensuring faster web performance.
- Secure: API key-based authentication ensures that only authorized users can upload and manage images.
- Efficient: Automatically manages storage containers and optimizes uploads for fast processing.
- Scalable: Built to handle large-scale applications and high volumes of image uploads.
- Developer-Friendly: Simplifies complex storage operations and offers quick integration into applications.
How to Use the API
Prerequisites
Before using the API, ensure you have the following:
- A valid API key, which can be generated from your dashboard.
- A supported image URL or Base64 string ready for upload.
Image Upload Endpoints
This section describes the two key endpoints used for uploading images:
- /api/upload for uploading images via URL.
- /api/base64 for uploading images via Base64 strings.
/api/upload Endpoint
/api/base64 Endpoint
This endpoint handles the uploading and storage of images from URLs.
POST https://imageurl.dev/api/upload
POST https://imageurl.dev/api/base64
Request Parameters
- urls (
Array of strings
) - Required: A list of image URLs to be uploaded. - folderName (
string
) - Required: The name of the folder or container where the images will be stored. - imageFormat (
string
) - Required: The desired format for the exported images (e.g.,png
,jpeg
).
Headers
- Authorization:
Bearer [token]
- Required: A valid API token must be included in the request headers.
Example Usage for url
import axios from "axios";
async function uploadImage() {
try {
const data = {
urls: ["https://example.com/image.jpg"],
folderName: "MyApp",
imageFormat: "jpeg",
};
const response = await axios.post("https://imageurl.dev/api/upload", data, {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_TOKEN_HERE",
},
});
const responseData = response.data;
console.log("Uploaded Image URLs:", responseData.uploadedUrls);
return responseData.uploadedUrls;
} catch (error) {
console.error("Error uploading image:", error);
}
}
Example Usage for Base64
import axios from "axios";
async function uploadImagesByBase64() {
try {
const data = {
base64Strings: ["iVBORw0KGgoAAAANSUhEUgAA..."], // Truncated Base64 string
folderName: "MyApp",
imageFormat: "jpeg",
};
const response = await axios.post("https://imageurl.dev/api/base64", data, {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer YOUR_TOKEN_HERE",
},
});
const responseData = response.data;
return responseData.uploadedUrls;
} catch (error) {
console.error("Error uploading Base64 image:", error);
}
}