Skip to content

WazapIO/client-javascript

Repository files navigation

WhatsAPI

WhatsApi - JavaScript client for WhatsAPI The V2 of WhatsAPI Go This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 2.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.JavascriptClientCodegen

Installation

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install WhatsAPI --save

Finally, you need to build the module:

npm run build
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

To use the link you just defined in your project, switch to the directory you want to use your WhatsAPI from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

Finally, you need to build the module:

npm run build

git

If the library is hosted at a git repository, e.g.https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var WhatsApi = require('WhatsAPI');

var defaultClient = WhatsApi.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
var ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix['Authorization'] = "Token"

var api = new WhatsApi.BusinessManagementApi()
var instanceKey = "instanceKey_example"; // {String} Instance key
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.fetchCatlog(instanceKey, callback);

Documentation for API Endpoints

All URIs are relative to /api

Class Method HTTP request Description
WhatsApi.BusinessManagementApi fetchCatlog GET /instances/{instance_key}/business/catalog Fetches the catlog.
WhatsApi.BusinessManagementApi sendPaymentRequest POST /instances/{instance_key}/business/payment-request Send a payment request.
WhatsApi.GroupManagementApi addParticipant POST /instances/{instance_key}/groups/{group_id}/participants/add Add participant.
WhatsApi.GroupManagementApi createGroup POST /instances/{instance_key}/groups/create Create group.
WhatsApi.GroupManagementApi demoteParticipant PUT /instances/{instance_key}/groups/{group_id}/participants/demote Demote participant.
WhatsApi.GroupManagementApi getAdminGroups GET /instances/{instance_key}/groups/admin Get admin groups.
WhatsApi.GroupManagementApi getAllGroups GET /instances/{instance_key}/groups/ Get all groups.
WhatsApi.GroupManagementApi getAllParticipants GET /instances/{instance_key}/groups/{group_id}/participants Get all participants.
WhatsApi.GroupManagementApi getGroup GET /instances/{instance_key}/groups/{group_id} Get group.
WhatsApi.GroupManagementApi getGroupFromInviteLink GET /instances/{instance_key}/groups/invite-info Get group from invite link.
WhatsApi.GroupManagementApi getGroupInviteCode GET /instances/{instance_key}/groups/{group_id}/invite-code Get group invite code.
WhatsApi.GroupManagementApi joinGroupWithLink GET /instances/{instance_key}/groups/join Join group with invite code.
WhatsApi.GroupManagementApi leaveGroup DELETE /instances/{instance_key}/groups/{group_id}/ Leaves the group.
WhatsApi.GroupManagementApi promoteParticipant PUT /instances/{instance_key}/groups/{group_id}/participants/promote Promote participant.
WhatsApi.GroupManagementApi removeParticipant DELETE /instances/{instance_key}/groups/{group_id}/participants/remove Remove participant.
WhatsApi.GroupManagementApi setGroupAnnounce PUT /instances/{instance_key}/groups/{group_id}/announce Set group announce.
WhatsApi.GroupManagementApi setGroupDescription PUT /instances/{instance_key}/groups/{group_id}/description Set group description.
WhatsApi.GroupManagementApi setGroupLocked PUT /instances/{instance_key}/groups/{group_id}/lock Set group locked.
WhatsApi.GroupManagementApi setGroupName PUT /instances/{instance_key}/groups/{group_id}/name Set group name.
WhatsApi.GroupManagementApi setGroupPicture PUT /instances/{instance_key}/groups/{group_id}/profile-pic Set group picture.
WhatsApi.InstanceApi changeWebhookUrl PUT /instances/{instance_key}/webhook Change Webhook url.
WhatsApi.InstanceApi createInstance POST /instances/create Creates a new instance key.
WhatsApi.InstanceApi deleteInstance DELETE /instances/{instance_key}/delete Delete Instance.
WhatsApi.InstanceApi getContacts GET /instances/{instance_key}/contacts Get contacts.
WhatsApi.InstanceApi getInstance GET /instances/{instance_key}/ Get Instance.
WhatsApi.InstanceApi getQrCode GET /instances/{instance_key}/qrcode Get QrCode.
WhatsApi.InstanceApi listInstances GET /instances/list Get all instances.
WhatsApi.InstanceApi logoutInstance DELETE /instances/{instance_key}/logout Logout Instance.
WhatsApi.MessageSendingApi sendAudio POST /instances/{instance_key}/send/audio Send raw audio.
WhatsApi.MessageSendingApi sendButtonMessage POST /instances/{instance_key}/send/buttons Send a button message.
WhatsApi.MessageSendingApi sendButtonWithMedia POST /instances/{instance_key}/send/button-media Send a button message with a media header.
WhatsApi.MessageSendingApi sendContact POST /instances/{instance_key}/send/contact Send a contact message.
WhatsApi.MessageSendingApi sendDocument POST /instances/{instance_key}/send/document Send raw document.
WhatsApi.MessageSendingApi sendGroupInvite POST /instances/{instance_key}/send/group-invite Send a group invite message
WhatsApi.MessageSendingApi sendImage POST /instances/{instance_key}/send/image Send raw image.
WhatsApi.MessageSendingApi sendListMessage POST /instances/{instance_key}/send/list Send a List message.
WhatsApi.MessageSendingApi sendLocation POST /instances/{instance_key}/send/location Send a location message.
WhatsApi.MessageSendingApi sendMediaMessage POST /instances/{instance_key}/send/media Send a media message.
WhatsApi.MessageSendingApi sendPollMessage POST /instances/{instance_key}/send/poll Send a Poll message.
WhatsApi.MessageSendingApi sendTemplate POST /instances/{instance_key}/send/template Send a template message.
WhatsApi.MessageSendingApi sendTemplateWithMedia POST /instances/{instance_key}/send/template-media Send a template message with media.
WhatsApi.MessageSendingApi sendTextMessage POST /instances/{instance_key}/send/text Send a text message.
WhatsApi.MessageSendingApi sendVideo POST /instances/{instance_key}/send/video Send raw video.
WhatsApi.MessageSendingApi uploadMedia POST /instances/{instance_key}/send/upload Upload media.
WhatsApi.MessageSendingApi uploadMediaFromUrl POST /instances/{instance_key}/send/upload-url Upload media from url.
WhatsApi.MiscellaneousApi downloadMedia POST /instances/{instance_key}/misc/download Download media
WhatsApi.MiscellaneousApi getProfilePic GET /instances/{instance_key}/misc/profile-pic Get profile pic.
WhatsApi.MiscellaneousApi getUsersInfo POST /instances/{instance_key}/misc/user-info Fetches the users info.
WhatsApi.MiscellaneousApi setChatPresence POST /instances/{instance_key}/misc/chat-presence Set chat presence
WhatsApi.MiscellaneousApi updateProfilePic PUT /instances/{instance_key}/misc/profile-pic Update profile picture

Documentation for Models

Documentation for Authorization

ApiKeyAuth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published