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

mediaplatform-sdk

v1.0.0

Published

TypeScript SDK for Media Platform API - Upload, manage, and share your media files with ease

Readme

MediaPlatform SDK

TypeScript/JavaScript SDK for Media Platform API - Upload, manage, and share your media files with ease.

Installation

npm install @media-platform/sdk

Quick Start

import { createMediaPlatformClient } from 'mediaplatform-sdk'

// Initialize the client
const client = createMediaPlatformClient('your-api-key')

// Upload a file from browser
const fileInput = document.querySelector('input[type="file"]')
const file = fileInput.files[0]
const uploadedFile = await client.upload(file)

console.log('File uploaded:', uploadedFile.url)

Features

  • File Upload - Upload files from browser or Node.js
  • File Management - List, get, and delete files
  • TypeScript Support - Full type definitions included
  • Browser & Node.js - Works in both environments
  • Promise-based - Modern async/await API
  • Lightweight - Zero dependencies

API Reference

Initialize Client

import { createMediaPlatformClient } from 'mediaplatform-sdk'

const client = createMediaPlatformClient(apiKey, apiUrl?)

Parameters:

  • apiKey (string): Your API key from MediaPlatform dashboard
  • apiUrl (string, optional): API base URL (defaults to production)

Upload File

From File Object (Browser)

const fileInfo = await client.upload(file)

From Buffer (Node.js)

import fs from 'fs'

const buffer = fs.readFileSync('image.jpg')
const fileInfo = await client.uploadFromBuffer(buffer, 'image.jpg', 'image/jpeg')

List Files

const response = await client.listFiles(page?, limit?)

console.log(response.files) // Array of files
console.log(response.pagination) // Pagination info

Get File Details

const fileInfo = await client.getFile(fileId)

Delete File

await client.deleteFile(fileId)

Download File

const buffer = await client.downloadFile(fileId)

Get File URL

const url = await client.getFileUrl(fileId)

Types

FileInfo

interface FileInfo {
  id: string
  filename: string
  mimeType: string
  size: number
  url: string
  createdAt: string
}

ListResponse

interface ListResponse {
  files: FileInfo[]
  pagination: {
    page: number
    limit: number
    total: number
    pages: number
  }
}

Examples

React Component

import React, { useState } from 'react'
import { createMediaPlatformClient } from 'mediaplatform-sdk'

const client = createMediaPlatformClient('your-api-key')

function FileUploader() {
  const [uploading, setUploading] = useState(false)
  
  const handleUpload = async (event) => {
    const file = event.target.files[0]
    if (!file) return
    
    setUploading(true)
    try {
      const uploadedFile = await client.upload(file)
      console.log('Uploaded:', uploadedFile.url)
    } catch (error) {
      console.error('Upload failed:', error)
    } finally {
      setUploading(false)
    }
  }
  
  return (
    <div>
      <input type="file" onChange={handleUpload} disabled={uploading} />
      {uploading && <p>Uploading...</p>}
    </div>
  )
}

Node.js Script

import { createMediaPlatformClient } from 'mediaplatform-sdk'
import fs from 'fs'

const client = createMediaPlatformClient('your-api-key')

async function uploadAndList() {
  // Upload a file
  const buffer = fs.readFileSync('document.pdf')
  const file = await client.uploadFromBuffer(buffer, 'document.pdf', 'application/pdf')
  
  console.log('Uploaded:', file.url)
  
  // List all files
  const response = await client.listFiles()
  console.log(`Total files: ${response.pagination.total}`)
  
  response.files.forEach(file => {
    console.log(`- ${file.filename} (${file.size} bytes)`)
  })
}

uploadAndList().catch(console.error)

Error Handling

try {
  const file = await client.upload(file)
} catch (error) {
  if (error.message.includes('401')) {
    console.error('Invalid API key')
  } else if (error.message.includes('413')) {
    console.error('File too large')
  } else {
    console.error('Upload failed:', error.message)
  }
}

Supported File Types

  • Images: JPEG, PNG, GIF, WebP
  • Videos: MP4, WebM, QuickTime
  • Documents: PDF, TXT, and more
  • Maximum file size: 50MB

Getting Your API Key

  1. Sign up at MediaPlatform
  2. Go to your dashboard
  3. Click on Settings → API Key
  4. Generate a new API key

License

MIT

Support