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 */
baseURL?: string;
}
import GetProntoClient from "@getpronto-io/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;
}
// Example response from file upload
const result = await client.files.upload(file);
const metadata: FileMetadata = result.data.file;
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 items for the current page */
items: 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.items;
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 = "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 structure returned by the API
interface APIError extends Error {
/** HTTP status code */
status: number;
/** Error message */
message: string;
/** Error code identifier */
code: string;
/** Additional error details */
details?: Record<string, any>;
/** Original response body */
body?: any;
}
try {
await client.files.upload(file);
} catch (error) {
if (error instanceof APIError) {
console.error("API Error:", error.message);
console.error("Status:", error.status);
console.error("Code:", error.code);
}
}
All types are available for import from the SDK package:
import type {
ClientConfig,
FileMetadata,
PaginatedResponse,
APIResponse,
ImageFit,
ImageFormat,
TransformOptions,
APIError
} from "@getpronto-io/getpronto-sdk";
Continue exploring our documentation with these related topics: