Skip to main content
The official Python SDK for the Data Legion API. Includes sync and async clients, Pydantic v2 response models, and full type hints.

Installation

Requires Python 3.10+.

Authentication

Get an API key by signing up for free; it’s available in your dashboard as soon as you sign up. The same key works across the API, SDKs, MCP server, and CLI.

Person

Enrichment

Look up a person by email, phone, name, LinkedIn, or other identifiers.
Enterprise accounts can return several matches with confidence levels by setting multiple_results=True. The feature is switched on per account: ask your account manager or support@datalegion.ai. Without it, the request returns 403 feature_not_available. Each match returned is billed.
Query people using a SQL SELECT against the people table. The query must start with SELECT and must not include a LIMIT clause; pass limit as a parameter.

Discovery

Find people using natural language.

Company

Enrichment

Look up a company by domain, name, ticker, or LinkedIn.

Search

Query companies using SQL.

Discovery

Find companies using natural language.

Utility Endpoints

Utility endpoints are free and don’t consume credits.

Clean Fields

Hash Email

Validate Data

Report a Data Issue

Found something wrong in a record? Report it against its legion_id. See Report a Data Issue for the issue_type/issue_level rules.
Company records use client.utility.report_company() with the same parameters.

Async Client

The AsyncDataLegion client has the same interface but all methods are async.

Response Metadata

After each request, response metadata is available on the client.
On search/discover, total_count_status tells you how the response total was derived: exact (true count), estimate (the query planner’s row estimate, returned on broad queries where an exact count is too expensive, so treat it as a magnitude), or page (count unavailable; total is just the returned page size).

Field Filtering

Control which fields are returned in the response.

Error Handling

The SDK raises a typed exception for each error status. Every one inherits from DataLegionError, and the classes for 400, 403, 404, 408 and 5xx also inherit from APIError.
The client doesn’t retry. On a 429, client.retry_after holds the seconds to wait.

Sandbox

Pass sandbox=True to build and test without spending credits. Enrich, bulk enrich, search and discover then call the sandbox and return sample records with every field a real record has; the utilities, which are free, call the real API.

Configuration

You can also pass a custom httpx client for advanced configuration:

Resources