---
updatedAt: 2025-11-24T14:23:47.000Z
agentTools:
  projectIndex: https://api-docs.thedatatrust.com/llms.txt
---

# Basic Voter Lookup

```python Python
import requests
import pandas as pd
import json

client_id = 'your-client-id'
client_secret = 'your-client-secret'

def get_auth_token():
    auth_url = 'https://api.thedatatrust.com/api/Authenticate'
    headers = {
        'Content-Type': 'application/json'
    }

    payload = {
        'clientId': client_id,
        'clientSecret': client_secret
    }

    response = requests.post(auth_url, headers=headers, json=payload)
    response_json = response.json()
    if 'AccessToken' in response_json:
        access_token = response_json['AccessToken']
        return access_token
    else:
      raise Exception('Failed to obtain authorization token')
      
access_token = get_auth_token()

#API Endpoint
api_endpoint = 'https://api.thedatatrust.com/api/VoterFile'

# Headers
headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json'
}

# Request payload
params = {
   "state": "VA",
   "top": "1",
   "firstName": "John",
   "lastName": "Smith"
    }

# Making the GET request
response = requests.get(api_endpoint, params=params, headers=headers)

if response.status_code == 200:
    data = json.loads(response.text)
    df = pd.DataFrame(data)
    display(df)
else:
    print(f"Request failed with status code {response.status_code}")

 
```

# Import required modules

<!-- python@1-3 -->



# Define Authentication Function

<!-- python@5-25 -->

Build a function to pass your clientId and clientSecret and generate a bearer token

# Get your bearer token

<!-- python@27 -->

Call your function to generate a token

# Define endpoint and headers

<!-- python@29-36 -->



# Specify query parameters

<!-- python@39-44 -->

State is required!

# Perform lookup and display response

<!-- python@46-54 -->