Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autopilot-sdk

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autopilot-sdk

Node SDK for Autopilot

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

Intro

This is an un-official Node SDK for interfacing the Autopilot API. You can view the REST api documentation here. Some cool features include:

  • Pass a normal JSON object and it would figure out which ones are custom fields and which ones are not
  • Automatically reformat keys to contain Autopilot data types along with all neccessary hyphens. E.g.{'Foo Bar': true} will re-format to {'boolean--Foo--Bar': true}
  • Add/Update/Delete Contact
  • Unsubscribe Contact from a list
  • Create lists
  • Add Contacts to lists
  • Get all Segments
  • Register/Unregister hooks etc...

NB: Still under development so some APIs may not be available yet.

Installation

> npm i -S autopilot-sdk

Usage

import Autopilot from 'autopilot-sdk';

const autopilot = new Autopilot('<API_KEY>');
//=> autopilot instance

API

The Autopilot instance has instance members that access the scopes of the API. Namely: contacts, lists, journeys, segments, etc... Below is the list of the methods for all the scopes.

NB: All calls on the contact/contacts scope must have a contact_id or email member parameter. Find more in the Autopilot documentation.

contacts#save()

Parameters:

  • data - An Object containing new/existing user details

Example:

const contactData = {
  'email': 'johndoe@example.com',
  'Full Name': 'John Doe',
  'Gender': 'male',
  'age': 35,
};

await autopilot.contacts.save(contactData);
//=> { contact_id: 'person_32941749279223008202071' }

// saving multiple contacts at once
const multipleContactsData = [
  {
    email: 'test@example.com',
    FirstName: 'Seeker',
    LastName: 'Drew',
    'Full Name': 'Seeker Drew',
    foo: true,
    age: 21,
  },
  {
    email: 'test1@example.com',
    FirstName: 'Bill',
    LastName: 'Gates',
    'Full Name': 'Bill Gates',
    foo: false,
    age: 25,
  },
];
await autopilot.contacts.save(multipleContactsData);

contacts#get()

Parameters:

  • args - This must be a email/contact_id string or an array of email/contact_ids to retrieve

Example:

// get contact data by email
const contactByEmail = await autopilot.contacts.get('chris@autopilothq.com');

// get contact data by id
const contactById = await autopilot.contacts.get('person_9EAF39E4-9AEC-4134-964A-D9D8D54162E7');

// get list of contact data by either email or id
const contacts = await autopilot.contacts.get(['chris@autopilothq.com', 'person_9EAF39E4-9AEC-4134-964A-D9D8D54162E7']);

contacts#delete()

Parameters:

  • emailOrId - As the name suggest, it must be an email or contact_id

Example:

// NB: the delete API doesn't return any object. You'll know it failed when the promise fails.
await autopilot.contacts.delete('person_9EAF39E4-9AEC-4134-964A-D9D8D54162E7');
//=> undefined

await autopilot.contacts.delete('test@example.com');
//=> undefined

contacts#unsubscribe()

Parameters:

  • emailOrId - As the name suggest, it must be an email or contact_id to unsubscribe

Example:

await autopilot.contacts.unsubscribe('test@example.com');
//=> undefined

Keywords

FAQs

Package last updated on 12 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc