newOS for Developers

Back to Lists & Rankings

User Posts

Posts by a specific author

beginnerGET /user/moods

Overview

User Posts fetches all moods (folders) created by a specific user. This is used for profile pages to show a user's content portfolio.

For the current authenticated user, this also includes private moods.

API Endpoint

GET/user/moods

Query Parameters:

  • userId — Target user ID (required)
  • orderBy — Sort field: "created", "updated", "watts"
  • direction — "asc" or "desc"
  • page — Pagination cursor

Usage Example

import { getUserMoods } from "@newgraph-signals/actions/user";

// Get moods for a specific user
const userMoods = getUserMoods({ userId: "user-123" });

// Get current user's moods (includes private)
const myMoods = getUserMoods({ userId: currentUser.id });

// Raw API call
const response = await newgraphClient.api.user.moods({
  query: {
    userId: "user-123",
    orderBy: "created",
    direction: "desc"
  }
});

Edge Pattern

This query uses the graph edge pattern for efficient traversal:

// Edge key format
user+{userId}+author+folder

// Returns array of folder IDs
["folder-1", "folder-2", "folder-3"]

Response Schema

// PagedResponse<MoodReadResponse>
{
  value: [
    {
      id: string;
      title: string;
      description: string;
      contentUrl: string;
      privacy: string;       // "public" | "private"
      postsCount: number;
      watts: number;
      created: string;
      updated: string;
    }
  ],
  done: boolean;
  page: string;
}