Negatory. Postpone Mission.

    zalo-api-service
    TypeScript icon, indicating that this package has built-in type declarations

    1.4.6 • Public • Published

    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 docs This library Status
    Social API
    Get access token Social.access_token()
    Send message to friend Social.message()
    Invite friend Social.app_request()
    Post feed Social.feed()
    List friends Social.friends()
    Invitable friends Social.invitable_friends()
    Get profile Social.profile()
    Official Account API
    Reply follower's message OA.reply_message()
    Send message OA.message()
    Shortcut APIs:
    OA.text_message()
    OA.media_message()
    OA.list_message()
    OA.request_info_message()
    Broadcast OA.broadcast()
    Update follower info OA.update_follower_info()
    Manage IP OA.register_ip()
    OA.remove_ip()
    Get infos OA.get_followers()
    OA.get_profile()
    OA.get_info()
    OA.get_recent_chat()
    OA.get_conversation()
    Upload image/file OA.upload_image()
    OA.upload_gif()
    OA.upload_file()
    Get/assign/remove tags OA.list_tags()
    OA.assign_tag()
    OA.remove_follower_tag()
    OA.delete_tag()
    Shop API
    Attributes type CRUD 🔳
    Upload photo 🔳
    Get industry 🔳
    Category 🔳
    Create order 🔳
    Manage order 🔳
    Products 🔳
    Article API
    Create article 🔳
    Upload video for article 🔳
    Get article ID 🔳
    Get article details 🔳
    Get list articles 🔳
    Delete article 🔳
    Update article 🔳

    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'
      }
    })

    Install

    npm i zalo-api-service

    DownloadsWeekly Downloads

    2

    Version

    1.4.6

    License

    ISC

    Unpacked Size

    8.13 kB

    Total Files

    5

    Last publish

    Collaborators

    • hieudv1408