How to Use the API
Prerequisites
Ensure you have:
- A valid API key, which can be generated in your dashboard.
Endpoint Descriptions
POST https://imageurl.dev/api/upload
Handles the uploading of images via URLs to your own secure vault.
POST https://imageurl.dev/api/base64
Handles the uploading of images via Base64-encoded strings to your own secure vault.
Request Parameters
For both endpoints, the following parameters are required:
- folderName (
string
): The name of the folder or container where images will be stored. - imageFormat (
string
): The desired format for the images (e.g.,"png"
,"jpeg"
).
For /api/upload
- urls (
Array of strings
): A list of URLs pointing to the images to be uploaded.
For /api/base64
- base64Strings (
Array of strings
): A list of Base64-encoded strings representing the images to be uploaded.
Headers
- Authorization:
Bearer [token]
- A valid API token must be included in the request headers for both endpoints.
Example Usage with TypeScript
Below are examples showing how to structure requests for both the /api/upload
and /api/base64
endpoints.
Example 1: Uploading Images via URLs (/api/upload
)
Use this example to upload images by passing URLs:
import axios from "axios";
async function uploadImagesByUrl() {
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;
return responseData.uploadedUrls;
} catch (error) {
console.error("Error uploading image via URL:", error);
}
}