Skip to content

@imvu/rest ​

The low-level REST client that @imvu/client is built on: IMVU authentication, session reuse, and typed access to the raw API envelopes, on the standard fetch. Use it directly when you want plain JSON instead of modeled resources.

sh
npm install @imvu/rest

Example ​

Log in and read the raw /login/me envelope (examples/rest-basic.ts):

ts
/**
 * @imvu/rest — the low-level client: cookie-based auth + raw typed JSON,
 * no resource classes. See examples/README.md for how to run.
 */
import { REST } from '@imvu/rest';

const username = process.env.IMVU_USERNAME;
const password = process.env.IMVU_PASSWORD ?? '';

if (!username) {
  console.error('Set IMVU_USERNAME (and IMVU_PASSWORD) — see examples/README.md');
  process.exit(1);
}

const rest = new REST();
await rest.login(username, password);
console.log(`Authenticated as ${username} — cid ${rest.cid}`);

// Raw denormalized API envelope; pick out the node we asked for.
const me = await rest.request('/login/me');
const login = me.denormalized[me.id];

console.log('session source:', login.data.source);
console.log('IMQ endpoint:', login.relations?.imq);

REST keeps the session's cookies in ./cookies.json by default in Node (configure with cookiePath, or cookieStorage: null for memory only) and reuses a cached session when the username matches, so repeated runs don't log in again.

REST also:

  • solves proof-of-work challenges when given a solver (new REST({ proofOfWork })), retrying requests rejected with VERIFY-001. See Handling errors.
  • reports every successful response through onResponse, including the documents it embeds; @imvu/client builds its cache from these. normalizeDocument(url, node) turns one embedded entry into a document.
  • returns edges with collections. rest.collection() returns items (each edge followed to its target) and edges (the edge documents themselves, which some collections, like chat participants, keep their data on).

See also: Authentication and sessions, Calling unmodeled endpoints, Running in the browser.

Every export is listed in the API reference.

Released under the MIT License.