npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tinyami-api

v1.0.10

Published

Official Node.js client for the Tinyami API

Readme

Tinyami Node.js Client

tinyami-node is the official Node.js client for the Tinyami API – a powerful image optimization service for developers.

With this package, you can easily upload images, trigger optimization, and check optimization status via Tinyami's REST API.


🚀 Features

  • Upload images to Tinyami
  • Optimize, convert, resize images by ID
  • Check image optimization status
  • Lightweight and easy-to-use
  • Written in TypeScript

🔐 Getting an API Key

To use this package, you’ll need a Tinyami API key.

  1. Go to https://tinyami.com
  2. Sign up or log in to your account
  3. Navigate to the https://tinyami.com/api-keys section
  4. Generate a new API key

Installation

npm install tinyami-api

Usage

import { TinyamiClient } from 'tinyami-api';

// Initialize the client
const client = new TinyamiClient({
  apiKey: 'your-api-key', // Your Tinyami API key
  // Optional configuration
  baseURL: 'https://api.tinyami.com', // Default
  timeout: 30000, // Default: 30 seconds
  maxRetries: 3, // Optional: Number of retry attempts
});

// Upload an image
const uploadResult = await client.uploadImage('/path/to/image.jpg');
console.log('Uploaded image ID:', uploadResult.image.id);

// Optimize the image
const optimizeResult = await client.optimizeImage(uploadResult.image.id);
console.log('Optimized image URL:', optimizeResult.optimized.preview_url);

// Check image status
const status = await client.getImageInfo(uploadResult.image.id);
console.log('Image status:', status.status);

// Delete the image
await client.deleteImage(uploadResult.image.id);

API Reference

TinyamiClient

The main client class for interacting with the Tinyami API.

Constructor

new TinyamiClient(config: TinyamiConfig)

Configuration options:

  • apiKey (required): Your Tinyami API key (X-Tinyami-Access-Token)
  • baseURL (optional): API base URL (default: 'https://api.tinyami.com')
  • timeout (optional): Request timeout in milliseconds (default: 30000)
  • maxRetries (optional): Number of retry attempts for failed requests (default: 3)

Methods

uploadImage(filePath: string): Promise

Uploads an image file to Tinyami. Supports large file uploads with proper FormData handling.

uploadImageFromUrl(url: string): Promise

Uploads an image url to Tinyami. Supports large file uploads with proper FormData handling.

optimizeImage(imageId: number): Promise

Optimizes a previously uploaded image.

getImageInfo(imageId: number): Promise

Gets the current status of an image.

deleteImage(imageId: number): Promise

Deletes an uploaded image.

getImagesList(page?: number, limit?: number): Promise

Gets a paginated list of images.

  • page: Page number (default: 1)
  • limit: Number of images per page (default: 20, max: 50)
convertImage(imageId: number, type: string): Promise

Converts an image to a different format.

  • imageId: ID of the image to convert
  • type: Target format (e.g., 'jpg', 'png', 'webp', 'avif')
resizeImage(imageId: number, method: string, width?: number, height?: number): Promise

Resizes an image using specified method and dimensions.

  • imageId: ID of the image to resize
  • method: Resizing method (e.g., 'scale', 'fit', 'cover', 'thumb')
  • width: Target width (optional)
  • height: Target height (optional)
getImageFormats(imageId: number): Promise

Gets all available formats for a specific image.

  • imageId: ID of the image
getImageVariants(imageId: number): Promise

Gets all variants of a specific image.

  • imageId: ID of the image
deleteImageFormat(imageId: number, formatId: string): Promise

Deletes a specific format of an image.

  • imageId: ID of the image
  • formatId: ID of the format to delete

Response Types

ImageUploadResponse

{
  status: string;
  msg: string;
  image: OriginalImageOut;
}

ImageOptimizeResponse

{
  msg: string;
  optimized: {
    id: number;
    original_image_id: number;
    format: string;
    size: number;
    s3_path: string;
    reduction: number;
    created_at: string;
    preview_url: string;
    download_url: string;
  }
}

ImageStatusResponse

{
  status: string;
  msg: string;
  image_info: OriginalImageOut;
}

ImageListResponse

{
  status: string;
  msg: string;
  images: OriginalImageOut[];
}

ImageConvertResponse

{
  status: string;
  msg: string;
  converted: VariantResponse;
}

ImageResizeResponse

{
  status: string;
  msg: string;
  resized: VariantResponse;
}

FormatListResponse

{
  msg: string;
  formats: FormatResponse[];
}

VariantListResponse

{
  msg: string;
  variants: VariantResponse[];
}

OriginalImageOut

{
  id: number;
  origin_name: string;
  ext: string;
  mime_type: string;
  origin_size: number;
  uid: string;
  s3_path: string;
  created_at: string;
  updated_at: string | null;
}

FormatResponse

{
  id: number;
  original_image_id: number;
  format: string;
  s3_path: string;
  size: number;
  reduction: number;
  created_at: string;
  updated_at: string | null;
}

VariantResponse

{
  id: number;
  original_image_id: number;
  variant_type: string;
  format: string | null;
  width: number | null;
  height: number | null;
  fit: string | null;
  size_bytes: number | null;
  s3_path: string;
  created_at: string;
  updated_at: string | null;
  preview_url: string | null;
  download_url: string | null;
}

Error Handling

The client throws TinyamiHttpError for API errors. You can catch and handle these errors:

try {
  await client.uploadImage('/path/to/image.jpg');
} catch (error) {
  if (error instanceof TinyamiHttpError) {
    console.error('API Error:', error.error.message);
  } else {
    console.error('Unexpected error:', error);
  }
}

Features

  • Full TypeScript support
  • Automatic FormData handling for file uploads
  • Support for large file uploads
  • Proper error handling with typed errors
  • Automatic retry mechanism for failed requests
  • Comprehensive API coverage

License

MIT