joy-upload-api
v1.0.0
Published
Upload files to catbox.moe / litterbox.catbox.moe as a library, CLI, or Express server
Maintainers
Readme
catbox-upload-api
Node.js package to upload files to catbox.moe and litterbox.catbox.moe — usable as a library, a CLI tool, or a standalone Express server.
Install (once published)
npm install catbox-upload-apiUse as a library
const { uploadFile, uploadFromUrl, uploadTemp } = require('catbox-upload-api');
// Upload a local file
const link = await uploadFile('./photo.jpg');
console.log(link); // https://files.catbox.moe/xxxxxx.jpg
// Upload from a remote URL
const link2 = await uploadFromUrl('https://example.com/image.png');
// Temporary upload (auto-expires: '1h', '12h', '24h', '72h')
const tempLink = await uploadTemp('./video.mp4', '1h');
// Video upload - auto-picks permanent (<=200MB) or temporary (up to 1GB) hosting
const video = await uploadVideo('./movie.mp4', { time: '72h' });
console.log(video); // { url: '...', temporary: false|true, sizeMB: '45.2' }Use as a CLI
npx catbox-upload-api ./photo.jpg
npx catbox-upload-api --url https://example.com/image.png
npx catbox-upload-api --video ./movie.mp4
npx catbox-upload-api --video ./movie.mp4 24hUse as a server (optional)
Requires express and multer (listed as optional dependencies):
npm install express multer
npm startEndpoints:
POST /upload— multipart form, field namefilePOST /upload-url— JSON body{ "url": "..." }POST /upload-video— multipart form, field namefile, optional field/querytime(1h,12h,24h,72h, default72h). Files ≤200MB go to permanent catbox storage; larger files (up to 1GB) go to temporary litterbox storage.
Publish to npm registry (npmjs.com)
- Create an account at npmjs.com if you don't have one.
- Login from terminal:
npm login - Check the package name is free (rename
nameinpackage.jsonifcatbox-upload-apiis taken):npm view catbox-upload-api - Publish:
npm publish - Done — anyone can now run
npm install catbox-upload-api.
Tip: bump
versioninpackage.json(e.g.1.0.1) before every newnpm publish.
