Skip to content

Reference

Endpoints

Every function returns a pandas DataFrame. Pass refresh=True to any of them to bypass the response cache for that call.

alepe.representatives(refresh=False)

Members of the current legislature, with name and party.

alepe.staff(status=None, refresh=False)

The Assembly's staff roster, optionally filtered by employment status.

alepe.positions(status=None, refresh=False)

Staff counts per position and level.

alepe.departments(refresh=False)

Active staff counts per department and employment status.

The reference period is fixed by the API, and retired staff are excluded.

alepe.remuneration(refresh=False)

Published remuneration per position, for the current reference month.

alepe.contracts(refresh=False)

The Assembly's administrative contracts.

Identifier fields are kept exactly as published, float-formatting artefacts included: at the time of writing the service fills numeroContrato with the contractor's tax id rather than the contract number.

alepe.procurements(refresh=False)

The Assembly's procurement processes.

This is the slowest endpoint of the API: it takes 25-30 s to answer and the service cuts its own query off at 30 s, so an occasional failure is the service timing out on itself rather than anything local. valor_estimado, vencedor and valor_adjudicado are published empty for every process at the time of writing.

alepe.bills(number=None, year=None, legislature=None, refresh=False)

Bills (projetos de lei).

Pass number together with year for the full record of a single proposition; pass year and/or legislature to list summaries. With no filter at all the API defaults to the current year.

alepe.indications(number=None, year=None, legislature=None, refresh=False)

Indications (indicações). Same two query modes as :func:bills.

alepe.requests(number=None, year=None, legislature=None, refresh=False)

Requests (requerimentos). Same two query modes as :func:bills.

Portuguese aliases

Each endpoint has an alias named after the endpoint it wraps, so a pipeline can stay in Portuguese end to end. parlamentares, servidores, cargos, lotacoes, remuneracao, contratos and licitacoes are the same objects as their English counterparts; the propositions aliases translate the argument names as well.

alepe.projetos(numero=None, ano=None, legislatura=None, refresh=False)

Alias de :func:bills, com argumentos em português.

alepe.indicacoes(numero=None, ano=None, legislatura=None, refresh=False)

Alias de :func:indications, com argumentos em português.

alepe.requerimentos(numero=None, ano=None, legislatura=None, refresh=False)

Alias de :func:requests, com argumentos em português.

Configuration

alepe.configure(**options)

Set connection options for the session, or read them back.

Called with no arguments, returns the configuration in use. Recognised options, passed as keywords:

  • timeout — seconds to wait for a response. Default 60, which clears the 25-30 s that /licitacoes takes.
  • max_tries — how many attempts a request gets before giving up. Default 3.
  • base_url — the API root, for pointing the package at a mirror or a test double.

Returns:

Type Description
dict

The configuration after applying the changes.

alepe.cache_dir(path=None)

Where cached responses are stored.

Called with no argument, reports the directory in use. Called with a path, switches to it for the rest of the session and creates it.

alepe.cache_clear()

Delete every cached response. Returns how many files were removed.

alepe.empty(endpoint)

A correctly typed empty frame for an endpoint.

Useful as a fallback when :class:AlepeHTTPError is caught and the code downstream still expects the columns to be there — which is what the R sibling returns of its own accord, CRAN policy requiring it.

Errors

alepe.AlepeError

Bases: Exception

Base class for every error this package raises.

alepe.AlepeHTTPError

Bases: AlepeError

A non-success HTTP status, or a request that never got a response.

Attributes:

Name Type Description
status

The HTTP status code, or None when the request failed before a response arrived (timeout, DNS failure, refused connection).

url

The URL that was requested.

alepe.AlepeParseError

Bases: AlepeError

A response the package cannot make sense of.

alepe.AlepeInputError

Bases: AlepeError

An argument combination the API cannot express.