Giter Club home page Giter Club logo

branchio-sdk's Introduction

Branch.io logo

This is an unofficial sdk for branch.io. See API reference for what you can do with branch here

Features

  • Initialize SDK using either appId or branchKey

Installation

> npm install branchio-sdk

Usage

const branchio = require('branchio-sdk')

const client = branchio({ 
  appId: <APP_ID>,
  key: <BRANCH_IO_KEY>  // initialize branchio with either appId or branch key and branch secret but not both
  secret: <BRANCH_IO_SECRET>
})

const { url } = await client.link({ 
  alias: '',
  stage: 'new user',
  channel: 'facebook',
  feature: 'dashboard',
  campaign: 'content 123',
  tags: [ 'tag1', 'tag2', 'tag3' ],
  data: {
    'custom_bool': true,
    '$og_title': 'Title',
    '$og_description': 'Description',
    '$og_image_url': 'https://lorempixel.com/400/400'
  }
})
//=> https://example.app.link/0AjuiLcpqF

Methods

link()

This method is use for creating a deep link. See corresponding docs here

const { url } = await client.link({ 
  alias: '',
  stage: 'new user',
  channel: 'facebook',
  feature: 'dashboard',
  campaign: 'content 123',
  tags: [ 'tag1', 'tag2', 'tag3' ],
  data: {
    'custom_bool': true,
    '$og_title': 'Title',
    '$og_description': 'Description',
    '$og_image_url': 'https://lorempixel.com/400/400'
  }
})
//=> https://example.app.link/0AjuiLcpqF

bulkLinks()

This method allows you to create multiple deep links at a go. See docs

const links = await client.bulkLinks([
  {
    stage: 'new user',
    channel: 'facebook',
    feature: 'dashboard',
    campaign: 'content 123',
    tags: [ 'tag1', 'tag2', 'tag3' ],
    data: {
      'custom_bool': true,
      '$og_title': 'Title',
      '$og_description': 'Description',
      '$og_image_url': 'https://lorempixel.com/400/400'
    }
  },
  {
    stage: 'new user',
    channel: 'facebook',
    feature: 'dashboard',
    campaign: 'content 123',
    tags: [ 'tag1', 'tag2', 'tag3' ],
    data: {
      'custom_bool': true,
      '$og_title': 'Title',
      '$og_description': 'Description',
      '$og_image_url': 'https://lorempixel.com/400/400'
    }
  }
])
// => [{ url: 'https://example.app.link/xUrsD0P' }, { url: 'https:/example.app.link/erTweDt' }]

readLink()

This method is for reading details of a deep link. See corresponding docs here

const linkData = await client.readLink('https://example.app.link/0AjuiLcpqF')
//=> link data

updateLink()

This method is for updating details of a deep link

const client = branch({ key: '<BRANCH_IO_KEY', secret: '<BRANCH_IO_SECRET' })

const updateData = await client.updateLink({ 
  deepLink: 'https://example.app.link/ggxaqsx1dR',
  data: {
    channel: 'twitter',
    data: {
      name: 'John',
      user_id: 2481084010
    }
  }
 })

//=> link data

TODO:

  • Add method to read link
  • Add method to update link
  • Add method to update link tips
  • Add method to create events
  • Add method to create commerce events
  • Add method to read user
  • Add method to create referral link
  • Add method to create referral reward

...

Maintainers

Samuel Amoah

branchio-sdk's People

Contributors

snamoah avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.