Contacts trait provides methods for checking WhatsApp registration status, fetching contact information, and retrieving profile pictures.
Access
Access contact operations through the client:Methods
is_on_whatsapp
Check if phone numbers are registered on WhatsApp.phones- Array of phone numbers (with or without+prefix)
Vec<IsOnWhatsAppResult>- Registration status for each number
jid: Jid- WhatsApp JID for the numberis_registered: bool- Whether the number is on WhatsApp
get_info
Get detailed contact information for phone numbers.phones- Array of phone numbers (with or without+prefix)
Vec<ContactInfo>- Detailed info for each registered number
jid: Jid- WhatsApp JIDlid: Option<Jid>- LID (privacy identifier) if availableis_registered: bool- Whether on WhatsAppis_business: bool- Whether this is a business accountstatus: Option<String>- Status message/aboutpicture_id: Option<u64>- Profile picture ID
get_profile_picture
Get the profile picture URL for a JID.jid- Target JID (user, group, or newsletter)preview-truefor preview thumbnail,falsefor full-size image
Option<ProfilePicture>- Picture info orNoneif not available
id: String- Picture IDurl: String- Download URLdirect_path: Option<String>- Direct path for media download
get_user_info
Get user information by JID (more detailed thanget_info).
jids- Array of JIDs to query
HashMap<Jid, UserInfo>- Map of JID to user info
jid: Jid- WhatsApp JIDlid: Option<Jid>- LID if availablestatus: Option<String>- Status messagepicture_id: Option<String>- Profile picture ID (String format)is_business: bool- Whether business account
Type Differences
ContactInfo vs UserInfo
Both types provide similar information but with different use cases: ContactInfo (fromget_info):
- Input: phone numbers
picture_id: Option<u64>- Numeric picture ID- Used for batch phone number lookups
get_user_info):
- Input: JIDs
picture_id: Option<String>- String picture ID (may include non-numeric prefixes)- Used for detailed JID-based queries
Privacy & TC Tokens
For user JIDs (not groups/newsletters), the library automatically includes TC tokens when fetching profile pictures. TC tokens are used for privacy-gated operations. The implementation automatically:- Looks up TC tokens for user JIDs
- Includes tokens in profile picture requests
- Skips tokens for groups and newsletters
Error Handling
All methods returnResult<T, anyhow::Error>. Common errors:
- Invalid phone number format
- Invalid JID format
- Network errors
- Rate limiting