API
Types
TypeScript type reference for nuxt-reviews.
All types are exported from the module:
import type {
NormalizedReview,
ReviewCollection,
AggregateRating,
ModuleOptions,
ReviewSchemaItem,
} from 'nuxt-reviews'
NormalizedReview
The core review type — every provider's reviews are normalized to this shape.
interface NormalizedReview {
id: string // Provider-prefixed, e.g. "google_abc123"
provider: ReviewProvider // 'google' | 'trustpilot' | 'serpapi' | 'outscraper' | 'bookingcom' | 'mock'
rating: number // 1-5 scale
text: string // Review body text
title?: string // Review headline (not all providers)
author: ReviewAuthor // { name, avatar?, url?, reviewCount? }
publishedAt: string // ISO 8601 date
language?: string // e.g. "en", "tr", "fr"
isVerified?: boolean
businessResponse?: ReviewResponse // { text, publishedAt }
likes?: number
images?: string[]
sourceUrl?: string
moderation?: ModerationResult // Only when moderation is enabled
raw?: Record<string, unknown> // Provider-specific raw data
}
ReviewCollection
Returned by API routes and useReviews().
interface ReviewCollection {
reviews: NormalizedReview[]
aggregate: AggregateRating
sources: Array<{
provider: ReviewProvider
count: number
average: number
}>
fetchedAt: string // ISO 8601
totalAvailable?: number // Total reviews on the platform (single-provider only)
nextPageToken?: string // Pagination token (single-provider only)
}
AggregateRating
interface AggregateRating {
average: number // Average rating (1-5)
total: number // Total number of reviews
distribution: {
1: number
2: number
3: number
4: number
5: number
}
}
ReviewSchemaItem
Options for useReviewSchema().
interface ReviewSchemaItem {
name: string // Business/entity name (required)
description?: string
url?: string // Canonical page URL
image?: string // Business image URL
type?: string // Schema.org @type (default: 'LocalBusiness')
}
ModuleOptions
interface ModuleOptions {
providers: ProvidersConfig
cacheTTL?: number // Default: 3600
cache?: boolean // Default: true
defaultLanguage?: string
maxReviews?: number // Default: 50
minRating?: number
moderation?: ModerationConfig
apiPrefix?: string // Default: "/api/_reviews"
}
Provider Configs
interface MockProviderConfig {
seed?: number // Reserved for future use
}
interface GoogleProviderConfig {
apiKey: string
placeId: string
}
interface TrustpilotProviderConfig {
apiKey: string
businessUnitId: string
}
interface SerpApiProviderConfig {
apiKey: string
placeId: string
sort?: 'qualityScore' | 'newestFirst' | 'ratingHigh' | 'ratingLow'
}
interface OutscraperProviderConfig {
apiKey: string
placeId: string
limit?: number
sort?: 'newest' | 'most_relevant' | 'highest_rating' | 'lowest_rating'
}
// BETA
interface BookingcomProviderConfig {
username: string
password: string
propertyId: string
}
ModerationConfig
interface ModerationConfig {
enabled: boolean
provider: 'perspective' | 'openai'
apiKey: string
toxicityThreshold?: number // Default: 0.7
attributes?: PerspectiveAttribute[]
action?: 'filter' | 'flag' // Default: 'filter'
}