Skip to main content
Glama
request.ts939 B
/** * API request utilities */ export interface RequestOptions { method?: string; headers?: Record<string, string>; body?: any; } export async function apiRequest( url: string, options: RequestOptions = {} ): Promise<Response> { const { method = "GET", headers = {}, body } = options; const response = await fetch(url, { method, headers: { "Content-Type": "application/json", ...headers, }, body: body ? JSON.stringify(body) : undefined, }); return response; } export async function apiRequestJson<T = any>( url: string, options: RequestOptions = {} ): Promise<T> { const response = await apiRequest(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error( `API request failed: ${response.status} ${response.statusText}\n${errorText}` ); } return response.json() as T; }

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/testdino-inc/testdino-mcp'

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