Skip to content
Pictastic.ai

API v1 · Node.js

Virtual staging API in Node.js

It's a plain REST API, so Node's built-in fetch is all you need to stage, restage or upscale a photo from JavaScript or TypeScript — no SDK, no extra dependencies.

Works with Node 18+ fetch · 1 credit per staged image

javascript
// Node 18+ (global fetch, ES modules). Never commit your key.
import { readFile } from "node:fs/promises";

const API = "https://app.pictastic.ai/api/v1";
const auth = { Authorization: `Bearer ${process.env.PICTASTIC_API_KEY}` };

// 1. Free upload slot (costs no credits)
const { uploads } = await fetch(`${API}/presigned-urls?count=1`, {
  headers: auth,
}).then((r) => r.json());
const slot = uploads[0];

// 2. PUT your photo to the slot
await fetch(slot.presignedUrl, {
  method: "PUT",
  headers: { "Content-Type": "image/jpeg" },
  body: await readFile("empty-room.jpg"),
});

// 3. Stage it (1 credit)
const res = await fetch(`${API}/virtual-staging`, {
  method: "POST",
  headers: { ...auth, "Content-Type": "application/json" },
  body: JSON.stringify({
    imageUrl: slot.publicUrl,
    roomType: "Living Room",
    designStyle: "Modern",
  }),
}).then((r) => r.json());

console.log(res.outputImageUrl);

Overview

How do I use the virtual staging API in Node.js?

You call the Pictastic virtual staging API from Node.js using the built-in fetch: GET a free presigned upload URL, PUT your photo to it, then POST that URL to the /virtual-staging endpoint and read outputImageUrl from the JSON response. It is a plain REST API that works the same from JavaScript or TypeScript with no SDK.

How it works

Upload, call, collect

Image inputs live on Pictastic storage, so every job starts with a free presigned upload.

  1. 1

    Get a presigned upload URL

    Ask for as many slots as you need, then PUT your image bytes straight to storage. This call is free — no credits.

  2. 2

    Call the endpoint you want

    Pass the returned publicUrl as imageUrl. Staging, removal and upscaling all take the same input shape.

  3. 3

    Read the output URL

    The response carries outputImageUrl and a downloadUrl, plus a jobId you can re-fetch later from the jobs history.

Why developers pick it

Built to drop into a Node codebase

Everything you need to wire staging into an Express, Next.js or serverless workflow.

Zero dependencies

Node 18+ ships fetch globally, so the whole integration is standard library. Nothing Pictastic-specific to add to package.json.

JavaScript or TypeScript

It is plain JSON over HTTPS, so the same calls work untyped or with your own request/response types — no generated client to keep in sync.

Runs in serverless handlers

The synchronous JSON response means a Vercel or Lambda function can stage an image and return its URL inside a single request.

1 credit, refunded on failure

You pay one credit per finished image and get it back automatically if a job fails — so a batch job never bills for errors.

Part of one API

Node.js is just one way to call the virtual staging API

It's a plain REST API, so the same endpoints work from any language. See the full API overview, or jump to a specific operation.

Virtual staging API in Node.js FAQ

How do I use the virtual staging API in Node.js?

You call the Pictastic virtual staging API from Node.js using the built-in fetch: GET a free presigned upload URL, PUT your photo to it, then POST that URL to the /virtual-staging endpoint and read outputImageUrl from the JSON response. It is a plain REST API that works the same from JavaScript or TypeScript with no SDK.

Do I need an npm package to call the API?

No. Node 18+ has global fetch, so the example needs no dependencies at all. Any HTTP client (axios, got, node-fetch) works too, but none is required, and there is no Pictastic SDK.

Does it work from a Next.js or serverless function?

Yes. Call it from a route handler or server action — never from the browser, so your key stays server-side. The response is synchronous, so the function can stage an image and return its URL in one request.

How much does it cost to call from Node?

The language makes no difference to price: staging and furniture removal are 1 credit per successful image and upscaling is 3 credits, drawn from the same balance, with presigned uploads free and failures refunded.

Stage your first photo from Node.js today

Create a key in the dashboard and the example above runs as-is once PICTASTIC_API_KEY is set.

Presigned uploads are free — you only spend credits on finished images.