Skip to main content
Glama
index.ts1.24 kB
import { GraphQLClient } from 'graphql-request'; import { getSdk, Sdk } from './generated/graphql.js'; export class WikiJSClient { private sdk: Sdk; constructor(endpoint: string, authToken: string) { const defaultHeaders = { Authorization: `Bearer ${authToken}` }; const endpointWithGraphql = `${endpoint}/graphql`; const client = new GraphQLClient(endpointWithGraphql, { headers: defaultHeaders }); this.sdk = getSdk(client); } async searchPages(query: string, path?: string, locale?: string) { const result = await this.sdk.SearchPages({ query, path, locale }); return result.pages?.search || { results: [], suggestions: [], totalHits: 0 }; } async getAllPages({limit, locale, tags}: {limit?: number, locale?: string, tags?: string[]} = {}) { const result = await this.sdk.GetAllPages({ limit, locale, tags }); return result.pages?.list || []; } async getPageById(id: number) { const result = await this.sdk.GetPageById({ id }); return result.pages?.single || null; } async getPageByPath(path: string, locale: string) { const result = await this.sdk.GetPageByPath({ path, locale }); return result.pages?.singleByPath || null; } }

Implementation Reference

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/RicardoCenci/wikijs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server