0.3.0 • Published 4 years ago

zalo-api v0.3.0

Weekly downloads
28
License
ISC
Repository
github
Last release
4 years ago

Zalo API

Integrate with Zalo API easily. Support typescript with types of request and response following Zalo documentation.

Getting started

Install with npm

npm i zalo-api

or yarn

yarn add zalo-api

Zalo API mapping

Zalo docsThis libraryStatus
Social API
Get access tokenSocial.access_token():white_check_mark:
Send message to friendSocial.message():white_check_mark:
Invite friendSocial.app_request():white_check_mark:
Post feedSocial.feed():white_check_mark:
List friendsSocial.friends():white_check_mark:
Invitable friendsSocial.invitable_friends():white_check_mark:
Get profileSocial.profile():white_check_mark:
Official Account API
Reply follower's messageOA.reply_message():white_check_mark:
Send messageOA.message() Shortcut APIs: OA.text_message() OA.media_message() OA.list_message() OA.request_info_message():white_check_mark:
BroadcastOA.broadcast():white_check_mark:
Update follower infoOA.update_follower_info():white_check_mark:
Manage IPOA.register_ip()OA.remove_ip():white_check_mark:
Get infosOA.get_followers()OA.get_profile()OA.get_info()OA.get_recent_chat()OA.get_conversation():white_check_mark:
Upload image/fileOA.upload_image()OA.upload_gif()OA.upload_file():white_check_mark:
Get/assign/remove tagsOA.list_tags()OA.assign_tag()OA.remove_follower_tag()OA.delete_tag():white_check_mark:
Shop API
Attributes type CRUD:white_square_button:
Upload photo:white_square_button:
Get industry:white_square_button:
Category:white_square_button:
Create order:white_square_button:
Manage order:white_square_button:
Products:white_square_button:
Article API
Create article:white_square_button:
Upload video for article:white_square_button:
Get article ID:white_square_button:
Get article details:white_square_button:
Get list articles:white_square_button:
Delete article:white_square_button:
Update article:white_square_button:

Using Zalo API integration

Social API

Get access token

Parameters

{
  app_id: string,
  app_secret: string,
  code: string,
  redirect_uri?: string
}

Return

{
  access_token: string,
  expires_in: number
}

Example

import { Social } from 'zalo-api';

const access_token = Social.access_token({
  app_id: 'your_app_id', // process.env.zalo_app_id
  app_secret: 'your_app_secret', // process.env.zalo_app_secret
  code: 'your_oauth_code', // refer document here https://developers.zalo.me/docs/api/social-api/tham-khao/user-access-token-post-4316
})

Official Account API

OA Message

Send generic message with all available parameters Parameters

{
  access_token: string,
  recipient: {
    message_id?: string,
    user_id?: string,
    target?: {}
  },
  message: {
    text?: string,
    attachment?: {
      type: 'template' | 'file',
      payload: {
        template_type?: 'list' | 'media' | 'request_user_info'
        elements?: {} //Depends on types
        buttons?: {}
        ...
      } 
    }
  }
}

Return (same for all message API)

{
  error?: number,
  message: string,
  data?: {
    message_id: string
  }
}

Example

import { OA } from 'zalo-api';

const access_token = OA.message({
  access_token: 'your_oa_access_token', // https://developers.zalo.me/docs/api/official-account-api/phu-luc/official-account-access-token-post-4307
  recipient: {
    user_id: 'user_id'
  }
  message: {
    text: 'Hello Zalo API'
  }
})
0.3.0

4 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.0.1

5 years ago