gohighlevel
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

Go High Level Node JS

Static Badge Static Badge Static Badge Static Badge Static Badge


Highlevel


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

Brief Overview of the Library GHL APP

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!

Brief Overview of the Library GHL using API Key

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!

Initialization

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 })

OAuth URL for GHL App

// 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()

OAuth Callback for GHL App

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 the API i.e Getting Contacts

// 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);

Support

You can support us with any amount. It's all appreciated.

Buy Me A Coffee PayPal Logo

Package Sidebar

Install

npm i gohighlevel

Weekly Downloads

19

Version

1.1.1

License

MIT

Unpacked Size

241 kB

Total Files

188

Last publish

Collaborators

  • m2kdevelopments