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!
import { Gohighlevel } from 'gohighlevel'; // const { Gohighlevel } = require('gohighlevel');
// Create Instance of Gohighlevel
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"]
})
// 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 - https://highlevel.stoplight.io/docs/integrations/ab55933a57f6f-get-contacts
const contacts = await GHL.getContacts();
console.log(contacts);
You can support us with any amount. It's all appreciated.