newOS for Developers

Back to Overview

API Schemas

TypeScript

Request and response types from the Newgraph API client.

@newstackdev/iosdk-newgraph-client-js

Source Package: These types are imported from @newstackdev/iosdk-newgraph-client-js. They represent the raw API contract with the Newgraph backend.

Response Types

PostReadResponse

Response when reading a post. Contains media metadata, ownership, and content.

interface PostReadResponse {
  id?: string;                  // Unique post identifier
  author?: UserReadPublicResponse;
  content?: string;             // Text content / caption
  contentUrl?: string;          // Primary media URL
  contentType?: string;         // MIME type (image/png, video/mp4)
  title?: string;               // Post title
  description?: string;         // Extended description
  created?: string;             // ISO timestamp
  updated?: string;             // Last modified timestamp
  aspectRatio?: number;         // Media aspect ratio
  tags?: string[];              // Associated tags
  license?: string;             // Content license
  blurHash?: string;            // BlurHash for loading placeholder
  // ... additional API fields
}

MoodReadResponse

Response when reading a folder/mood. Represents a collection of posts.

interface MoodReadResponse {
  id?: string;                  // Unique folder identifier
  author?: UserReadPublicResponse;
  title?: string;               // Folder/mood title
  description?: string;         // Folder description
  contentUrl?: string;          // Cover image URL
  created?: string;             // ISO timestamp
  updated?: string;             // Last modified timestamp
  flags?: string;               // Category/visibility flags
  posts?: PostReadResponse[];   // Contained posts (when fetched)
  postsCount?: number;          // Total post count
  score?: number;               // Aggregated engagement score
  // ... additional API fields
}

UserReadPublicResponse

Public user profile visible to all authenticated users.

interface UserReadPublicResponse {
  id?: string;                  // Unique user ID
  username?: string;            // Display username
  displayName?: string;         // Full display name
  description?: string;         // Bio/description
  contentUrl?: string;          // Profile picture URL
  coverContentUrl?: string;     // Cover image URL
  created?: string;             // Account creation date
  watts?: string;               // WATTS token balance
  // ... additional API fields
}

UserReadPrivateResponse

Private user profile with sensitive data, only accessible to the authenticated user.

interface UserReadPrivateResponse extends UserReadPublicResponse {
  email?: string;               // Email address
  phone?: string;               // Phone number
  stripeCustomerId?: string;    // Stripe payment ID
  subscriptionStatus?: string;  // Subscription tier
  // ... additional private fields
}

Request Types

QueryById

Standard parameter for fetching resources by ID.

interface QueryById {
  id: string;  // Required resource identifier
}

UserUpdateRequest

Fields that can be updated on a user profile.

interface UserUpdateRequest {
  displayName?: string;         // Update display name
  description?: string;         // Update bio
  contentUrl?: string;          // Update profile picture URL
  coverContentUrl?: string;     // Update cover image URL
  // ... additional updatable fields
}

MoodCreateRequest

Parameters for creating a new folder/mood.

interface MoodCreateRequest {
  title: string;                // Required folder title
  description?: string;         // Optional description
  flags?: string;               // Visibility/category flags
  // ... additional creation fields
}

PostCreateRequest

Parameters for creating a new post (without file upload).

interface PostCreateRequest {
  title?: string;               // Post title
  content?: string;             // Text content
  contentType?: string;         // MIME type
  tags?: string[];              // Post tags
  license?: string;             // Content license
  // ... additional creation fields
}

Common Patterns

Optional Fields

Most API response fields are optional (?) to handle partial responses and API evolution. Always check for undefined.

ISO Timestamps

All timestamps (created, updated) are ISO 8601 strings. Parse with new Date(timestamp).

URL Fields

Fields ending in Url contain pre-signed S3 URLs for media. These may expire and should be fetched fresh when needed.

Author Embedding

Posts and folders include an embedded author field with UserReadPublicResponse. This avoids extra API calls.