Skip to main content

Cliente para listas quienesquien

Project description

quienesquien

test codecov PyPI

Client for the Quienesquien list service (https://app.q-detect.com/)

[!IMPORTANT] Generating a new authentication token automatically invalidates any previously created tokens. If multiple applications or services are using the same credentials, creating a new token will render the old ones invalid, potentially causing other applications to fail. To avoid issues, reuse an existing token whenever possible by storing it in an environment variable or a secure location.

Installation

pip install quienesquien

Development & Testing

The project configuration is managed through environment variables. Set them before running tests:

export $(<env.template)

To run unit tests, use pytest.

pytest

Usage

Before using the client, configure the required environment variables:

export QEQ_USER=your_user
export QEQ_CLIENT_ID=your_client_id
export QEQ_SECRET_ID=your_secret_key

Token Generation

Before performing searches, you need to create an authentication token using the create_token method:

from quienesquien import Client

client = Client(os.environ['QEQ_USER'], os.environ['QEQ_CLIENT_ID'])

auth_token = await client.create_token(os.environ['QEQ_SECRET_ID'])

You can reuse this token in subsequent requests.

Example

Once you have the token, you can perform searches by passing it:

import os
from quienesquien import Client
from quienesquien.enums import Gender, SearchList, SearchType
from quienesquien.exc import (
    InsufficientBalanceError,
    InvalidPlanError,
    InvalidTokenError,
    PersonNotFoundError,
)

# Create the client with the token
client = Client(
    os.environ['QEQ_USER'],
    os.environ['QEQ_CLIENT_ID'],
    auth_token,
)

try:
    persons = await client.search(
        full_name='Andres Manuel Lopez Obrador',
        match_score=85,
        rfc='LOOA531113F15',
        curp='LOOA531113HTCPBN07',
        gender=Gender.masculino,
        birthday=dt.date(1953, 11, 13),
        search_type=SearchType.fisica,
        search_list=(SearchList.PPE, SearchList.ONU),
    )
except InsufficientBalanceError:
    print('Saldo insuficiente')
except InvalidPlanError:
    print('Plan inválido')
except InvalidTokenError:
    print('Token inválido')
except PersonNotFoundError:
    persons = []

Environment Variable (Optional)

To simplify usage, you can store the token in an environment variable:

export QEQ_AUTH_TOKEN=your_auth_token

Then, instantiate the client using the environment variable:

import os

client = Client(
    os.environ['QEQ_USER'],
    os.environ['QEQ_CLIENT_ID'],
    os.environ.get('QEQ_AUTH_TOKEN'),
)

Search Parameters

  • full_name (str): Full name of the person.
  • match_score (int): Minimum match percentage (default: 60).
  • rfc (str): Mexican RFC.
  • curp (str): Mexican CURP.
  • gender (Gender): masculino or femenino.
  • birthday (datetime.date): Date of birth.
  • search_type (SearchType): fisica or moral.
  • search_list (tuple[SearchList, ...]): Lists to search. If not provided, searches all.

The search follows a hierarchical approach: it first attempts to find a match using the RFC. If no match is found, it searches by CURP. Finally, if neither is found, it looks for a match by name. You must specify at least one search parameter: full_name, rfc or curp.

Response Structure

  • persons (list): List of matched persons.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quienesquien-1.0.1.dev2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quienesquien-1.0.1.dev2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file quienesquien-1.0.1.dev2.tar.gz.

File metadata

  • Download URL: quienesquien-1.0.1.dev2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for quienesquien-1.0.1.dev2.tar.gz
Algorithm Hash digest
SHA256 74b4b45c8d50c6c71a2cd1da63e7638137b2bf60bdb6c62d8068a921de56c310
MD5 51d30cf8d73b6212349ad16e0afa9530
BLAKE2b-256 b9f43ac2c21651ebf2e8b873e99fb5c51a2bf4edc208b3eae1242450c12a598d

See more details on using hashes here.

File details

Details for the file quienesquien-1.0.1.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for quienesquien-1.0.1.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 c7f185101541d4066eea37b83aaf2212b331816a5912b58ac0b4f06670584feb
MD5 620e68127b18f2665cafb06b86668dbf
BLAKE2b-256 6cde84a9bef55c7ca9789ec6cfdd5c246f863df593cbfcc0e09a1c8748455e0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page