TypeScript SDK
Install and start using the TypeScript SDK.
Intro
The Cloudinary API v1.1 SDK provides access to the Cloudinary API v1.1 REST APIs.
Installation
The SDK compiles to dist/ before it can be referenced — run its build script once in the SDK folder, then add it to your project by path:
npm install <path-to-sdk>Quick Start
Create one client and reuse it. Configure its behaviour through ClientOptions.
import { CloudinaryApiV11Client, PkceMethod, ServerEnvironment } from "cloudinary-api-v1-1";
const client = new CloudinaryApiV11Client({
serverEnvironment: ServerEnvironment.Production,
basicAuth: { username: "YOUR_USERNAME", password: "YOUR_PASSWORD" },
oauth2: {
clientId: "YOUR_CLIENT_ID",
redirectUri: "YOUR_REDIRECT_URI",
pkce: PkceMethod.S256,
promptForAuthorizationCode: (authorizationUrl, signal) => Promise.resolve("YOUR_AUTHORIZATION_CODE"),
},
});Nothing in ClientOptions is required — new CloudinaryApiV11Client() compiles — and each option left out falls back to its default. serverEnvironment is spelled out above so the environment a call reaches is visible where the client is built rather than inherited silently.
From CommonJS
The package ships both dialects from a single entry, so require works with full types. In a TypeScript CommonJS file use the import ... = require(...) form — a plain destructuring require runs fine but gives you any.
import sdk = require("cloudinary-api-v1-1");
const client = new sdk.CloudinaryApiV11Client({
serverEnvironment: sdk.ServerEnvironment.Production,
basicAuth: { username: "YOUR_USERNAME", password: "YOUR_PASSWORD" },
oauth2: {
clientId: "YOUR_CLIENT_ID",
redirectUri: "YOUR_REDIRECT_URI",
pkce: sdk.PkceMethod.S256,
promptForAuthorizationCode: (authorizationUrl, signal) => Promise.resolve("YOUR_AUTHORIZATION_CODE"),
},
});