The Get Pronto SDK is written in TypeScript and provides comprehensive type definitions for all its features. This page documents the main types and interfaces you'll encounter when using the SDK.
Configuration options for initializing the Get Pronto client
interface ClientConfig {
/** Your Get Pronto API key */
apiKey: string;
/** Base URL for API requests. Defaults to https://api.getpronto.io/v1 */
baseUrl?: string;
/** Request timeout in milliseconds */
timeout?: number;
/** Number of retries for failed requests */
retries?: number;
/** Additional headers to include in all requests */
headers?: Record<string, string>;
}import GetProntoClient from "getpronto-sdk";
const client = new GetProntoClient({
apiKey: "your_api_key",
});Metadata for files stored in Get Pronto
interface FileMetadata {
/** Unique identifier for the file */
id: string;
/** Name of the file */
name: string;
/** Secure URL for file access with authentication */
secureUrl: string;
/** Secure URL for thumbnail access with authentication */
secureThumbnailUrl: string;
/** Raw URL for public file access */
rawUrl: string;
/** Formatted file type */
type: string;
/** Raw MIME type */
rawType: string;
/** Formatted file size (e.g., "1.5 MB") */
size: string;
/** File size in bytes */
rawSize: number;
/** Formatted update timestamp */
updated: string;
/** Raw update timestamp */
rawUpdated: string;
/** ID of the folder the file belongs to, or null */
folderId: string | null;
}// Example response from file upload
const result = await client.files.upload(file);
const metadata: FileMetadata = result.data;
console.log(metadata.secureUrl); // Authenticated URL
console.log(metadata.rawSize); // Size in bytes
console.log(metadata.type); // Formatted type (e.g., "PDF")Structure for paginated API responses
interface PaginatedResponse<T> {
/** Array of files for the current page */
files: T[];
/** Pagination metadata */
pagination: {
/** Current page number */
page: number;
/** Number of items per page */
pageSize: number;
/** Total number of items across all pages */
totalCount: number;
/** Total number of pages */
totalPages: number;
};
}// List files with pagination
const response = await client.files.list({
page: 2,
pageSize: 50
});
const files: FileMetadata[] = response.data.files;
const { totalPages } = response.data.pagination;Standard wrapper for API responses
interface APIResponse<T> {
/** Response data */
data: T;
/** Response status code */
status: number;
/** Response headers */
headers?: Record<string, string>;
}// Example API response handling
const response = await client.files.get(fileId);
const file: FileMetadata = response.data;
const status: number = response.status;Types related to image transformation options
// Resize fit options
type ImageFit = "cover" | "contain" | "fill" | "inside" | "outside";
// Supported output formats
type ImageFormat = "jpeg" | "jpg" | "png" | "webp" | "avif";
// Full transformation options
interface TransformOptions {
/** Target width in pixels (1-5000) */
w?: number;
/** Target height in pixels (1-5000) */
h?: number;
/** How the image should fit the target dimensions */
fit?: ImageFit;
/** Output quality (1-100) */
q?: number;
/** Gaussian blur radius (0.3-1000) */
blur?: number;
/** Apply sharpening */
sharp?: boolean;
/** Convert to grayscale */
gray?: boolean;
/** Rotation angle (-360 to 360) */
rot?: number;
/** Border width and color (e.g., "5_FF0000") */
border?: string;
/** Crop coordinates (e.g., "100,100,500,500") */
crop?: string;
/** Output format */
format?: ImageFormat;
}// Example image transformation
const url = await client.images
.transform(fileId)
.resize(800, 600, "contain")
.quality(90)
.format("webp")
.toURL();Error class thrown by the SDK when API requests fail
class APIError extends Error {
/** HTTP status code */
status: number;
/** HTTP status text */
statusText: string;
/** Response headers */
headers: Record<string, string>;
/** Original response body */
body: any;
}import { APIError } from "getpronto-sdk/core/http-client";
try {
await client.files.upload(file);
} catch (error) {
if (error.name === "APIError") {
console.error("API Error:", error.message);
console.error("Status:", error.status);
console.error("Body:", error.body);
}
}All types are available for import from the SDK package:
import type {
ClientConfig,
FileMetadata,
PaginatedResponse,
APIResponse,
ImageFit,
ImageFormat,
TransformOptions,
} from "getpronto-sdk";Continue exploring our documentation with these related topics: