Go Highlevel Node Js ease of use library implementation to their API. Make sure you've create a Go Highlevel App in the Market Place
We recommend that you glance over the official Go Highlevel Documentation. We have tried to make the library have a corresponding function for each endpoint. Enjoy the intellisense!
We recommend that you glance over the official Go Highlevel Documentation. We have tried to make the library have a corresponding function for each endpoint. Enjoy the intellisense!
import { Gohighlevel } from 'gohighlevel'; // const { Gohighlevel } = require('gohighlevel');
// Create Instance of Gohighlevel
// if you want to use the OAuth Way
const GHL = new Gohighlevel({
// App Info from GHL Market Place
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_ID_SECRET,
redirectUri: process.env.REDIRECT_URI,
isWhiteLabel: true,
scopes: ["contacts.readonly", "contacts.write", "locations.readonly"]
})
// Or if you just want to an API Key
// How to get API Key - https://www.youtube.com/watch?v=Blr6jTYP3nM&t=3s&pp=ygUeaG93IHRvIGdldCBnb2hpZ2hsZXZlbCBhcGkga2V5
const GHL = new Gohighlevel({ apiKey: process.env.GOHIGHLEVEL_API_KEY })
// use the scopes when initializing -> new Gohighlevel({ ... })
let url = GHL.oauth.getOAuthURL()
// or if you want to add scopes this way
url = GHL.oauth
// you can add the necessary scopes for your
// using the Builder Design Pattern
.scopeBusinessesReadonly()
.scopeBusinessesWrite()
.scopeCalendarsReadonly()
.scopeCalendarsEventsWrite()
// get the oauth URL
.getOAuthURL()
async function callback(req, res){
// Get Auth Info
const code = req.query.code;
const refresh_token = req.query.refresh_token;
const authInfo = await GHL.oauth.getCallbackAuthTokens({
code: code,
refresh_token: refresh_token
});
// log token values
console.log(authInfo.access_token, authInfo.refresh_token, authInfo.expires_in)
// Set Auth Info
GHL.setAuth(authInfo);
}
// Use GHL API
// Corresponse with the endpoint
// For GHL APP - https://highlevel.stoplight.io/docs/integrations/ab55933a57f6f-get-contacts
// For GHL API KEY - https://public-api.gohighlevel.com/#0097b747-33c2-452f-8c78-aab5ab36c071
const contacts = GHL.contacts.search("Martin")
console.log(contacts);
You can support us with any amount. It's all appreciated.