> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hypersender.com/llms.txt
> Use this file to discover all available pages before exploring further.

# WhatsApp Number Checker and Contacts API in Python

> Check if a phone number has WhatsApp, list and save contacts, get profile pictures, and resolve LIDs from Python with the Hypersender WhatsApp API.

## Overview

Look up information about WhatsApp contacts. Contact methods live under `hs.whatsapp.contacts`.

## Contacts

### Check if a Number Has WhatsApp

Use this as a WhatsApp number checker: find out whether a phone number has a WhatsApp account before you message it, and get its chat ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/check-contact-exists.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.contacts.check_contact_exists("20123456789")
>
> print(result["numberExists"], result["chatId"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | phone | str | yes | Phone number with country code, without `+` or spaces |

### Get All Contacts

List the contacts saved on the instance, with pagination and sorting. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-all-contacts.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.contacts.get_all_contacts(
>     limit=100,
>     offset=0,
>     sort_by="name",
>     sort_order="asc",
> )
>
> contacts = result["data"]
> ```

> [tab] Parameters
>
> All parameters are keyword-only.
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | limit | int | no | Number of contacts to return, 1-1000 (default: 100) |
> | offset | int | no | Number of contacts to skip (default: 0) |
> | sort\_by | str | no | `"id"` or `"name"` (default: `"name"`) |
> | sort\_order | str | no | `"asc"` or `"desc"` (default: `"asc"`) |

### Get a Contact

Get a single contact by phone number or chat ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-contact.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.contacts.get_contact("20123456789@c.us")
>
> print(result["data"]["name"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | Phone number (`123123123`) or chat ID (`123123@c.us` or `123123@lid`), passed as the first argument |

### Get WhatsApp Profile Picture

Get the URL of a contact's WhatsApp profile picture. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-profile-picture.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.contacts.get_profile_picture("20123456789@c.us")
>
> print(result["data"]["profilePictureURL"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | Phone number (`123123123`) or chat ID (`123123@c.us` or `123123@lid`), passed as the first argument |

### Create or Update a Contact

Save a contact on the instance, or update its name if it already exists. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/upsert-contact.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> hs.whatsapp.contacts.upsert_contact(
>     "20123456789@c.us",
>     first_name="John",
>     last_name="Doe",
> )
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | chat\_id | str | yes | Phone number (`123123123`) or chat ID (`123123@c.us` or `123123@lid`) |
> | first\_name | str | yes | The contact's first name |
> | last\_name | str | no | The contact's last name |

## LIDs

WhatsApp sometimes identifies contacts by a LID (linked identifier, e.g. `1111111@lid`) instead of their phone number. Use these methods to map between the two. [(learn more about LIDs)](https://docs.hypersender.com/v2/hypersender/overview/whatsapp/whatsapp-lid-issue.md)

### Get Phone Number by LID

Resolve a LID to the contact's phone-number chat ID. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-phone-number-by-lid.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> mapping = hs.whatsapp.contacts.get_phone_number_by_lid("1111111@lid")
>
> # {"lid": "1111111@lid", "pn": "3333333@c.us"}
> print(mapping["pn"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | lid | str | yes | The LID to resolve, e.g. `1111111@lid` or `1111111` (passed as the first argument) |

### Get LID by Phone Number

Find the LID linked to a phone number. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-lid-by-phone-number.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> mapping = hs.whatsapp.contacts.get_lid_by_phone_number("3333333@c.us")
>
> # {"lid": "1111111@lid", "pn": "3333333@c.us"}
> print(mapping["lid"])
> ```

> [tab] Parameters
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | phone\_number | str | yes | The phone number to resolve, e.g. `3333333@c.us` or `3333333` (passed as the first argument) |

### Get All Known LIDs

List the LID to phone number mappings the instance knows about. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-all-known-lids.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> mappings = hs.whatsapp.contacts.get_all_known_lids(limit=100, offset=0)
>
> # [{"lid": "1111111@lid", "pn": "3333333@c.us"}, ...]
> print(len(mappings))
> ```

> [tab] Parameters
>
> All parameters are keyword-only.
>
> | Parameter | Type | Required | Description |
> | - | - | - | - |
> | limit | int | no | Maximum number of mappings to return (default: 100) |
> | offset | int | no | Number of mappings to skip (default: 0) |

### Get LIDs Count

Get how many LID mappings the instance knows about. [(learn more)](https://docs.hypersender.com/v2/api-reference/whatsapp/contacts/get-count-of-lids.md)

> [tab] Basic Usage
>
> ```python theme={null}
> from hypersender import Hypersender
>
> hs = Hypersender()
>
> result = hs.whatsapp.contacts.get_lids_count()
>
> print(result["count"])
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.