Skip to content

REST API provides programmatic access to GoLogin App. Create a new browser profile, get a list of all browser profiles, add a browser profile and runnig

Notifications You must be signed in to change notification settings

gologinapp/gologin

Repository files navigation

GoLogin Node.js SDK

This package provides functionality to run and stop GoLogin profiles with node.js and then connect the profiles to automation tools like Selenium, Puppetteer, Playwright etc.

How does it work?

  1. You give SDK your dev token and profile id that you want to run
  2. SDK takes care of downloading, preparing your profile and starts the browser
  3. SDK gives you websocket url for automation tools
  4. You take this websocker url and connect it to the automation tool on your choice: Puppetteer, Selenium, Playwright etc
  5. Automation tool connects to browser and you can manage it through code

Getting Started

Where is token? API token is here.

Token API in Settings

Installation

npm i gologin

Example

import { GologinApi } from './src/gologin-api.js';

const GL = GologinApi({
  token: 'your token',
});

const profile = await GL.createProfileRandomFingerprint('some name');
const profileId = profile.id;

await GL.addGologinProxyToProfile(profileId, 'us');
const browser = await GL.launch({ profileId });
const page = await browser.newPage();
await page.goto('https://linkedin.com');
await new Promise((resolve) => setTimeout(resolve, 5000));
await browser.close();
await GL.stop();

Methods

constructor

Required options:

  • token <[string]> Required - your API token

Optional options:

  • profile_id <[string]> - profile ID (NOT PROFILE NAME) will be generated if not specified
  • executablePath <[string]> path to executable Orbita file. Orbita will be downloaded automatically if not specified
  • extra_params arrayof <[string]> additional flags for browser start. For example: '--headles', '--load-extentions=path/to/extension'
  • uploadCookiesToServer <[boolean]> upload cookies to server after profile stopping (default false). It allows you to export cookies from api later.
  • writeCookesFromServer <[boolean]> if you have predefined cookies and you want browser to import it (default true).
  • tmpdir <[string]> absolute path to the directtory where you want to store user-data-dir. Default path in tmp folder will be picked if no specified
  • vncPort <[integer]> port of VNC server if you using it
const GL = new GoLogin({
    token: 'your token',
    profile_id: 'profile id',
    extra_params: ["--headless", "--load-extentions=path/to/extension"]
});

createProfileRandomFingerprint - you pass os ('lin', 'win', 'mac') and profile name and we give you brand new shiny profile

const GL = new GoLogin({
    token: 'your token',
    profile_id: 'profile id',
    extra_params: ["--headless", "--load-extentions=path/to/extension"]
});
const profile = await gl.createProfileRandomFingerprint("some name")
const profileId = profile.id

createProfileWithCustomParams - This method creates a profile and you can pass any particular params to it. Full list of params you can find here - https://api.gologin.com/docs

const GL = GoLogin({
	"token": "your token",
	})
const profile = await gl.createProfileWithCustomParams({
    "os": "lin",
    "name": "some name",
    "navigator": {
        "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        "resolution": "1920x1080",
        "language": "en-US",
        "platform": "Linux x86_64",
        "hardwareConcurrency": 8,
        "deviceMemory": 8,
        "maxTouchPoints": 0
    }
})
const profileId = profile.id

updateUserAgentToLatestBrowser - user agent is one of the most important thing in your fingerprint. It decides which browser version to run. This method help you to keep useragent up to date.

const GL = GoLogin({
	"token": "your token",
	})
await GL.updateUserAgentToLatestBrowser(["profineId1", "profileId2"], "workspceId(optional)")

addGologinProxyToProfile - Gologin provides high quality proxies with free traffic for paid users. Here you can add gologin proxy to profile, just pass country code

const GL = GoLogin({
	"token": "your token",
	})
await GL.addGologinProxyToProfile("profileId", "us")

addCookiesToProfile - You can pass cookies to the profile and browser will import it before starting

const GL = GoLogin({
	"token": "your token",
	})

await GL.addCookiesToProfile("profileId", [
    {
        "name": "session_id",
        "value": "abc123",
        "domain": "example.com",
        "path": "/",
        "expirationDate": 1719161018.307793,
        "httpOnly": True,
        "secure": True
    },
    {
        "name": "user_preferences",
        "value": "dark_mode",
        "domain": "example.com",
        "path": "/settings",
        "sameSite": "lax"
    }
])

refreshProfilesFingerprint - Replaces your profile fingerprint with a new one

const GL = GoLogin({
	"token": "your token",
	})

await GL.refreshProfilesFingerprint(["profileId1", "profileId2"])

changeProfileProxy - allows you to set a proxy to a profile

const GL = GoLogin({
	"token": "your token",
	})
await GL.changeProfileProxy("profileId", { "mode": "http", "host": "somehost.com", "port": 109, "username": "someusername", "password": "somepassword"})

launch() - starts browser with profile id, returning WebSocket url for puppeteer

const GL = GoLogin({
	"token": "your token",
	})
await GL.launch({ profileId: 'some profileId' })

exit() stops browser and uploads it to the storage

const GL = GoLogin({
	"token": "your token",
	})
await GL.launch({ profileId: 'some profileId' })
await GL.exit()

DEBUG

For debugging use DEBUG=* node example.js command

Selenium

To use GoLogin with Selenium see selenium/example.js

Full GoLogin API

Swagger: link here

Postman: link here

For local profiles

startLocal()

  • returns: string

start browser with profile id, return WebSocket url for puppeteer. Extracted profile folder should be in specified temp directory.

stopLocal()

stop current browser without removing archived profile

example-local-profile.js

import puppeteer from 'puppeteer-core';

import GoLogin from '../src/gologin.js';

const { connect } = puppeteer;

(async () => {
  const GL = new GoLogin({
    token: 'yU0token',
    profile_id: 'yU0Pr0f1leiD',
    executablePath: '/usr/bin/orbita-browser/chrome',
    tmpdir: '/my/tmp/dir',
  });

  const wsUrl = await GL.startLocal();
  const browser = await connect({
    browserWSEndpoint: wsUrl.toString(),
    ignoreHTTPSErrors: true,
  });

  const page = await browser.newPage();
  await page.goto('https://myip.link');
  console.log(await page.content());
  await browser.close();
  await GL.stopLocal({ posting: false });
})();

Python support

pyppeteer (recommend) and Selenium supported (see file gologin.py)

for Selenium may need download webdriver

About

REST API provides programmatic access to GoLogin App. Create a new browser profile, get a list of all browser profiles, add a browser profile and runnig

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published