# Look up a number with Python

You can quickly see how the Number Lookup API works by looking up a number using the Python SDK.

In this guide you will learn:
1. How to [set up](#set-up-your-python-application-and-install-dependencies) your Python application.
2. [Look up](#look-up-your-phone-number) your phone number.


## What you need to know before you start

Before you can get started, you need the following already set up:

* Set all Number Lookup API [configuration settings](/docs/number-lookup-api-v2/getting-started).
* [Python](https://www.python.org/) and a familiarity with how to create a new file.
* [Poetry](https://python-poetry.org/) for dependency management
* [PIP (package installer for Python)](https://pypi.org/project/pip/) and a familiarity with how to install Python modules.


## Set up your Python application

To quickly get started setting up a simple client application using the Python SDK:

1. If you haven't already, clone the [sinch-sdk-python](https://github.com/sinch/sinch-sdk-python) repository.
2. Navigate to the `examples/snippets` folder.
3. Copy the example `.env` file by running the following command:


Linux/Mac
```bash
cp .env.example .env
```

Windows (Command Prompt)
```cmd
copy .env.example .env
```

Windows (Powershell)
```powershell
Copy-Item .env.example .env
```

1. Open the `.env` [file](https://github.com/sinch/sinch-sdk-python/blob/main/examples/snippets/.env.example) you just created. Using the [access key credentials](https://dashboard.sinch.com/settings/access-keys) from your Sinch Build Dashboard, populate the following fields with your values:


| Field | Description |
|  --- | --- |
| SINCH_PROJECT_ID | The unique ID of your Project. |
| SINCH_KEY_ID | The unique ID of your access key. |
| SINCH_KEY_SECRET | The secret that goes with your access key.  **Note:** For security reasons, this secret is only visible right after access key creation. |


1. Save the file.
2. The Python SDK uses [Poetry](https://python-poetry.org/) to manage packages and dependencies, so install those dependencies using the following command:


```cmd
poetry install
```

## Modify your code

1. Navigate to `examples/snippets/number_lookup/lookup/` and open the `snippet.py` file.


snippet.py
```python snippet.py
# Use this code to look up a phone number using the Number Lookup API. 
"""
Sinch Python Snippet

This snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets
"""

import os
from dotenv import load_dotenv
from sinch import SinchClient

load_dotenv()

sinch_client = SinchClient(
    project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID",
    key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID",
    key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET",
)

# The phone number to look up in E.164 format (e.g. +1234567890)
phone_number = "PHONE_NUMBER"

response = sinch_client.number_lookup.lookup(number=phone_number)

print(f"Number lookup result:\n{response}")
```

1. Before you can run the code, you need to update some values. Update the following parameters with your own values:
Assign your values to the following parameters:
| Parameter | Your value |
|  --- | --- |
| `phone_number` | The phone number that you want to look up in [E.164](https://community.sinch.com/t5/Glossary/E-164/ta-p/7537) format. |
2. Save the file.


## Look up your phone number

Now you can execute the code and look up your phone number. Run the following command:

```shell
python examples/snippets/number_lookup/lookup/snippet.py
```

You should receive a response in your console with details about the phone number you specified.

Troubleshooting tip
If after running your app you receive a 5000 error response, you may have forgotten to save your file after adding your authentication values. This is an easy mistake to make! Try saving the file and running the app again.

## Additional resources

- [API specification](/docs/number-lookup-api-v2/api-reference/)