Learn R Programming

whapi (version 0.0.2)

whapi_get_contact_profile: Get WhatsApp contact profile(s) via Whapi.Cloud

Description

Fetches profile information for one or more contacts using GET /contacts/{ContactID}/profile and returns a tidy tibble. This version assumes the response body contains:

  • name (string, user name),

  • about (string, user info in About section),

  • icon (string, profile preview icon URL),

  • icon_full (string, full avatar URL).

Usage

whapi_get_contact_profile(
  contacts,
  token = Sys.getenv("WHAPI_TOKEN", unset = ""),
  full = TRUE,
  timeout = 30,
  verbose = TRUE
)

Value

A tibble with one row per contact:

  • contact_id (input id or JID as queried),

  • name, about, icon, icon_full,

  • resp with the raw response (list).

Arguments

contacts

Character vector. Phones in E.164 digits (no "+") or chat IDs.

token

Bearer token. Defaults to env var WHAPI_TOKEN.

full

Logical. If TRUE, add _full=true query param. Default TRUE.

timeout

Numeric. Request timeout (seconds). Default 30.

verbose

Logical. Print progress with cli? Default TRUE.

Details

  • Each contacts element may be a phone number (free text) or a JID (e.g., "1203...@g.us"). Phone numbers are normalized via whapi_normalize_to() (12 digits total); JIDs are kept as-is.

  • When full = TRUE, _full=true is added to the querystring to request higher-resolution avatars (if supported).

Examples

Run this code
if (FALSE) {

 Sys.setenv(WHAPI_TOKEN = "your_token_here")
# Single:
 whapi_get_contact_profile("5581999999999")

# Mixed (number + group JID):
 whapi_get_contact_profile(c("5581999999999", "1203630xxxxxx@g.us"))
}

Run the code above in your browser using DataLab