UNPKG

@gnosticdev/highlevel-sdk

Version:
44 lines (43 loc) 1.08 kB
import { t as HighLevelSDKError } from "./errors-DX_S3nKC.js"; import createClient from "openapi-fetch"; //#region src/v1/index.ts const DEFAULT_V1_BASE_URL = "https://rest.gohighlevel.com"; /** * Creates a client for v1 of the HighLevel API. * * _Note_: The v1 API uses legacy API keys, use the v2 client for OAuth or Private Integration. * * @see {@link createHighLevelClient} * * @see https://public-api.gohighlevel.com * * @example * ```ts * const client = createHighLevelV1Client({ * apiKey: process.env.HIGHLEVEL_API_KEY, * }) * * const {data, error} = await client.get('/v1/contacts', { * params: { * query: { * locationId: '1234567890' * } * } * }) * * if (error) { * throw new Error(error.message) * } * * console.log(data) // { contacts: [{...}] } * ``` */ function createHighLevelV1Client(config) { if (!config.apiKey) throw new HighLevelSDKError("API_KEY_REQUIRED"); return createClient({ baseUrl: config.baseUrl ?? DEFAULT_V1_BASE_URL, headers: { Authorization: `Bearer ${config.apiKey}` } }); } //#endregion export { createHighLevelV1Client };