Skip to main content

Python client library for Prometeo

Project description

Prometeo Python API Client PyPI version Documentation Status Bitbucket Pipelines branch

This is the official python library for the Prometeo API

Documentation

Complete client documentation is available at Read the docs

Installation

Prerequisites

  • Python version 2.7 and 3.5+
  • An API Key (contact us to get one!)

Install package

$ pip install prometeo

Quick Start

Get your key

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.

Listing movements

The following example logs in to the sandboxed bank and retrieves a list of movements

from datetime import datetime

session = client.banking.login(provider='test', username='12345', password='gfdsa')
accounts = session.get_accounts()
account = accounts[0]
print(account.number, ' - ', account.name)
movements = account.get_movements(datetime(2019, 2, 1), datetime(2019, 2, 2))
for movement in movements:
    print(movement.detail, movement.debit, movement.credit)

Listing credit card movements

cards = session.get_credit_cards()
card = cards[0]
print(card.number, ' - ', card.name)
movements = card.get_movements('USD', datetime(2019, 2, 1), datetime(2019, 2, 2))
for movement in movements:
    print(movement.detail, movement.debit, movement.credit)

Listing all available banks

providers = client.banking.get_providers()
for provider in providers:
    print(provider.name, provider.country)

CURP API

Checking the existence of a curp

from prometeo.curp import exceptions

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

Looking for a CURP by person

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)

DIAN API

Log in

Supply the NIT to log in as a company:

from prometeo.dian import DocumentType

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:

from prometeo.dian import DocumentType

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

Get the data

Company info:

session.get_company_info()

Balances:

session.get_balances()

Rent declaration:

session.get_rent_declaration(2018)

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

Login in

from prometeo.sat import LoginScope

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

Work with CFDI bills

List emitted and received bills

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,
)

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

Bulk download of bills

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:
    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()

License

The MIT License

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

prometeo-1.1.0.tar.gz (22.9 kB view details)

Uploaded Source

File details

Details for the file prometeo-1.1.0.tar.gz.

File metadata

  • Download URL: prometeo-1.1.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5

File hashes

Hashes for prometeo-1.1.0.tar.gz
Algorithm Hash digest
SHA256 7f0a65bf13e8c61e96b974429a5ac766b4c6261e11504aa83153fe1b91d28354
MD5 fca73b5d7e79e01faf47f25938e04a0f
BLAKE2b-256 d225a767e8de46d3a046eb7c65cb2644196ccd5019ee76198c50c91c6a145c93

See more details on using hashes here.

Supported by

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