canva-sdk-patterns

Featured

Apply production-ready Canva Connect API client patterns for TypeScript and Python. Use when building a reusable API client, implementing token refresh, or establishing team coding standards for Canva integrations. Trigger with phrases like "canva client patterns", "canva best practices", "canva code patterns", "canva API wrapper", "canva TypeScript client".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Canva SDK Patterns ## Overview Production-ready patterns for wrapping the Canva Connect REST API. There is no official SDK — all integrations use `fetch` against `api.canva.com/rest/v1/*` with OAuth Bearer tokens. These patterns add automatic token refresh, retry logic, type safety, and multi-tenant support. ## Prerequisites - Completed `canva-install-auth` setup - Understanding of OAuth 2.0 token lifecycle - TypeScript 5+ project (or Python 3.10+) ## Pattern 1: Type-Safe Client with Auto Token Refresh ```typescript // src/canva/client.ts interface CanvaTokens { accessToken: string; refreshToken: string; expiresAt: number; // Unix ms } interface CanvaClientConfig { clientId: string; clientSecret: string; tokens: CanvaTokens; onTokenRefresh?: (tokens: CanvaTokens) => Promise<void>; // Persist new tokens } export class CanvaClient { private static BASE = 'https://api.canva.com/rest/v1'; private tokens: CanvaTokens; constructor(private config: CanvaClientConfig) { this.tokens = config.tokens; } async request<T = any>(path: string, init: RequestInit = {}): Promise<T> { // Auto-refresh if token expires within 5 minutes if (Date.now() > this.tokens.expiresAt - 300_000) { await this.refreshToken(); } const res = await fetch(`${CanvaClient.BASE}${path}`, { ...init, headers: { 'Authorization': `Bearer ${this.tokens.accessToken}`, 'Content-Type': 'application/json', ...init.headers, ...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category