Skip to main content
This page documents every method available on the NearIQ client, with TypeScript signatures, parameter details, and runnable examples. All methods return Promises and throw a NearIQError-shaped error on non-2xx responses. For installation instructions and error handling, see SDK installation.
import { NearIQ } from '@neariq/sdk'
const client = new NearIQ({ apiKey: process.env.NEARIQ_API_KEY! })

client.me

client.me.get()

Returns your business profile.
get(): Promise<Business>
const biz = await client.me.get()
console.log(biz.name, biz.rating, biz.plan)

client.me.competitors(params?)

Returns your list of tracked competitors.
competitors(params?: {
  limit?: number
  offset?: number
  sort?: string
}): Promise<{ data: Competitor[]; count: number }>
limit
number
Maximum number of competitors to return.
offset
number
Number of results to skip for pagination.
sort
string
Sort order: score_desc (default), score_asc, name, or rating_desc.
const { data: competitors, count } = await client.me.competitors({
  sort: 'rating_desc',
})

console.log(`Tracking ${count} competitors`)
competitors.forEach((c) => console.log(`${c.name}: ${c.rating} ★`))

client.me.alerts(params?)

Returns recent alerts for your account.
alerts(params?: {
  severity?: 'info' | 'warning' | 'opportunity' | 'danger'
  limit?: number
  offset?: number
  unread?: boolean
}): Promise<{ data: Alert[]; count: number }>
severity
string
Filter to a single severity level: info, warning, opportunity, or danger.
limit
number
default:"50"
Maximum number of alerts to return (max 200).
offset
number
Number of results to skip for pagination.
unread
boolean
default:"false"
When true, returns only unread alerts.
// Fetch unread danger alerts
const { data: alerts } = await client.me.alerts({
  unread: true,
  severity: 'danger',
})

alerts.forEach((a) => {
  console.log(`${a.title}`)
  if (a.recommendation) console.log(`  → ${a.recommendation}`)
})

client.me.snapshots(params?)

Returns historical rating snapshots for your business.
snapshots(params?: {
  days?: number
  limit?: number
}): Promise<{ data: Snapshot[] }>
days
number
Limit snapshots to the past N days.
limit
number
default:"90"
Maximum number of snapshots to return (max 365).
const { data: snaps } = await client.me.snapshots({ limit: 30 })
snaps.forEach((s) => console.log(`${s.capturedAt}: ${s.rating} ★`))

client.me.reviews()

Returns your Google reviews with aggregated metadata.
reviews(): Promise<ReviewsResponse>
const result = await client.me.reviews()
console.log(`${result.reviews.length} reviews fetched`)
console.log(`Owner response rate: ${result.ownerResponseRate}`)

client.me.gbpHealth()

Returns your Google Business Profile health score and checklist.
gbpHealth(): Promise<GBPHealthResponse>
const health = await client.me.gbpHealth()
console.log(`GBP health score: ${health.score}/100`)

const failing = health.checks.filter((c) => !c.done)
failing.forEach((c) => console.log(`  ✗ ${c.label}: ${c.detail}`))

client.competitors

client.competitors.get(id)

Returns full details for a single tracked competitor.
get(id: string): Promise<CompetitorDetail>
const c = await client.competitors.get('comp_abc123')
console.log(`${c.name}${c.rating} ★, health ${c.healthScore}`)
console.log(`Status: ${c.status}, last checked ${c.lastCheckedAt}`)

client.competitors.snapshots(id, params?)

Returns historical rating snapshots for a competitor.
snapshots(
  id: string,
  params?: { days?: number; limit?: number }
): Promise<{
  competitor: { id: string; name: string }
  count: number
  snapshots: Snapshot[]
}>
id
string
required
The competitor’s NearIQ ID.
days
number
Limit snapshots to the past N days.
limit
number
default:"90"
Maximum number of snapshots to return (max 365).
const result = await client.competitors.snapshots('comp_abc123', { limit: 60 })

console.log(`${result.competitor.name}${result.count} snapshots`)
result.snapshots.forEach((s) =>
  console.log(`  ${s.capturedAt}: ${s.rating} ★ (${s.reviewCount} reviews)`)
)

client.competitors.reviews(id)

Returns cached Google reviews for a competitor.
reviews(id: string): Promise<ReviewsResponse & {
  competitor: { id: string; name: string }
}>
const result = await client.competitors.reviews('comp_abc123')

console.log(`${result.competitor.name} reviews (source: ${result.source})`)
result.reviews.slice(0, 5).forEach((r) =>
  console.log(`  ${r.rating}★ — ${r.text ?? '(no text)'}`)
)

client.webhooks

client.webhooks.list()

Returns all registered webhook endpoints.
list(): Promise<{ data: WebhookEndpoint[]; count: number }>
const { data: hooks, count } = await client.webhooks.list()
console.log(`${count} webhook endpoints registered`)
hooks.forEach((h) => console.log(`${h.url} — active: ${h.active}`))

client.webhooks.create(body)

Registers a new webhook endpoint. The secret in the response is shown only once.
create(body: {
  url: string
  events: string[]
}): Promise<WebhookEndpoint & { secret: string; note: string }>
url
string
required
The HTTPS URL to deliver events to.
events
string[]
required
One or more event types to subscribe to.
const hook = await client.webhooks.create({
  url: 'https://example.com/hooks/neariq',
  events: ['competitor.rating_change', 'alert.created'],
})

// Store hook.secret securely — it will not be returned again
console.log(`Webhook created: ${hook.id}`)
console.log(`Secret (save this!): ${hook.secret}`)

client.webhooks.update(id, body)

Updates a webhook endpoint’s URL, events, or active status.
update(
  id: string,
  body: { url?: string; events?: string[]; active?: boolean }
): Promise<WebhookEndpoint>
// Pause a webhook without deleting it
const updated = await client.webhooks.update('wh_abc123', { active: false })
console.log(`Webhook active: ${updated.active}`)

client.webhooks.delete(id)

Permanently deletes a webhook endpoint. Returns void.
delete(id: string): Promise<void>
await client.webhooks.delete('wh_abc123')
console.log('Webhook deleted')

client.export(params?)

Bulk-exports all account data as a single object.
export(params?: { include?: string }): Promise<ExportResponse>
include
string
Comma-separated list of sections to include: business, competitors, alerts. Defaults to all three.
// Export everything
const data = await client.export()
console.log(`Exported at ${data.exportedAt}`)
console.log(`${data.competitors?.length} competitors`)
console.log(`${data.alerts?.length} alerts`)

// Export only alerts
const alertsOnly = await client.export({ include: 'alerts' })

client.usage()

Returns API usage statistics for your account.
usage(): Promise<UsageResponse>
const stats = await client.usage()
console.log(`Plan: ${stats.plan}`)
console.log(`Tracking ${stats.competitors.tracked} competitors`)
console.log(`${stats.alerts.last30Days} alerts in the last 30 days`)
stats.apiKeys.forEach((k) =>
  console.log(`Key "${k.name ?? k.id}" — last used ${k.lastUsedAt ?? 'never'}`)
)

Exported types

All types are re-exported from @neariq/sdk and can be imported individually.

Business

interface Business {
  id: string
  name: string
  category: string | null
  address: string | null
  website: string | null
  phone: string | null
  googlePlaceId: string | null
  rating: number | null
  reviewCount: number | null
  plan: string | null
  createdAt: string
  updatedAt: string | null
}

Competitor

interface Competitor {
  id: string
  name: string
  rating: number | null
  reviewCount: number | null
  address: string | null
  placeId: string | null
  category: string | null
  ratingDelta30d: number | null
  reviewDelta30d: number | null
}

CompetitorDetail

Extends Competitor with additional GBP fields:
interface CompetitorDetail extends Competitor {
  phone: string | null
  website: string | null
  status: string | null
  priceLevel: string | null
  editorialSummary: string | null
  services: string[]
  openNow: boolean | null
  hours: Record<string, string> | null
}

Snapshot

interface Snapshot {
  id: string
  rating: number | null
  reviewCount: number | null
  capturedAt: string
}

Alert

interface Alert {
  id: string
  title: string
  description: string | null
  recommendation: string | null
  severity: 'info' | 'warning' | 'opportunity' | 'danger'
  type: string
  competitorName: string | null
  createdAt: string
}

Review

interface Review {
  rating: number
  text: { text: string } | undefined
  authorAttribution: { displayName: string; photoUri?: string }
  relativePublishTimeDescription: string
  publishTime: string
  likes: number | null
  ownerResponse: string | null
  ownerResponseDate: string | null
  reviewerReviewCount: number | null
  isLocalGuide: boolean
}

ReviewSentiment

interface ReviewSentiment {
  summary: string
  themes: Array<{
    label: string
    sentiment: 'positive' | 'negative' | 'mixed'
    count: number
    examples?: string[]
  }>
  keywords: string[]
  trend?: 'improving' | 'declining' | 'stable' | null
  trendNote?: string | null
}

ReviewsResponse

interface ReviewsResponse {
  reviews: Review[]
  sentiment: ReviewSentiment | null
  ratingDistribution: Record<number, number> | null
  ownerResponseRate: number | null
  source: 'serp' | 'places' | 'cache' | null
  fromCache?: boolean
}

GBPHealthResponse

interface GBPHealthResponse {
  score: number
  checks: Array<{
    id: string
    label: string
    status: 'pass' | 'fail' | 'warn'
    message?: string
  }>
}

WebhookEndpoint

interface WebhookEndpoint {
  id: string
  url: string
  events: string[]
  active: boolean
  secret?: string
  createdAt: string
  lastTriggeredAt: string | null
}

UsageResponse

interface UsageResponse {
  accountId: string
  plan: string
  trialEndsAt: string | null
  memberSince: string | null
  competitors: { tracked: number }
  alerts: { last30Days: number }
  apiKeys: Array<{
    id: string
    name: string | null
    createdAt: string
    lastUsedAt: string | null
    revoked: boolean
  }>
}

ExportResponse

interface ExportResponse {
  exportedAt: string
  accountId: string
  business?: Business | null
  competitors?: Array<
    CompetitorDetail & { latestSnapshot: Snapshot | null; snapshotCount: number }
  >
  alerts?: Alert[]
}

NearIQError

interface NearIQError extends Error {
  status: number  // HTTP status code
  body: unknown   // Parsed JSON response body
}