Sign inSign up

codechat/api

By codechat

•Updated 3 months ago

API for communication with whatsapp.

Image
API management
11

10K+

codechat/api repository overview

⁠Quick reference

⁠Quick reference (cont.)


Telegram Group Whatsapp Group Git Repository License

⁠What is CodeChat Api?

⁠WhatsApp-Api-NodeJs

This code is an implementation of Baileys⁠, as a stable and scalable RestFull Api service, which controls whatsapp functions.
With this you can create multiservice chats, service bots or any other system that uses whatsapp. With this code you don't need to know javascript for nodejs, just start the server and make the language requests you feel most comfortable with.

⁠Read the git repository documentation.⁠

⁠Environment variable

All environment⁠ variables have the value described in this document as default.

⁠Server
EnviromenttypeRequiredDefault value
SERVER_PORTint✅8084
SESSION_HTTP_SECRETstring✅"************"
⁠Determine the logs to be displayed
EnviromenttypeRequiredDefault value
LOG_LEVELstring🚫ERROR,WARN,DEBUG,INFO,LOG,VERBOSE,DARK
LOG_COLORboolen🚫true
⁠Cleaning up instances

Determine how long the instance should be deleted from memory in case of no connection.
Default time: 5 minutes.
If you don't even want an expiration, enter the value false.

EnviromenttypeRequiredDefault value
INSTANCE_EXPIRATION_TIMEint or boolean🚫5
⁠Webhook Settings

Define a global webhook that will listen for enabled events from all instances.

EnviromenttypeRequiredDefault value
WEBHOOK_GLOBAL_URLstring🚫""
WEBHOOK_GLOBAL_ENABLEDboolen🚫false
⁠Permanent data storage

Current compatibility is with postgres⁠ only.

EnviromenttypeRequiredDefault value
DATABASE_URLstring✅""
DATABASE_SYNC_MESSAGESboolean🚫true
DATABASE_SAVE_DATA_NEW_MESSAGEboolean🚫true
DATABASE_SAVE_MESSAGE_UPDATEboolean🚫true
DATABASE_SAVE_DATA_CONTACTSboolean🚫true
DATABASE_SAVE_DATA_CHATSboolean🚫true
DATABASE_SAVE_LOGSboolean🚫true
⁠Connection to redis

Whatsapp connection data can be saved in redis⁠.

EnviromenttypeRequiredDefault value
REDIS_ENABLEDboolean🚫false
DATABASE_SYNC_MESSAGESboolean🚫true
DATABASE_SAVE_DATA_NEW_MESSAGEboolean🚫true
DATABASE_SAVE_MESSAGE_UPDATEboolean🚫true
⁠Session Phone

Name that will be displayed on smartphone connection

EnviromenttypeRequiredDefault value
CONFIG_SESSION_PHONE_CLIENTstring🚫"CodeChat_V1"
CONFIG_SESSION_PHONE_NAMEboolean🚫"Edge"
⁠Set qrcode display limit
EnviromenttypeRequiredDefault value
QRCODE_LIMITint🚫5 seconds
QRCODE_EXPIRATION_TIMEint🚫20 seconds
⁠Maximun time to connect to whatsapp
EnviromenttypeRequiredDefault value
CONNECTION_TIMEOUTint🚫120 seconds
⁠Authentication

Defines an authentication type for the api

Define a global apikey to access all instances.
OBS: This key must be inserted in the request header to create an instance.

EnviromenttypeRequiredDefault value
AUTHENTICATION_GLOBAL_AUTH_TOKENstring✅"************"

⁠0 = never expires | 3600 = 1 hour | 86400 = 1 day | 604800 = 1 week

EnviromenttypeRequiredDefault value
AUTHENTICATION_JWT_EXPIRES_INint✅0
AUTHENTICATION_JWT_SECRETstring✅"************"
⁠MinIO - AWS S3
EnviromenttypeRequiredDefault value
S3_ENABLEDboolena🚫false
S3_ACCESS_KEYstring🚫"************"
S3_SECRET_KEYstring🚫"************"
S3_BUCKETstring🚫"bucket_name"
S3_PORTstring🚫9000
S3_ENDPOINTstring🚫"127.0.01"
S3_USE_SSLstring🚫false

⁠Start the container.

docker run -d --restart 'always' \
 --name 'api-codechat' \
 --mount 'type=bind,source=/data/instances,target=/codechat/instances' \
 --publish '8083:8083' \
 --hostname 'codechat' \
 --env-file './env' \
 --network 'codechat-net' \
 codechat/api:latest
⁠Compose
version: '3.8'

networks:
  public-network:
    driver: bridge

services:
  api:
    container_name: codechat_api
    image: codechat/api:latest
    restart: unless-stopped
    ports:
      - 8084:8084
    volumes:
      - instances_connecteds:/codechat/instances
    environment:
      - SERVER_PORT=8084
      - SESSION_SECRET=W0NvZGVDaGF0XTpbU2Vzc

      - LOG_LEVEL=ERROR|WARN|INFO|DEBUG|LOG|VERBOSE|DARK
      - LOG_COLOR=true

      - DATABASE_ENABLED=true
      - DATABASE_URL=postgres://[USER]:[PASS]@[HOST]:[PORT]/[DATABASE_NAME]?schema=public
      - DATABASE_SYNC_MESSAGES=true
      - DATABASE_SAVE_DATA_NEW_MESSAGE=true
      - DATABASE_SAVE_MESSAGE_UPDATE=true
      - DATABASE_SAVE_DATA_CONTACTS=true
      - DATABASE_SAVE_DATA_CHATS=true

      - GLOBAL_WEBHOOK_URL=url
      - GLOBAL_WEBHOOK_ENABLED=false

      - INSTANCE_EXPIRATION_TIME=false

      - CONFIG_SESSION_PHONE_CLIENT=CodeChat_V1
      - CONFIG_SESSION_PHONE_NAME=Edge

      - QRCODE_LIMIT=10
      - QRCODE_EXPIRATION_TIME=60

      - CONNECTION_TIMEOUT=300

      - AUTHENTICATION_GLOBAL_AUTH_TOKEN=zYzP7ocstxh3SJ23D4FZTCu4ehnM8v4hu
      - AUTHENTICATION_JWT_EXPIRES_IN=0
      - AUTHENTICATION_JWT_SECRET=3RFYiiRmvNiokSBrLZzx

      # - REDIS_ENABLED=false
      # - REDIS_URI=redis://[HOST]/5
      # - REDIS_PREFIX=codechat

      # - S3_ENABLED=false
      # - S3_ACCESS_KEY=[ACCESS_KEY]
      # - S3_SECRET_KEY=[SECRET_KEY]
      # - S3_BUCKET=[BUCKET]
      # - S3_PORT=9000
      # - S3_ENDPOINT=[ENDPOINT]
      # - S3_USE_SSL=false
    networks:
      - public-network
  
  # redis_cache:
  #   image: redis:latest
  #   container_name: redis_cache
  #   volumes:
  #     - redis_data:/data
  #   ports:
  #     - "6379:6379"
  #   networks:
  #     - public_network

volumes:
  instances_connecteds:
    driver: local
  # redis_data:
  #   driver: local

By CodeChat ©

Tag summary

Content type

Image

Digest

sha256:fd27858d9…

Size

210.3 MB

Last updated

3 months ago

docker pull codechat/api