Prometeo Python API client

The official python package for the Prometeo API

Installation

Install from PyPI using pip:

$ pip install prometeo

Quick Start

Go to your dashboard, there you’ll find your API key. Use it to instantiate the client:

from prometeo import Client

client = Client('<YOUR_API_KEY>', environment='testing')

The environment argument is either testing for the sandbox or production for the production environment.

Note

Contact us to get an api key!

Usage Guide

Guides for all the available services:

Banking API

Initialize the client

To initialize the client you’ll need to provide your api key and the environment (either testing or production)

from prometeo import Client

client = Client('<YOUR_API_KEY>', environment='testing')

Log in

session = client.banking.login(
    provider='test',
    username='12345',
    password='gfdsa',
)

To get a list of available provider codes, use get_providers()

Becuase some banks require extra fields to log in, these must be provided inside kwargs as a dictionary. To see if a provider requires extra auth fields to log in, use get_provider_detail()

Example with extra auth fields:

session = client.banking.login(
    provider='bbva_mx',
    username='12345',
    password='gfdsa',
    otp=11223
)

The following is a table with all the extra auth fields and their respective providers.

Extra Login fields

Field

Provider

Required

Description

otp

bbva_mx

True

One-time password

personal_question

banco_general, intermatico

True

Personal question

token

banorte

True

Provider authorization token

company_code

pe_bbva_netcash

True

Company code

type

davivienda

False

Options
  • cedula_ciudadania: citizenship card

  • cedula_extranjeria: foreigner Identity card

  • nit NIT

  • tarjeta_identidad: identity card

  • pasaporte: passport

  • tarjeta_seguro_social_extranjero: foreign Social Security card

  • sociedad_extranjera_sin_nit: foreign company without NIT in Colombia

  • fideicomiso: fideicomiso

  • nit_menores: Minor NIT

  • rif_venezuela: RIF Venezuela

  • nit_extranjeria: Foreigners NIT

  • nit_persona_natural: Natural Person NIT

  • registro_civil_nacimiento: birth certificate

  • nit_desasociado: disassociated NIT

  • cif: CIF (Unique client number)

  • numero_identidad: Identity number

  • rtn: RTN

  • cedula_identidad: identity card

  • dimex: DIMEX

  • ced: CED

  • pas: PAS

  • documento_unico_identidad: unique identity document

  • nit_salvadoreno: Salvadoran NIT

Select client

In some banks a user can have access to more than one profile (called client), in those cases, the session status after login will be select_client. It is then necessary to select the client, for that, first list the available clients and pass one to session.select_client

if session.get_status() == 'select_client':
    clients = session.get_clients()
    session.select_client(clients[0])
    assert session.status == 'logged_in'

If the bank doesn’t uses multiple clients, calling get_clients will return an empty list.

Handling security questions and OTPs

In cases where the bank requires additional steps to login, such as answering a personal security question or using a 2FA device like an OTP, the status of the session will be set as interaction_required, which can be handled like this:

session = client.login(provider='test', username='user', password='pass')
if session.get_status() == 'interaction_required':
    # necessary context, like the security question to answer.
    print(session.get_interactive_context())
    session.finish_login(
        provider='test',
        username='user',
        password='pass',
        answer='1234',
    )

Restoring a session

In some cases it may be useful to serialize the session to be used later or to transfer to another process, like in a task queue job. For this use get_session_key() and get_session():

session_key = session.get_session_key()

# save session_key somewhere...

restored_session = client.banking.get_session(session_key)

Listing accounts and movements

from datetime import datetime

accounts = session.get_accounts()
for account in accounts:
    movements = account.get_movements(
        datetime(2019, 2, 1), datetime(2019, 15, 1)
    )

For more detailed information, refer to the docs for get_accounts() and get_movements()

Listing credit cards and their movements

Credit cards can have movements in more than one currency, so it’s necessary to specify it when listing movements.

from datetime import datetime

cards = session.get_credit_cards()
for card in cards:
    movements = card.get_movements(
        'USD', datetime(2019, 2, 1), datetime(2019, 15, 1)
    )

Listing available banks

We recommend that the list of available banks be stored on a database and updated weekly.

providers = client.banking.get_providers()

Preprocess transfer

preprocess = session.preprocess_transfer(
  origin_account='002206345988',
  destination_institution='0',
  destination_account='001002363321',
  currency='UYU',
  amount='1.3',
  concept='transfer description',
  destination_owner_name='John Doe',
  branch='62',
)

print(preprocess)

Confirm transfer

confirmation = session.confirm_transfer(
  request_id='0b7d6b32d1be4c11bde21e7ddc08cc36',
  authorization_type='cardCode',
  authorization_data='1, 2, 3',
)

print(confirmation)

List transfer institutions

institutions_list = session.list_transfer_institutions()
for intitution in institutions_list:
  print(intitution)

CURP API

Checking the existence of a curp

from prometeo import Client
from prometeo.curp import exceptions

client = Client('<YOUR_API_KEY>', environment='testing')
try:
    result = client.curp.query('ABCD12345EFGH')
except exceptions.CurpError as e:
    print("CURP does not exist:", e.message)

Looking for a CURP by personal info

from datetime import datetime
from prometeo.curp import exceptions, Gender, State

curp = 'ABCD12345EFGH'
state = State.SINALOA
birthdate = datetime(1988, 3, 4)
name = 'JOHN'
first_surname = 'DOE'
last_surname = 'PONCE'
gender = Gender.MALE
try:
    result = client.curp.reverse_query(
        state, birthdate, name, first_surname, last_surname, gender
    )
except exceptions.CurpError as e:
    print("CURP does not exist:", e.message)

Check the reference for a list of possible values for State

DIAN API

Log in

Initialize the client:

from prometeo import Client
from prometeo.dian import DocumentType

client = Client('<YOUR_API_KEY>', environment='testing')

Supply the NIT to log in as a company

session = client.dian.login(
    nit='098765',
    document_type=DocumentType.CEDULA_CIUDADANIA,
    document='12345',
    password='test_password',
)

Or omit it to log in as a person:

session = client.dian.login(
    document_type=DocumentType.CEDULA_CIUDADANIA,
    document='12345',
    password='test_password',
)

Check the reference for a list of possible values for DocumentType

Restoring a session

In some cases it may be useful to serialize the session to be used later or to transfer to another process, like in a task queue job. For this use get_session_key() and get_session():

session_key = session.get_session_key()

# save session_key somewhere...

restored_session = client.dian.get_session(session_key)

Download the forms

To download the original forms in pdf format, use the pdf property of the object returned by the methods:

info = session.get_company_info()
pdf_content = info.pdf.get_content()
# write the contents to a file:
with open("company-info.pdf", "wb") as f:
    f.write(pdf_content)

Getting the data

Company info (form 001):

session.get_company_info()

Balances:

session.get_balances()

Rent declaration:

session.get_rent_declaration(2019)

VAT declaration:

from prometeo.dian import Periodicity, QuartlerlyPeriod

session.get_vat_declaration(2019, Periodicity.QUARTERLY, QuartlerlyPeriod.JANUARY_APRIL)

Numeration:

from datetime import datetime
from prometeo.dian import NumerationType

session.get_numeration(
    NumerationType.Authorization,
    datetime(2019, 1, 1),
    datetime(2019, 5, 1)
)

Retentions:

from prometeo.dian import MonthlyPeriod

session.get_retentions(2019, MonthlyPeriod.NOVEMBER)

SAT API

Log in

from prometeo.sat import LoginScope

session = client.sat.login(
    rfc='ABCD1234EFGH',
    password='password',
    scope=LoginScope.CFDI,
)

Restoring a session

In some cases it may be useful to serialize the session to be used later or to transfer to another process, like in a task queue job. For this use get_session_key() and get_session():

session_key = session.get_session_key()

# save session_key somewhere...

restored_session = client.sat.get_session(session_key)

Listing bills

To list emitted bills, supply a date range and the BillStatus

from prometeo.sat import BillStatus

emitted_bills = session.get_emitted_bills(
    date_start=datetime(2020, 1, 1),
    date_end=datetime(2020, 2, 1),
    status=BillStatus.ANY,
)

And for received bills, supply the year, month and the BillStatus

received_bills = session.get_received_bills(
    year=2020,
    month=1,
    status=BillStatus.ANY,
)

Check the documentation for CFDIBill to see a list of all fields available for a bill.

Downlading bills

import time
from prometeo.sat import BillStatus

download_requests = session.download_emitted_bills(
    date_start=datetime(2020, 1, 1),
    date_end=datetime(2020, 2, 1),
    status=BillStatus.ANY,
)
for request in download_requests:
    while not request.is_ready():
        time.sleep(5)
    download = request.get_download()
    content = download.get_file().read()

Download acknowledgements

from prometeo.sat import Motive, DocumentType, Status, SendType

acks = session.get_acknowledgement(
    year=2020,
    month_start=1,
    month_end=2,
    motive=Motive.ALL,
    document_type=DocumentType.ALL,
    status=Status.ALL,
    send_type=SendType.ALL,
)
for ack in acks:
    download = ack.download().get_file()

Reference

Client Reference

A complete documentation of the prometeo module.

prometeo.banking

API Client
class prometeo.banking.client.Account(client, session_key, account_data)[source]

A bank account, returned by get_accounts()

get_movements(date_start, date_end)[source]

List an account’s movements for a range of dates.

Parameters
  • date_start (datetime) – Start of the date range for movements.

  • date_end (datetime) – End of the date range for movements.

Return type

List of Movement

class prometeo.banking.client.BankingAPIClient(api_key, environment)[source]

API Client for banking api

confirm_transfer(session_key, request_id, authorization_type, authorization_data)[source]

Confirm transfer.

Parameters
  • session_key (str) – The session key.

  • request_id (str) – Id of the request returned by the endpoint of preprocess_transfer()

  • authorization_type (str) –

    • cardCode Coordinates card

    • pin Account personal pin

    • otp One-time generated pin, sent by sms, email, hard token or soft token.

    • otp-api Hard token or soft token device, digitized by Prometeo

  • authorization_data (str) – Verification value (pin number, coordinates card response , etc) if there are several values, they must be separated by commas.

Return type

ConfirmTransfer

get_provider_detail(provider_code)[source]

Get more detailed information about a bank.

Parameters

provider_code (str) – Name of the provider, as returned in get_providers()

Return type

ProviderDetail

get_providers()[source]

List all available banks.

Return type

Provider

list_transfer_institutions(session_key)[source]

List transfer institutions.

Parameters

session_key (str) – The session key.

Return type

TransferInstitution

login(provider, username, password, **kwargs)[source]

Start log in process with the provider

Parameters
  • provider (str) – Name of the provider, use get_providers() to get a list of available providers

  • username (str) – Username used to log in to the banking app or web

  • password (str) – User’s password

  • kwargs (dict) – Extra login fields for providers that require it, use get_provider_detail() to get a list of all the auth login fields

Return type

Session

logout(session_key)[source]

Logs the user out and invalidates its session.

Parameters

session_key (str) – The session key.

on_response(data)[source]

Called after every 200 response

preprocess_transfer(session_key, origin_account, destination_institution, destination_account, currency, amount, concept, destination_owner_name, branch)[source]

Preprocess transfer.

Parameters
  • session_key (str) – The session key.

  • origin_account (str) – Account number from where it is transferred

  • destination_institution (str) – Id of the institution where it is transferred. As provided by get_providers()

  • destination_account (str) – Account number where it is transferred

  • currency (str) – Account currency in format ISO 4217

  • amount (str) – Amount to transfer

  • concept (str) – Concept or description of the transfer

  • destination_owner_name (str) – Name of the holder of the destination account (empty if not applicable)

  • branch (str) – Branch number of the destination account (empty if not applicable)

Return type

PreprocessTransfer

session_class

alias of Session

class prometeo.banking.client.CreditCard(client, session_key, card_data)[source]

A credit card, returned by get_credit_cards()

get_movements(currency_code, date_start, date_end)[source]

List credit card’s movements for a range of dates.

Parameters
  • date_start (datetime) – Start of the date range for movements.

  • date_end (datetime) – End of the date range for movements.

Return type

List of Movement

class prometeo.banking.client.Session(client, status, session_key, context=None, field=None)[source]

Encapsulates the user’s session, returned by login()

confirm_transfer(request_id, authorization_type, authorization_data)[source]

Confirm transfer.

Parameters
  • request_id (str) – Id of the request returned by the endpoint of preprocess_transfer()

  • authorization_type (str) –

    • cardCode Coordinates card

    • pin Account personal pin

    • otp One-time generated pin, sent by sms, email, hard token or soft token.

    • otp-api Hard token or soft token device, digitized by Promete

  • authorization_data (str) – Verification value (pin number, coordinates card response , etc) if there are several values, they must be separated by commas.

Return type

ConfirmTransfer

finish_login(provider, username, password, answer)[source]

Answer the security challenge, like an OTP or personal question.

Parameters
  • provider (str) – The provider used to login

  • username (str) – The username used to login

  • password (str) – The password used to login

  • answer (str) – The answer to the login challenge

get_accounts()[source]

List all the user’s accounts

Return type

List of Account

get_clients()[source]

List the user’s clients. Returns an empty list if the bank doesn’t uses clients.

Return type

List of Client

get_credit_cards()[source]

List all the user’s credit cards

Return type

List of CreditCard

get_interactive_context()[source]

Necessary information to answer the login challenge, like a security question.

Return type

str

list_transfer_institutions()[source]

List transfer institutions.

Return type

TransferInstitution

logout()[source]

Logs the user out and invalidates its session.

preprocess_transfer(origin_account, destination_institution, destination_account, currency, amount, concept, destination_owner_name, branch)[source]

Preprocess transfer.

Parameters
  • origin_account (str) – Account number from where it is transferred

  • destination_institution (str) – Id of the institution where it is transferred. As provided by get_providers()

  • destination_account (str) – Account number where it is transferred

  • currency (str) – Account currency in format ISO 4217

  • amount (str) – Amount to transfer

  • concept (str) – Concept or description of the transfer

  • destination_owner_name (str) – Name of the holder of the destination account (empty if not applicable)

  • branch (str) – Branch number of the destination account (empty if not applicable)

Return type

PreprocessTransfer

select_client(client)[source]

Selects the client to use for this session.

Parameters

client_id (str) – The id of the client, obtained from listing the clients

Models
class prometeo.banking.models.Account(id, name, number, branch, currency, balance)
property balance

Alias for field number 5

property branch

Alias for field number 3

property currency

Alias for field number 4

property id

Alias for field number 0

property name

Alias for field number 1

property number

Alias for field number 2

class prometeo.banking.models.Client(id, name)
property id

Alias for field number 0

property name

Alias for field number 1

class prometeo.banking.models.ConfirmTransfer(message, success)
property message

Alias for field number 0

property success

Alias for field number 1

class prometeo.banking.models.CreditCard(id, name, number, close_date, due_date, balance_local, balance_dollar)
property balance_dollar

Alias for field number 6

property balance_local

Alias for field number 5

property close_date

Alias for field number 3

property due_date

Alias for field number 4

property id

Alias for field number 0

property name

Alias for field number 1

property number

Alias for field number 2

class prometeo.banking.models.Movement(id, reference, date, detail, debit, credit, extra_data)
property credit

Alias for field number 5

property date

Alias for field number 2

property debit

Alias for field number 4

property detail

Alias for field number 3

property extra_data

Alias for field number 6

property id

Alias for field number 0

property reference

Alias for field number 1

class prometeo.banking.models.PreprocessTransfer(approved, authorization_devices, message, request_id)
property approved

Alias for field number 0

property authorization_devices

Alias for field number 1

property message

Alias for field number 2

property request_id

Alias for field number 3

class prometeo.banking.models.Provider(code, country, name)
property code

Alias for field number 0

property country

Alias for field number 1

property name

Alias for field number 2

class prometeo.banking.models.ProviderDetail(country, name, auth_fields)
property auth_fields

Alias for field number 2

property country

Alias for field number 0

property name

Alias for field number 1

class prometeo.banking.models.TransferInstitution(id, name)
property id

Alias for field number 0

property name

Alias for field number 1

base

Base Client
class prometeo.base_client.BaseClient(api_key, environment)[source]

Base client class to make api calls

call_api(method, url, *args, **kwargs)[source]

Calls an API endpoint, using the configured api key and environment.

Parameters
  • method (str) – The HTTP method to use (GET, POST, etc)

  • url (str) – The url to call (without the environment’s domain)

Return type

JSON data as a python object.

get_session(session_key)[source]

Restore a session from its session key

Parameters

session_key (str) – The session key

Return type

Session

on_response(response_data)[source]

Called after every 200 response

class prometeo.base_client.Download(client, url)[source]

Represents a downloadable file, like an xml bill or pdf document

get_file()[source]

Downloads the file and returns its contents.

Return type

bytes

Base Session
class prometeo.base_session.BaseSession(client, status, session_key)[source]

Base class that handles calling the API endpoints that use session keys.

get_session_key()[source]

Returns this session’s session key

Return type

str

get_status()[source]

Returns this session’s status

Return type

str

prometeo.curp

API Client
class prometeo.curp.client.CurpAPIClient(api_key, environment)[source]

API Client for CURP queries

query(curp)[source]

Find the personal data associated with a CURP

Parameters

curp (str) – The CURP of the person to query

Return type

QueryResult

reverse_query(state, birthdate, name, first_surname, last_surname, gender)[source]

Search for a person by their personal information.

Parameters
  • state (State) – The state where the person is registered

  • birthdate (datetime) – The person’s birthdate

  • name (str) – The person’s name

  • first_surname (str) – The person’s first surname

  • last_surname (str) – The person’s last surname

  • gender (Gender) – The person’s gender

Return type

QueryResult

Enums
class prometeo.curp.client.Gender[source]

A person’s gender

FEMALE = 'M'
MALE = 'H'
class prometeo.curp.client.State[source]

The state a person is registered

AGUASCALIENTES = 'AS'
BAJA_CALIFORNIA = 'BC'
BAJA_CALIFORNIA_SUR = 'BS'
CAMPECHE = 'CC'
CHIAPAS = 'CS'
CHIHUAHUA = 'CH'
CIUDAD_DE_MEXICO = 'DF'
COAHUILA = 'CL'
COLIMA = 'CM'
DURANGO = 'DG'
ESTADO_DE_MEXICO = 'MC'
GUANAJUATO = 'GT'
GUERRERO = 'GR'
HIDALGO = 'HG'
JALISCO = 'JC'
MICHOACAN = 'MN'
MORELOS = 'MS'
NACIDO_EN_EL_EXTRANJERO = 'NE'
NAYARIT = 'NT'
NUEVO_LEON = 'NL'
OAXACA = 'OC'
PUEBLA = 'PL'
QUERETARO = 'QT'
QUINTANA_ROO = 'QR'
SAN_LUIS_POTOSI = 'SP'
SINALOA = 'SL'
SONORA = 'SR'
TABASCO = 'TC'
TAMAULIPAS = 'TS'
TLAXCALA = 'TL'
VERACRUZ = 'VZ'
YUCATAN = 'YN'
ZACATECA = 'ZS'
Models
class prometeo.curp.models.DocumentData(clave_entidad_registro, clave_municipio_registro, entidad_registro, tomo, foja, num_acta, municipio_registro, anio_reg, libro)
property anio_reg

Alias for field number 7

property clave_entidad_registro

Alias for field number 0

property clave_municipio_registro

Alias for field number 1

property entidad_registro

Alias for field number 2

property foja

Alias for field number 4

property libro

Alias for field number 8

property municipio_registro

Alias for field number 6

property num_acta

Alias for field number 5

property tomo

Alias for field number 3

prometeo.curp.models.PersonalData

alias of prometeo.curp.models.DocumentData

class prometeo.curp.models.QueryResult(document_data, personal_data, pdf_url, pdf)
property document_data

Alias for field number 0

property pdf

Alias for field number 3

property pdf_url

Alias for field number 2

property personal_data

Alias for field number 1

prometeo.dian

API Client
class prometeo.dian.client.DianAPIClient(api_key, environment)[source]

API Client for DIAN API

login(document_type, document, password, nit=None)[source]

Log in to DIAN

Parameters
  • document_type (DocumentType) – The type of document for the document argument.

  • document (str) – The document of the person

  • password (str) – The password used to log in

  • nit (str) – The NIT of the company (used only when logging in as a company)

Return type

Session

session_class

alias of Session

class prometeo.dian.client.Session(client, status, session_key)[source]
get_balances()[source]

Get balances.

Return type

list of Balance

get_company_info()[source]

Get information about the company or person (form 001).

Return type

CompanyInfo

get_numeration(type, date_start, date_end)[source]

Get bill numeration (form 1876)

Parameters
  • type (NumerationType) – The type of numeration request to get

  • date_start (datetime) – Start date to filter

  • date_end (datetime) – End date to filter

Return type

List of Numeration

get_rent_declaration(year)[source]

Get rent declaration information (form 110 for companies and 210 for persons)

Parameters

year (int) – Year of the declaration

Return type

RentDeclaration

get_retentions(year, period)[source]

Get retentions information (form 350)

Parameters
  • year (int) – Year of the retention

  • period (int) – Period of the retention

Return type

List of Retentions

get_vat_declaration(year, periodicity, period)[source]

Get VAT declaration information (form 300)

Parameters
  • year (int) – Year of the declaration

  • periodicity (Periodicity) – Periodicity, either quarterly or bimonthly

  • period (int) – Period of the declaration

Return type

VATDeclaration

Enums
class prometeo.dian.client.NumerationType[source]

An enumeration.

Authorization = 'authorization'
Habilitation = 'habilitation'
Inhabilitation = 'inhabilitation'
class prometeo.dian.client.Periodicity[source]

An enumeration.

BIMONTHLY = 'b'
QUARTERLY = 'q'
class prometeo.dian.client.QuarterlyPeriod[source]

An enumeration.

JANUARY_APRIL = 1
MAY_AUGUST = 2
SEPTEMBER_DECEMBER = 3
class prometeo.dian.client.BimonthlyPeriod[source]

An enumeration.

JANUARY_FEBRUARY = 1
JULY_AUGUST = 4
MARCH_APRIL = 2
MAY_JUNE = 3
NOVEMBER_DECEMBER = 6
SEPTEMBER_OCTOBER = 5
class prometeo.dian.client.MonthlyPeriod[source]

An enumeration.

APRIL = 4
AUGUST = 8
DECEMBER = 12
FEBRUARY = 2
JANUARY = 1
JULY = 7
JUNE = 6
MARCH = 3
MAY = 5
NOVEMBER = 11
OCTOBER = 10
SEPTEMBER = 9
class prometeo.dian.client.DocumentType[source]

Document types used for DianAPIClient.login()

CARNE_DIPLOMATICO = '46'
CEDULA_CIUDADANIA = '13'
CEDULA_EXTRANJERIA = '22'
CERTIFICADO_REGISTRADURIA = '14'
DOCUMENTO_IDENTIFICACION_EXTRANJERO = '42'
DOCUMENTO_IDENTIFICACION_EXTRANJERO_PERSONA_JURIDICA = '44'
PASAPORTE = '41'
SIN_IDENTIFICACION_EXTRANJERO = '43'
TARJETA_EXTRANJERIA = '21'
TARJETA_IDENTIDAD = '12'
Models
class prometeo.dian.models.Accountant(document, start_date, name, professional_card)
property document

Alias for field number 0

property name

Alias for field number 2

property professional_card

Alias for field number 3

property start_date

Alias for field number 1

class prometeo.dian.models.Balance(type, amount, value)
property amount

Alias for field number 1

property type

Alias for field number 0

property value

Alias for field number 2

class prometeo.dian.models.CapitalComposition(national, national_private, national_public, foreign, foreign_private, foreign_public)
property foreign

Alias for field number 3

property foreign_private

Alias for field number 4

property foreign_public

Alias for field number 5

property national

Alias for field number 0

property national_private

Alias for field number 1

property national_public

Alias for field number 2

class prometeo.dian.models.CompanyInfo(accountant, capital_composition, reason, pdf_url, pdf, location, name, constitution_date, representation, members)
property accountant

Alias for field number 0

property capital_composition

Alias for field number 1

property constitution_date

Alias for field number 7

property location

Alias for field number 5

property members

Alias for field number 9

property name

Alias for field number 6

property pdf

Alias for field number 4

property pdf_url

Alias for field number 3

property reason

Alias for field number 2

property representation

Alias for field number 8

class prometeo.dian.models.Field(name, number, value)
property name

Alias for field number 0

property number

Alias for field number 1

property value

Alias for field number 2

class prometeo.dian.models.Location(country, city, phone1, phone2, department, address, email)
property address

Alias for field number 5

property city

Alias for field number 1

property country

Alias for field number 0

property department

Alias for field number 4

property email

Alias for field number 6

property phone1

Alias for field number 2

property phone2

Alias for field number 3

class prometeo.dian.models.Member(document_type, document, nationality, name, start_date)
property document

Alias for field number 1

property document_type

Alias for field number 0

property name

Alias for field number 3

property nationality

Alias for field number 2

property start_date

Alias for field number 4

class prometeo.dian.models.Name(first_surname, second_surname, first_name, other_names)
property first_name

Alias for field number 2

property first_surname

Alias for field number 0

property other_names

Alias for field number 3

property second_surname

Alias for field number 1

class prometeo.dian.models.Numeration(nit, dv, name, reason, address, country, department, municipality, ranges, pdf_url, pdf_available)
property address

Alias for field number 4

property country

Alias for field number 5

property department

Alias for field number 6

property dv

Alias for field number 1

property municipality

Alias for field number 7

property name

Alias for field number 2

property nit

Alias for field number 0

property pdf_available

Alias for field number 10

property pdf_url

Alias for field number 9

property ranges

Alias for field number 8

property reason

Alias for field number 3

prometeo.dian.models.NumerationRange

alias of prometeo.dian.models.Range

class prometeo.dian.models.RentDeclaration(pdf_url, pdf, fields, year, form_number, nit, dv, name, reason, direction_code, economic_activity, correction_code, previous_form)
property correction_code

Alias for field number 11

property direction_code

Alias for field number 9

property dv

Alias for field number 6

property economic_activity

Alias for field number 10

property fields

Alias for field number 2

property form_number

Alias for field number 4

property name

Alias for field number 7

property nit

Alias for field number 5

property pdf

Alias for field number 1

property pdf_url

Alias for field number 0

property previous_form

Alias for field number 12

property reason

Alias for field number 8

property year

Alias for field number 3

class prometeo.dian.models.Representative(document, document_type, name, representation_type, start_date)
property document

Alias for field number 0

property document_type

Alias for field number 1

property name

Alias for field number 2

property representation_type

Alias for field number 3

property start_date

Alias for field number 4

class prometeo.dian.models.Retentions(pdf_url, pdf, fields, year, period, form_number, nit, reason, direction_code)
property direction_code

Alias for field number 8

property fields

Alias for field number 2

property form_number

Alias for field number 5

property nit

Alias for field number 6

property pdf

Alias for field number 1

property pdf_url

Alias for field number 0

property period

Alias for field number 4

property reason

Alias for field number 7

property year

Alias for field number 3

class prometeo.dian.models.VATDeclaration(pdf_url, pdf, fields, year, period, form_number, nit, dv, name, reason, direction_code, correction_code, previous_form)
property correction_code

Alias for field number 11

property direction_code

Alias for field number 10

property dv

Alias for field number 7

property fields

Alias for field number 2

property form_number

Alias for field number 5

property name

Alias for field number 8

property nit

Alias for field number 6

property pdf

Alias for field number 1

property pdf_url

Alias for field number 0

property period

Alias for field number 4

property previous_form

Alias for field number 12

property reason

Alias for field number 9

property year

Alias for field number 3

prometeo.sat

API Client
class prometeo.sat.client.SatAPIClient(api_key, environment)[source]

API Client for SAT API

login(rfc, password, scope)[source]

Log in to SAT

Parameters
  • rfc (str) – RFC of the person to log in

  • password (str) – Password used to login, also known as CIEC

  • scope (LoginScope) – Depending on the type of information to query, use LoginScope.CFDI to download bill xmls or LoginScope.SIAT to download acknowledgements.

Return type

Session

session_class

alias of Session

class prometeo.sat.client.Session(client, status, session_key)[source]
download_emitted_bills(date_start, date_end, status)[source]

Creates a request to download all the emitted bills in a range of dates.

Parameters
  • date_start (datetime) – Start date to filter

  • date_end (datetime) – End date to filter

  • status (BillStatus) – Status of the bills

Return type

List of DownloadRequest

download_received_bills(year, month, status)[source]

Creates a request to download all the received bills in a range of dates.

Parameters
  • date_start (datetime) – Start date to filter

  • date_end (datetime) – End date to filter

  • status (BillStatus) – Status of the bills

Return type

List of DownloadRequest

get_acknowledgements(year, month_start, month_end, motive, document_type, status, send_type)[source]

Gets a list of acknowledgements for a range of dates

Parameters
  • year (int) – The year of the acknowledgements

  • month_start (int) – Start month to filter

  • month_end (int) – End month to filter

  • motive (Motive) – Motive

  • document_type (DocumentType) – Document type

  • status (Status) – Status

  • send_type (SendType) – Send type

Return type

List of AcknowledgementResult

get_downloads()[source]

Gets a list of available downloads

Return type

List of DownloadRequest

get_emitted_bills(date_start, date_end, status)[source]

List all emitted bills in a range of dates.

Parameters
  • date_start (datetime) – Start date to filter

  • date_end (datetime) – End date to filter

  • status (BillStatus) – Status of the bills

Return type

List of CFDIBill

get_received_bills(year, month, status)[source]

List all received bills in a range of dates.

Parameters
  • year (int) – Year of the received bills

  • month (int) – Month of the received bills

  • status (BillStatus) – Status of the bills

Return type

List of CFDIBill

logout()[source]

Logs out of SAT. You won’t be able to use this session after logout.

class prometeo.sat.client.AcknowledgementResult(client, session_key, data)[source]

Info on an acknowledgement, returned by Session.get_acknowledgements()

get_download()[source]

Download the acknowledgement data

Return type

Download

class prometeo.sat.client.DownloadRequest(client, session_key, request_id)[source]

A request for bulk downloading of bills.

get_download()[source]

Download the generated zip file with all the xmls

Return type

Download

is_ready()[source]

Check if the request is ready to download.

Return type

bool

Enums
class prometeo.sat.client.LoginScope[source]

An enumeration.

CFDI = 'cfdi'
SIAT = 'siat'
class prometeo.sat.client.BillStatus[source]

An enumeration.

ANY = 'any'
CANCELLED = 'cancelled'
VALID = 'valid'
class prometeo.sat.client.Motive[source]

An enumeration.

AF = 'af'
ALL = 'all'
CO = 'co'
DE = 'de'
FC = 'fc'
MONTHLY = 'monthly'
class prometeo.sat.client.DocumentType[source]

An enumeration.

ALL = 'all'
B = 'b'
CT = 'ct'
PL = 'pl'
XC = 'xc'
XF = 'xf'
class prometeo.sat.client.Status[source]

An enumeration.

ACCEPTED = 'accepted'
ALL = 'all'
RECEIVED = 'received'
REJECTED = 'rejected'
class prometeo.sat.client.SendType[source]

An enumeration.

ALL = 'all'
C = 'c'
N = 'n'
Models
class prometeo.sat.models.AcknowledgementResult(id, period, motive, document_type, send_type, file_name, reception_date, status)
property document_type

Alias for field number 3

property file_name

Alias for field number 5

property id

Alias for field number 0

property motive

Alias for field number 2

property period

Alias for field number 1

property reception_date

Alias for field number 6

property send_type

Alias for field number 4

property status

Alias for field number 7

class prometeo.sat.models.CFDIBill(id, emitter_rfc, emitter_reason, receiver_rfc, receiver_reason, emitted_date, certification_date, certification_pac, total_value, effect, status)
property certification_date

Alias for field number 6

property certification_pac

Alias for field number 7

property effect

Alias for field number 9

property emitted_date

Alias for field number 5

property emitter_reason

Alias for field number 2

property emitter_rfc

Alias for field number 1

property id

Alias for field number 0

property receiver_reason

Alias for field number 4

property receiver_rfc

Alias for field number 3

property status

Alias for field number 10

property total_value

Alias for field number 8

class prometeo.sat.models.CFDIDownloadItem(request_id, type, count)
property count

Alias for field number 2

property request_id

Alias for field number 0

property type

Alias for field number 1

class prometeo.sat.models.DownloadFile(download_url)
property download_url

Alias for field number 0

class prometeo.sat.models.DownloadRequest(request_id)
property request_id

Alias for field number 0

class prometeo.sat.models.PdfFile(pdf_url)
property pdf_url

Alias for field number 0

Indices and tables