ftmq
This library provides methods to query and filter entities formatted as Follow The Money data, either from a json file/stream or using a statement-based store backend from nomenklatura.
It also provides a Query class that can be used in other libraries to work with SQL store queries or api queries.
ftmq.Query is the central query hub of the OpenAleph ecosystem: one backend-agnostic query object that filters FtM streams and stores, translates to SQL, and bridges to the OpenAleph API.
To get familiar with the Follow The Money ecosystem, you can have a look at this pad here.
Installation
Minimum Python version: 3.11
pip install ftmq
Usage
Command line
cat entities.ftm.json | ftmq -q 'filter:schema=Company&filter:properties.country=de&filter:gte:properties.incorporationDate=2023' -o s3://data/entities-filtered.ftm.json
Python Library
from ftmq import Query, M, P, G, smart_read_proxies
# Legal entities in the `companies` dataset that are based in Germany, or in
# Austria and incorporated since 2020, but never the dissolved ones, return the
# 5 most recent incorporated ones:
q = Query().where(
M(dataset="companies"),
M(schemata="LegalEntity"),
G(countries="de") | (G(countries="at") & P(incorporationDate__gte=2020)),
~P(status__ilike="%dissolved%"),
).order_by("incorporationDate", ascending=False)[:5]
for proxy in smart_read_proxies("s3://data/entities.ftm.json"):
if q.apply(proxy):
yield proxy
Full-text search
ftmq.search (formerly the standalone ftmq-search package) indexes entities into simple full-text search stores, backed by SQLite FTS5 or Tantivy (pip install ftmq[search]):
cat entities.ftm.json | ftmq search transform | ftmq search --uri sqlite:///ftmqs.db index
ftmq search --uri sqlite:///ftmqs.db "jane doe"
HTTP API
ftmq.api (formerly the standalone ftmq-api package) exposes a store and its search index as a read-only FastAPI application (pip install ftmq[api]), speaking the Aleph filter grammar:
granian --interface asgi ftmq.api.app:app
curl "localhost:8000/entities?filter:schema=Payment&filter:gte:properties.date=2023"
Documentation
https://docs.investigraph.dev/lib/ftmq
Support
This project is part of investigraph
In 2023, development of ftmq was supported by Media Tech Lab Bayern batch #3
License and Copyright
ftmq, (C) 2023 Simon Wörpel
ftmq, (C) 2024-2025 investigativedata.io
ftmq, (C) 2025 Data and Research Center – DARC
ftmq is licensed under the AGPLv3 or later license.
Prior to version 0.8.0, ftmq was released under the MIT license.
Metadata
Release files for ftmq 5.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ftmq-5.0.0.tar.gz | 106.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ftmq-5.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 237.6 kB
Release files / ftmq-5.0.0.tar.gz
| Download URL | ftmq-5.0.0.tar.gz |
|---|---|
| Size | 106.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ea39f8daade3597e0b916236cfa48cd9071d6820aa8abe9f09875d46341f9d3
|
|
BLAKE2b-256 checksum How to use checksums |
6e32a3cecc10dd1190d721b11d47b727c304abf6b911c0d71ecd536c36bae6b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-29-generic
|
Release files / ftmq-5.0.0-py3-none-any.whl
| Download URL | ftmq-5.0.0-py3-none-any.whl |
|---|---|
| Size | 131.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af75229a1152ab20447b5d3ed81a78bbe1d34c103c442b46ff4edd6fccd4e0a6
|
|
BLAKE2b-256 checksum How to use checksums |
0f51201725466c64a3732ba982f0305e9be5402361ea064c2f00d9feb367a362
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.14.4 Linux/7.0.0-29-generic
|