This guide will help you get started with Get Pronto's asset hosting service in just a few minutes. You'll learn how to set up your account, install the SDK, and perform basic file operations.
Important: Your API key will only be shown once. Make sure to copy it to a secure location. For more information on API keys, see our Authentication guide.
Install the Get Pronto SDK using npm or yarn:
# Using npm
npm install getpronto-sdk
# Using yarn
yarn add getpronto-sdkCreate and initialize a Get Pronto client with your API key. Use a secret key for server-side code or a public key for browser-side uploads:
import GetProntoClient from "getpronto-sdk";
// Server-side — full access
const client = new GetProntoClient({
apiKey: "pronto_sk_..."
});
// Or client-side — upload only (safe for browser)
const client = new GetProntoClient({
apiKey: "pronto_pk_..."
});Now that you have the client set up, let's upload a file:
try {
const result = await client.files.upload("./path/to/image.jpg");
console.log("File uploaded successfully:", result.data);
} catch (error) {
console.error("Upload failed:", error.message);
}Retrieve a list of your uploaded files:
try {
const response = await client.files.list();
console.log("Files:", response.data.files);
console.log("Pagination:", response.data.pagination);
} catch (error) {
console.error("Failed to list files:", error.message);
}Get Pronto allows you to transform images on-the-fly. Here's how to generate a URL for a resized image:
// Server-side: generate a transform URL with the SDK (requires secret key)
const fileId = "YOUR_FILE_ID";
const imageUrl = await client.images
.transform(fileId)
.resize(800, 600)
.grayscale()
.quality(90)
.toURL();
console.log("Transformed image URL:", imageUrl);
// Or use URL query parameters directly (works anywhere, no key needed):
// https://api.getpronto.io/v1/file/user-123/image.webp?w=800&h=600&gray=true&q=90Here's a complete example that ties everything together:
import GetProntoClient from "getpronto-sdk";
// Server-side example using a secret key
const client = new GetProntoClient({
apiKey: "pronto_sk_..."
});
async function uploadAndTransform() {
try {
// Upload a file
const uploadResult = await client.files.upload("./image.jpg");
console.log("File uploaded:", uploadResult.data);
// Get the file ID
const fileId = uploadResult.data.id;
// Generate a URL for the transformed image
const transformedUrl = await client.images
.transform(fileId)
.resize(300, 200)
.grayscale()
.toURL();
console.log("Transformed image URL:", transformedUrl);
// List all files
const listResult = await client.files.list();
console.log("Total files:", listResult.data.pagination.totalCount);
return {
originalFile: uploadResult.data,
transformedUrl
};
} catch (error) {
console.error("Error:", error.message);
}
}
// Run the example
uploadAndTransform();Continue exploring our documentation with these related topics: