@nudity/api
v1.0.2
Published
Client for the Undress API.
Maintainers
Readme
Nudity API SDK for JavaScript/TypeScript
A high-performance, strictly typed client for the Nudity API. This SDK allows you to integrate image generation, video animation, and face swap technologies into your applications with ease. Built with native Fetch, it is optimized for Bun, Node.js (18+), and modern browser environments.
Core Concepts: The Asynchronous Workflow Most operations in this API (Undressing, Animation, Face Swap) are resource-intensive and process asynchronously.
Request: You submit a task with required media and a webhook URL.
Queue: The API returns a idGen (Task ID) immediately.
Processing: The server processes your request in the background.
Callback: Once finished, the API sends an HTTP POST request containing the result URL to your specified webhook.
Installation
# Using Bun (Recommended)
bun add @nudity/api
# Using NPM
npm install @nudity/apiQuick Start
Initialize the Client
import { NudityApi } from '@nudity/api';
// Initialize with your API token
const client = new NudityApi('your_api_token_here');Image Generation (Undress) This method requires a webhook to receive the final image.
const response = await client.image.generate({
image: Bun.file('./input.jpg'), // Supports BunFile, Blob, or File
cloth: 'Bikini',
webhook: 'https://your-backend.com/api/callback',
idGen: 'internal_tracking_id_001'
});
console.log(`Task queued: ${response.idGen}`);API Reference
The SDK is organized into domain-specific resources:
client.image:
generate(params): Submits an image processing task.
getPosition(idGen): Checks the current queue status and result.
getCollections(): Fetches available style collections.
client.video
animate(params): Converts a static image into a video.
getPosition(idGen): Polls video generation status.
getModels(): Lists available animation models.
client.swap
generate(params): Initiates a face swap (Image/Video).
getPosition(idGen): Polls status for swap tasks.
client.profile
- getBalance(): Returns current account credit balance.
Handling Webhooks (Best Practices)
To receive results from the API, your server must expose a public POST endpoint.
Example Express/NestJS logic:
- Your server receives a POST request from the API.
- The body contains the idGen and the url of the generated asset.
- You map this idGen to a user in your database and notify them.
Tip: During development, use tools like ngrok or webhook.site to inspect incoming results.
Error Handling The SDK throws descriptive errors for failed requests.
try {
const balance = await client.profile.getBalance();
} catch (error) {
// error.message will contain: "NudityApi Error [401]: Unauthorized"
console.error(error.message);
}```