npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@trieb.work/zadarma

v1.3.0

Published

Module which help you work with API Zadarma (v1). Worker in edge functions and node

Readme

version npm downloads per month license

GitHub last commit Github Repository Size Github forks Lines of code GitHub open issues GitHub closed issues

GitHub Repo stars GitHub User's stars

zadarma

Zadarma Nodes.js

Module which help you work with API Zadarma (v1)

Requirements:

  • Node.js > 14.0.0

How to use?

An official documentation on Zadarma API is here.

Getting Started

Install

#npm
npm install zadarma
#or
npm i zadarma

Authorization keys

Page authorization keys: here

Usage examples

const { api } = require("zadarma");

single account use

//Example configure default config
const { api } = require("zadarma");

process.env.ZADARMA_USER_KEY = 'a248a6a984459935b569';//your user key
process.env.ZADARMA_SECRET_KEY = '8a8e91d214fb728889c7';//your secret key

(async () => {
    //https://zadarma.com/ru/support/api/#api_info_balance
    let balance = await api({api_method: '/v1/info/balance/'});
    
    //https://zadarma.com/ru/support/api/#api_info_timezone
    let timezone = await api({api_method: '/v1/info/timezone/'});

    //https://zadarma.com/ru/support/api/#api_tariff
    let tariff = await api({api_method: '/v1/tariff/'});

    console.log(balance);
    console.log(timezone);
    console.log(tariff);
})()

multi account use

//Example with send "api_user_key" && "api_secret_key"
const { api: z_api/*rename "api": "your name"*/ } = require("zadarma");

(async () => {

    let response = await z_api({
        api_method: '/v1/direct_numbers/',
        api_user_key: 'a248a6a984459935b569', //your user key
        api_secret_key: '8a8e91d217fb728889c7' //your secret key
    });
    console.log(response);

})()
const { api: z_api } = require("zadarma");

let method = '/v1/pbx/internal/';
let user_key = 'your_user_key';
let secret_key = 'your_secret_key';

(async () => {
    let dataObj = await z_api({
        api_method: method,
        api_user_key: user_key,
        api_secret_key: secret_key
    });
    console.log(dataObj);
})()
const { api: z_api } = require("zadarma");

let method = '/v1/pbx/callinfo/';
let user_key = 'your_user_key';
let secret_key = 'your_secret_key';

(async () => {
    let dataObj = await z_api({
        api_method: method,
        api_user_key: user_key,
        api_secret_key: secret_key
    });
    console.log(dataObj);
})()

parameters

//https://zadarma.com/ru/support/api/#api_callback
const { api: z_api } = require("zadarma");

let userKey = 'your_user_key 20 symbols';
let secretKey = 'user_secret_key 20 symbols';

(async () => {
    //Example with parameters
    let response = await z_api({
        api_method: '/v1/request/callback/',
        api_user_key: userKey,
        api_secret_key: secretKey,
        params: {
            from: '73919100000',
            to: '67200000000',
            sip: '100',
            predicted: 'predicted'
        }
    });
    console.log(response);
})()

http_method "post"

//https://zadarma.com/ru/support/api/#api_sms_send

let from = '67200000000'; //[optional] your verified phone number
let to = '67200000000';
let message = 'Test sms 0987654321\nТестовый текст';

let response = await z_api({
    http_method: 'POST',
    api_method: '/v1/sms/send/',
    params: {
        caller_id: from, //[optional]
        number: to,
        message: message
    }
});
console.log(response);

zcrm methods examples

ZCRM integration on/off page here

//example get all customers
process.env.ZADARMA_USER_KEY = 'a248a6a984459935b569';//your user key
process.env.ZADARMA_SECRET_KEY = '8a8e91d214fb728889c7';//your secret key

let response = await z_api({
    api_method: '/v1/zcrm/customers'
});
console.log(response);
//example create customer
let response = await z_api({
    http_method: 'POST',
    api_method: '/v1/zcrm/customers',
    params: {
        customer: {
            "name": "Good company 32",
            "status": "company",
            "type": "client",
            "responsible_user_id": "",
            "employees_count": "50",
            "comment": "",
            "country": "GB",
            "city": "London",
            "address": "",
            "zip": "",
            "website": "",
            "lead_source": "manual",
            "phones": [{
                "type": "work",
                "phone": "+44123456100"
            }],
            "contacts": [{
                "type": "email_work",
                "value": "[email protected]"
            }],
            "labels": [],
            "custom_properties": []
        }
    }
});
console.log(response);
//example create, get, delete customers

//create labal 1
let response = await z_api({
    http_method: 'POST',
    api_method: '/v1/zcrm/customers/labels',
    params: {
        name: 'label 1'
    }
});

//create label 2
response = await z_api({
    http_method: 'POST',
    api_method: '/v1/zcrm/customers/labels',
    params: {
        name: 'label 2'
    }
});

//get all labels
response = await z_api({
    api_method: '/v1/zcrm/customers/labels'
});
console.log(response.data.labels);

for (label of response.data.labels) {
    //delete label
    response = await z_api({
        http_method: 'DELETE',
        api_method: `/v1/zcrm/customers/labels/${label.id}`
    });
    console.log( `label id ${label.id} deleted!` );
}

//get all labels
response = await z_api({
    api_method: '/v1/zcrm/customers/labels'
});
console.log(response.data.labels);

Handle event requests with Express

API settings and description page

Set link to your hendler server on API description page

Example link: http://YOUR_IP:3000/zadarma

Events

  1. NOTIFY_START - start incoming call
  2. NOTIFY_INTERNAL - dialing up to the internal on incoming call
  3. NOTIFY_ANSWER - the internal answered theincoming call
  4. NOTIFY_END - end incoming call
  5. NOTIFY_OUT_START
  6. NOTIFY_OUT_END
  7. NOTIFY_RECORD - call recording is being prepared for download
  8. NOTIFY_IVR
  9. SPEECH_RECOGNITION
  10. NUMBER_LOOKUP
  11. CALL_TRACKING
  12. SMS - incoming sms
  13. NOTIFY_INTERNAL_END - halloween event ) событие не описано в документации на 22.12.2021
const { zadarma_express_handler } = require("zadarma");

const express = require('express');

const app = express();

process.env.ZADARMA_SECRET_KEY = 'de4b346b835b86158233';//your secret key

//https://zadarma.com/ru/support/api/#api_webhook_notify_start
zadarma_express_handler.on('NOTIFY_START', (request, response) => {
  
  console.log(request);

  response.set('Content-Type', 'application/json');
  //res.json({"ivr_play": "ID"})
  //res.json({"redirect": "ID", ["return_timeout": TIMEOUT]})
  //res.json({"hangup": 1})
  //res.json({"ivr_saypopular": 1, "language": "en"})

  res.json({
    "ivr_saynumber": "123",
    "language": "en"
  })

  res.end()
});


zadarma_express_handler.on('NOTIFY_END', request => {
  let all_calls_before_clear_storage = zadarma_express_handler.get_temporary_storage();
  zadarma_express_handler.clear_temporary_storage();
  console.log(request);
});


zadarma_express_handler.on('NOTIFY_OUT_START', request => {
    console.log(request);
    
});

zadarma_express_handler.on('NOTIFY_OUT_END', request => {
  zadarma_express_handler.clear_temporary_storage(request.pbx_call_id);
  console.log(request);
});


const { api: z_api/*rename "api": "your name"*/ } = require("zadarma");

zadarma_express_handler.on('NOTIFY_RECORD', async incoming_request => {
    //Need dalay, if not wait few time, servise Zadarma send message ~~~"File not found"!
    setTimeout(async () => {
    
        let res = await z_api({
            api_method: '/v1/pbx/record/request/',
            api_user_key: 'a248a6a984459935b569', // || [process.env.ZADARMA_USER_KEY]
            api_secret_key: '8a8e91d217fb728889c7', // || [process.env.ZADARMA_SECRET_KEY]
            params: {
                pbx_call_id: incoming_request.pbx_call_id,
                lifetime : 7200
            }
        });
        console.log(res)
        //console.log(res.data.links[0] ? res.data.links[0]: res.data.link)
        //console.log(res.links[0] ? res.links[0]: res.link)
        
    }, 15000);//15sec [variable, need test optimal time dalay] if not important put more
});

zadarma_express_handler.on('SMS', request => {
  console.log(request);
});

app.use('/zadarma', zadarma_express_handler);
app.listen(3000); //app.listen(your port)