Follow the Money

raw JSON →
4.8.1 verified Fri May 01 auth: no python

A Python library for modeling, validating, and exporting structured anti-corruption data. It provides a schema (the 'Follow the Money' data model) with entities, properties, and relations, along with tools for data import/export (CSV, Excel, JSON, RDF), entity deduplication, and graph analysis. Current version 4.8.1, supports Python >=3.10, released under MIT license. Active development.

pip install followthemoney
error ModuleNotFoundError: No module named 'followthemoney.model'
cause Importing from submodule incorrectly.
fix
Use from followthemoney import Model instead of from followthemoney.model import Model.
error followthemoney.exceptions.InvalidData: Invalid entity type: 'Organisation'
cause Entity type name typo or wrong case. Schema uses 'Organization' (with 'z').
fix
Use 'Organization' (US spelling) instead of 'Organisation' (UK spelling).
error AttributeError: 'Model' object has no attribute 'Entity'
cause Trying to access Entity class on Model instance incorrectly.
fix
Use model.make_entity('Person') or from followthemoney import Entity.
error ValueError: Entity ID is required before adding properties
cause Calling `add()` on Entity before calling `make_id()`.
fix
Always call entity.make_id('...') before adding properties.
breaking In version 4.0, the proxy API was removed. Use model.make_entity instead of direct Entity construction.
fix Replace `Entity(model, 'Person')` with `model.make_entity('Person')`.
breaking Schema changes between minor versions may rename or remove entity types and properties. Always check migration docs.
fix Run `followthemoney -m` to see current schema, and update code accordingly.
gotcha The `Entity` object is mutable and shares model state; copying entities with `copy()` does a shallow copy of properties. Use deepcopy for full independence.
fix Use `copy.deepcopy(entity)` instead of `entity.copy()`.
deprecated The `followthemoney.cli` namespace and command-line scripts (like `ftm`) are deprecated; use the `followthemoney` module directly.
fix Use `python -m followthemoney` instead of `ftm`.

Create a Person entity, add properties, validate, and export to dict.

from followthemoney import Model

# Load the default data model
model = Model()

# Create an entity of type 'Person'
entity = model.make_entity('Person')
entity.make_id('some-unique-id')
entity.add('name', 'John Doe')
entity.add('birthDate', '1980-01-01')

# Validate the entity (raises on invalid)
entity.validate()

# Export to dict
print(entity.to_dict())