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

@infobip-api/sdk

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@infobip-api/sdk

Node.js Client SDK for Infobip APIs.

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4K
decreased by-18.37%
Maintainers
3
Weekly downloads
 
Created
Source

infobip-api-node-sdk

Node.js Client SDK for Infobip APIs.

Supported Channels

  • Whatsapp -> Docs
  • Email -> Docs
  • SMS -> Docs
Table of Contents:

General Info

For the @infobip-api/sdk package versioning we use the Semantic Versioning scheme.

Node.js 14 is minimum supported version by this SDK.

License

Published under an MIT License.

Installation

Install the library by using the following command:

npm install @infobip-api/sdk

Code Example

The package is intended to be used with an Infobip account. If you don't already have one, you can create a free trial account here.

This example shows you how to send a WhatsApp text message. The first step is to import the Infobip and AuthType dependencies.

import { Infobip, AuthType } from "@infobip-api/sdk";

Next, you need to create an instance of Infobip with your API Base URL and authentication mechanism. You can find all this information on the Infobip Portal.

let infobip = new Infobip({
  baseUrl: "YOUR_BASE_URL",
  apiKey: "YOUR_API_KEY",
  authType: AuthType.ApiKey,
});

After that you can access all the objects from infobip.channel.

To send text message you can use the infobip.channel.whatsapp.send method and add a payload:

let response = await infobip.channels.whatsapp.send({
  type: "text",
  from: "447860099299",
  to: "447123456789",
  content: {
    text: "Hello World",
  },
});

console.log(response);

E-mail Attachment Example

When sending an E-mail with an attachment or inline image, you'll need follow the below process

``javascript import { Infobip, AuthType } from "@infobip-api/sdk";


Next, you need to create an instance of `Infobip` with your API Base URL and authentication mechanism. You can find all this information on the [Infobip Portal](https://portal.infobip.com/homepage/).

```javascript
let infobip = new Infobip({
  baseUrl: "YOUR_BASE_URL",
  apiKey: "YOUR_API_KEY",
  authType: AuthType.ApiKey,
});

And to send with an attachment, the following way to identify it

let response = await infobip.channels.email.send({
  to: 'test@example.com',
  from: 'Tests <testing@example.com>',
  subject: 'Testing',
  text: 'hello world',
  attachment: [{
    data: Fs.readFile('/path/to/your/file'),
    name: 'name-of-the-attachment-in-the-email',
  }]
})

console.log(response);

Testing

To run tests position yourself in the project's root after you've installed dependencies and run:

npm run test

Building & Installing a Local Version

To build the project for the first time, position yourself in the project's root and run:

npm install

Subsequent builds can be triggered by using:

npm run build

After building a local version of this SDK, you can use it in a local Node.js project. First, position yourself in the new project root, and then run:

npm install ../path/to/infobip-node

Keywords

FAQs

Package last updated on 23 Nov 2023

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