flowiq
Client and command line for the FlowIQ REST API
Downloads & Community Adoption
Health & Engineering Analysis (5 Pillars)
1. Governance & Community100 / 200 ▾
2. PEP Metadata & Packaging200 / 200 ▾
3. Security & Supply Chain200 / 200 ▾
4. Documentation, SEO & Ecosystem155 / 200 ▾
5. Engineering, CI & Quality130 / 200 ▾
Official Documentation & Usage Guide — flowiq
Show full original documentation (English README) ▾
flowiq
A Python client and a command for the FlowIQ REST API. Python 3.9 or later, no other packages.
What the API does, in one file for programs: https://flowiq-labs.com/api/openapi.json. The query language: https://flowiq-labs.com/help.
Install
pip install flowiq
Your key
Put it in the environment. The command has no option for it, because an argument can be read by every other process on the machine and stays in the shell's history.
export FLOWIQ_API_KEY=sk_live_...
The key is sent in a header, only to https (or to your own machine), and never to wherever a redirect points.
In Python
from flowiq import FlowIQ
fq = FlowIQ()
fq.count("protocol:mongodb country:BR")["total_found"]
for s in fq.search("protocol:mongodb country:BR -tags:honeypot", limit=500, fields=["ip", "port", "org"]):
print(s["ip"], s["port"], s["org"])
fq.host("203.0.113.5")["services"]
[n["name"] for n in fq.domain("example.com", limit=1000)]
fq.breakdown("asn", "protocol:mongodb country:BR", limit=20)["buckets"]
fq.fields() # what breakdown accepts
fq.account()["credits_remaining"]
fq.export("protocol:mongodb", "mongo.ndjson", limit=50000)
search and domain fetch a page at a time as you read, so stopping early costs only what was fetched.
limit=None reads to the end. The object they return knows total_found, notes and next_after; give
next_after back as after= to continue a search later.
Read notes. A field name the server does not know is not an error: it searches titles for it, finds
nothing, and says so there.
What it costs
| call | credits |
|---|---|
search |
1 a record, at least 1 a page |
count |
1 |
host |
1 a service on the host, at least 1. You do not choose how many that is; count(ip) says first |
domain |
1 a name, at least 1 a page |
breakdown |
1 a value returned, at least 1 |
export |
1 a record in the file |
account, fields, export status and download |
none |
When it fails
Everything raised is a FlowIQError. An answer from the server is an APIError with status, message
(the server's own sentence) and refused, and has a class of its own: BadRequest, Unauthorized,
Forbidden, NotFound, NotReady, Gone, RateLimited, ServerError, ServiceUnavailable.
- 429 and 503 are tried again, waiting as long as the server says, or 1, 2, 4 ... seconds when it does not
say. A try that ends in 503 can cost one credit.
FlowIQ(retries=0)turns this off. - A connection lost while waiting is tried again only where asking twice is free. Anywhere else the server
may have run the call and charged for it, so you get
ConnectionFailedand decide. IncompleteResponsemeans the answer began and stopped. Nothing half-read is ever returned as if whole.
Exports
export starts it, waits and downloads. The bytes go to FILE.part and take the name FILE only when the
file is whole. If it is interrupted, export_download(id, path) continues where it stopped, unless the file
on the server was rebuilt in the meantime, in which case it is fetched again. The four steps are also
methods of their own: export_start, export_status, export_wait, export_download.
The command
flowiq count 'protocol:mongodb country:BR'
flowiq search 'protocol:mongodb country:BR' --limit 500 --fields ip,port,org -o csv > mongo.csv
flowiq host 203.0.113.5
flowiq domain example.com --resolved --limit 1000 -o ndjson
flowiq breakdown asn 'protocol:mongodb country:BR' --limit 20
flowiq export 'protocol:mongodb' --limit 50000 -O mongo.ndjson --yes
flowiq export --resume 4711 -O mongo.ndjson
flowiq account
flowiq fields
-o is json, ndjson, csv or table; without it you get a table on a terminal and JSON elsewhere.
A call that can cost more than 1,000 credits says what it costs and what you have left, and stops unless you
add --yes. --all counts first, for one credit.
Titles, banners and names were written by whoever runs the service. On a terminal they are shown without control characters, so they cannot move the cursor or hide text; in CSV a cell that a spreadsheet would run as a formula gets a leading apostrophe. JSON keeps the exact value.
FlowIQ records what a service returned. It makes no claim that a host is vulnerable, and last_seen is the
last time a service answered, not a statement that it is up.
Exit codes: 0 done, 1 an error (the reason is on the error stream), 2 wrong arguments or --yes needed,
3 the export is not ready, 130 interrupted.
Tests
cd clients/python
python -m unittest
They use a small server on a local port and no network. tests/test_spec.py holds that server, the limits
and the types to openapi.json at the top of the repository (set FLOWIQ_OPENAPI to its path), the document the server publishes at https://flowiq-labs.com/api/openapi.json.