flowiq 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
flowiq-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kaike Southier Leite
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
flowiq-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,137 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowiq
3
+ Version: 0.1.0
4
+ Summary: Client and command line for the FlowIQ REST API
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://flowiq-labs.com
7
+ Project-URL: Documentation, https://flowiq-labs.com/api-docs
8
+ Project-URL: Source, https://github.com/flowiq-labs/flowiq
9
+ Project-URL: Issues, https://github.com/flowiq-labs/flowiq/issues
10
+ Keywords: internet measurement,attack surface,exposure,threat intelligence,osint,security,search,api client
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Information Technology
14
+ Classifier: Intended Audience :: System Administrators
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Internet
18
+ Classifier: Topic :: Security
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # flowiq
26
+
27
+ A Python client and a command for the FlowIQ REST API. Python 3.9 or later, no other packages.
28
+
29
+ What the API does, in one file for programs: <https://flowiq-labs.com/api/openapi.json>. The query
30
+ language: <https://flowiq-labs.com/help>.
31
+
32
+ ## Install
33
+
34
+ pip install flowiq
35
+
36
+ ## Your key
37
+
38
+ Put it in the environment. The command has no option for it, because an argument can be read by every
39
+ other process on the machine and stays in the shell's history.
40
+
41
+ export FLOWIQ_API_KEY=sk_live_...
42
+
43
+ The key is sent in a header, only to https (or to your own machine), and never to wherever a redirect
44
+ points.
45
+
46
+ ## In Python
47
+
48
+ ```python
49
+ from flowiq import FlowIQ
50
+
51
+ fq = FlowIQ()
52
+
53
+ fq.count("protocol:mongodb country:BR")["total_found"]
54
+
55
+ for s in fq.search("protocol:mongodb country:BR -tags:honeypot", limit=500, fields=["ip", "port", "org"]):
56
+ print(s["ip"], s["port"], s["org"])
57
+
58
+ fq.host("203.0.113.5")["services"]
59
+ [n["name"] for n in fq.domain("example.com", limit=1000)]
60
+ fq.breakdown("asn", "protocol:mongodb country:BR", limit=20)["buckets"]
61
+ fq.fields() # what breakdown accepts
62
+ fq.account()["credits_remaining"]
63
+ fq.export("protocol:mongodb", "mongo.ndjson", limit=50000)
64
+ ```
65
+
66
+ `search` and `domain` fetch a page at a time as you read, so stopping early costs only what was fetched.
67
+ `limit=None` reads to the end. The object they return knows `total_found`, `notes` and `next_after`; give
68
+ `next_after` back as `after=` to continue a search later.
69
+
70
+ Read `notes`. A field name the server does not know is not an error: it searches titles for it, finds
71
+ nothing, and says so there.
72
+
73
+ ### What it costs
74
+
75
+ | call | credits |
76
+ |---|---|
77
+ | `search` | 1 a record, at least 1 a page |
78
+ | `count` | 1 |
79
+ | `host` | 1 a service on the host, at least 1. You do not choose how many that is; `count(ip)` says first |
80
+ | `domain` | 1 a name, at least 1 a page |
81
+ | `breakdown` | 1 a value returned, at least 1 |
82
+ | `export` | 1 a record in the file |
83
+ | `account`, `fields`, export status and download | none |
84
+
85
+ ### When it fails
86
+
87
+ Everything raised is a `FlowIQError`. An answer from the server is an `APIError` with `status`, `message`
88
+ (the server's own sentence) and `refused`, and has a class of its own: `BadRequest`, `Unauthorized`,
89
+ `Forbidden`, `NotFound`, `NotReady`, `Gone`, `RateLimited`, `ServerError`, `ServiceUnavailable`.
90
+
91
+ * 429 and 503 are tried again, waiting as long as the server says, or 1, 2, 4 ... seconds when it does not
92
+ say. A try that ends in 503 can cost one credit. `FlowIQ(retries=0)` turns this off.
93
+ * A connection lost while waiting is tried again only where asking twice is free. Anywhere else the server
94
+ may have run the call and charged for it, so you get `ConnectionFailed` and decide.
95
+ * `IncompleteResponse` means the answer began and stopped. Nothing half-read is ever returned as if whole.
96
+
97
+ ### Exports
98
+
99
+ `export` starts it, waits and downloads. The bytes go to `FILE.part` and take the name `FILE` only when the
100
+ file is whole. If it is interrupted, `export_download(id, path)` continues where it stopped, unless the file
101
+ on the server was rebuilt in the meantime, in which case it is fetched again. The four steps are also
102
+ methods of their own: `export_start`, `export_status`, `export_wait`, `export_download`.
103
+
104
+ ## The command
105
+
106
+ flowiq count 'protocol:mongodb country:BR'
107
+ flowiq search 'protocol:mongodb country:BR' --limit 500 --fields ip,port,org -o csv > mongo.csv
108
+ flowiq host 203.0.113.5
109
+ flowiq domain example.com --resolved --limit 1000 -o ndjson
110
+ flowiq breakdown asn 'protocol:mongodb country:BR' --limit 20
111
+ flowiq export 'protocol:mongodb' --limit 50000 -O mongo.ndjson --yes
112
+ flowiq export --resume 4711 -O mongo.ndjson
113
+ flowiq account
114
+ flowiq fields
115
+
116
+ `-o` is `json`, `ndjson`, `csv` or `table`; without it you get a table on a terminal and JSON elsewhere.
117
+
118
+ A call that can cost more than 1,000 credits says what it costs and what you have left, and stops unless you
119
+ add `--yes`. `--all` counts first, for one credit.
120
+
121
+ Titles, banners and names were written by whoever runs the service. On a terminal they are shown without
122
+ control characters, so they cannot move the cursor or hide text; in CSV a cell that a spreadsheet would run
123
+ as a formula gets a leading apostrophe. JSON keeps the exact value.
124
+
125
+ FlowIQ records what a service returned. It makes no claim that a host is vulnerable, and `last_seen` is the
126
+ last time a service answered, not a statement that it is up.
127
+
128
+ Exit codes: 0 done, 1 an error (the reason is on the error stream), 2 wrong arguments or `--yes` needed,
129
+ 3 the export is not ready, 130 interrupted.
130
+
131
+ ## Tests
132
+
133
+ cd clients/python
134
+ python -m unittest
135
+
136
+ They use a small server on a local port and no network. `tests/test_spec.py` holds that server, the limits
137
+ 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>.
flowiq-0.1.0/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # flowiq
2
+
3
+ A Python client and a command for the FlowIQ REST API. Python 3.9 or later, no other packages.
4
+
5
+ What the API does, in one file for programs: <https://flowiq-labs.com/api/openapi.json>. The query
6
+ language: <https://flowiq-labs.com/help>.
7
+
8
+ ## Install
9
+
10
+ pip install flowiq
11
+
12
+ ## Your key
13
+
14
+ Put it in the environment. The command has no option for it, because an argument can be read by every
15
+ other process on the machine and stays in the shell's history.
16
+
17
+ export FLOWIQ_API_KEY=sk_live_...
18
+
19
+ The key is sent in a header, only to https (or to your own machine), and never to wherever a redirect
20
+ points.
21
+
22
+ ## In Python
23
+
24
+ ```python
25
+ from flowiq import FlowIQ
26
+
27
+ fq = FlowIQ()
28
+
29
+ fq.count("protocol:mongodb country:BR")["total_found"]
30
+
31
+ for s in fq.search("protocol:mongodb country:BR -tags:honeypot", limit=500, fields=["ip", "port", "org"]):
32
+ print(s["ip"], s["port"], s["org"])
33
+
34
+ fq.host("203.0.113.5")["services"]
35
+ [n["name"] for n in fq.domain("example.com", limit=1000)]
36
+ fq.breakdown("asn", "protocol:mongodb country:BR", limit=20)["buckets"]
37
+ fq.fields() # what breakdown accepts
38
+ fq.account()["credits_remaining"]
39
+ fq.export("protocol:mongodb", "mongo.ndjson", limit=50000)
40
+ ```
41
+
42
+ `search` and `domain` fetch a page at a time as you read, so stopping early costs only what was fetched.
43
+ `limit=None` reads to the end. The object they return knows `total_found`, `notes` and `next_after`; give
44
+ `next_after` back as `after=` to continue a search later.
45
+
46
+ Read `notes`. A field name the server does not know is not an error: it searches titles for it, finds
47
+ nothing, and says so there.
48
+
49
+ ### What it costs
50
+
51
+ | call | credits |
52
+ |---|---|
53
+ | `search` | 1 a record, at least 1 a page |
54
+ | `count` | 1 |
55
+ | `host` | 1 a service on the host, at least 1. You do not choose how many that is; `count(ip)` says first |
56
+ | `domain` | 1 a name, at least 1 a page |
57
+ | `breakdown` | 1 a value returned, at least 1 |
58
+ | `export` | 1 a record in the file |
59
+ | `account`, `fields`, export status and download | none |
60
+
61
+ ### When it fails
62
+
63
+ Everything raised is a `FlowIQError`. An answer from the server is an `APIError` with `status`, `message`
64
+ (the server's own sentence) and `refused`, and has a class of its own: `BadRequest`, `Unauthorized`,
65
+ `Forbidden`, `NotFound`, `NotReady`, `Gone`, `RateLimited`, `ServerError`, `ServiceUnavailable`.
66
+
67
+ * 429 and 503 are tried again, waiting as long as the server says, or 1, 2, 4 ... seconds when it does not
68
+ say. A try that ends in 503 can cost one credit. `FlowIQ(retries=0)` turns this off.
69
+ * A connection lost while waiting is tried again only where asking twice is free. Anywhere else the server
70
+ may have run the call and charged for it, so you get `ConnectionFailed` and decide.
71
+ * `IncompleteResponse` means the answer began and stopped. Nothing half-read is ever returned as if whole.
72
+
73
+ ### Exports
74
+
75
+ `export` starts it, waits and downloads. The bytes go to `FILE.part` and take the name `FILE` only when the
76
+ file is whole. If it is interrupted, `export_download(id, path)` continues where it stopped, unless the file
77
+ on the server was rebuilt in the meantime, in which case it is fetched again. The four steps are also
78
+ methods of their own: `export_start`, `export_status`, `export_wait`, `export_download`.
79
+
80
+ ## The command
81
+
82
+ flowiq count 'protocol:mongodb country:BR'
83
+ flowiq search 'protocol:mongodb country:BR' --limit 500 --fields ip,port,org -o csv > mongo.csv
84
+ flowiq host 203.0.113.5
85
+ flowiq domain example.com --resolved --limit 1000 -o ndjson
86
+ flowiq breakdown asn 'protocol:mongodb country:BR' --limit 20
87
+ flowiq export 'protocol:mongodb' --limit 50000 -O mongo.ndjson --yes
88
+ flowiq export --resume 4711 -O mongo.ndjson
89
+ flowiq account
90
+ flowiq fields
91
+
92
+ `-o` is `json`, `ndjson`, `csv` or `table`; without it you get a table on a terminal and JSON elsewhere.
93
+
94
+ A call that can cost more than 1,000 credits says what it costs and what you have left, and stops unless you
95
+ add `--yes`. `--all` counts first, for one credit.
96
+
97
+ Titles, banners and names were written by whoever runs the service. On a terminal they are shown without
98
+ control characters, so they cannot move the cursor or hide text; in CSV a cell that a spreadsheet would run
99
+ as a formula gets a leading apostrophe. JSON keeps the exact value.
100
+
101
+ FlowIQ records what a service returned. It makes no claim that a host is vulnerable, and `last_seen` is the
102
+ last time a service answered, not a statement that it is up.
103
+
104
+ Exit codes: 0 done, 1 an error (the reason is on the error stream), 2 wrong arguments or `--yes` needed,
105
+ 3 the export is not ready, 130 interrupted.
106
+
107
+ ## Tests
108
+
109
+ cd clients/python
110
+ python -m unittest
111
+
112
+ They use a small server on a local port and no network. `tests/test_spec.py` holds that server, the limits
113
+ 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>.
@@ -0,0 +1,64 @@
1
+ """Client for the FlowIQ REST API. Standard library only.
2
+
3
+ from flowiq import FlowIQ
4
+
5
+ fq = FlowIQ() # key from FLOWIQ_API_KEY
6
+ for s in fq.search("protocol:mongodb country:BR", limit=500):
7
+ print(s["ip"], s["port"], s["last_seen"])
8
+ """
9
+
10
+ from ._version import __version__
11
+ from .client import (
12
+ DEFAULT_BASE_URL,
13
+ MAX_BREAKDOWN_BUCKETS,
14
+ MAX_DOMAIN_NAMES,
15
+ MAX_EXPORT_ROWS,
16
+ MAX_SEARCH_ROWS,
17
+ DomainNames,
18
+ FlowIQ,
19
+ SearchResults,
20
+ )
21
+ from .errors import (
22
+ APIError,
23
+ BadRequest,
24
+ ConfigError,
25
+ ConnectionFailed,
26
+ ExportFailed,
27
+ FlowIQError,
28
+ Forbidden,
29
+ Gone,
30
+ IncompleteResponse,
31
+ NotFound,
32
+ NotReady,
33
+ RateLimited,
34
+ ServerError,
35
+ ServiceUnavailable,
36
+ Unauthorized,
37
+ )
38
+
39
+ __all__ = [
40
+ "__version__",
41
+ "FlowIQ",
42
+ "SearchResults",
43
+ "DomainNames",
44
+ "DEFAULT_BASE_URL",
45
+ "MAX_SEARCH_ROWS",
46
+ "MAX_BREAKDOWN_BUCKETS",
47
+ "MAX_DOMAIN_NAMES",
48
+ "MAX_EXPORT_ROWS",
49
+ "FlowIQError",
50
+ "ConfigError",
51
+ "ConnectionFailed",
52
+ "IncompleteResponse",
53
+ "ExportFailed",
54
+ "APIError",
55
+ "BadRequest",
56
+ "Unauthorized",
57
+ "Forbidden",
58
+ "NotFound",
59
+ "NotReady",
60
+ "Gone",
61
+ "RateLimited",
62
+ "ServerError",
63
+ "ServiceUnavailable",
64
+ ]
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"