Skip to content

Commit beb7185

Browse files
committed
Docs: Add examples for search(), get_domain() and streaming bulk
1 parent 4e4d2bc commit beb7185

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ pip install leakix
1313

1414
To run tests, use `poetry run pytest`.
1515

16+
## Quick Start
17+
18+
```python
19+
from leakix import Client
20+
21+
client = Client(api_key="your-api-key")
22+
23+
# Simple search - same syntax as the website
24+
results = client.search("+plugin:GitConfigHttpPlugin", scope="leak")
25+
for event in results.json():
26+
print(event.ip, event.host)
27+
28+
# Search services
29+
results = client.search("+country:FR +port:22", scope="service")
30+
```
31+
1632
## Documentation
1733

1834
Docstrings are used to document the library.
@@ -156,6 +172,55 @@ def example_get_plugins():
156172
print(p.description)
157173

158174

175+
def example_search_simple():
176+
"""
177+
Simple search using query string syntax (same as the website).
178+
No need to build Query objects manually.
179+
"""
180+
response = CLIENT.search("+plugin:GitConfigHttpPlugin", scope="leak")
181+
for event in response.json():
182+
print(event.ip)
183+
184+
185+
def example_search_service():
186+
"""
187+
Search for services with multiple filters.
188+
"""
189+
response = CLIENT.search("+country:FR +port:22", scope="service")
190+
for event in response.json():
191+
print(event.ip, event.port)
192+
193+
194+
def example_get_domain():
195+
"""
196+
Get services and leaks for a domain.
197+
"""
198+
response = CLIENT.get_domain("example.com")
199+
if response.is_success():
200+
print("Services:", response.json()["services"])
201+
print("Leaks:", response.json()["leaks"])
202+
203+
204+
def example_bulk_stream():
205+
"""
206+
Streaming bulk export - memory efficient for large datasets.
207+
Results are yielded one by one instead of loading all into memory.
208+
"""
209+
query = MustQuery(field=PluginField(Plugin.GitConfigHttpPlugin))
210+
for aggregation in CLIENT.bulk_export_stream(queries=[query]):
211+
for event in aggregation.events:
212+
print(event.ip)
213+
214+
215+
def example_bulk_service_stream():
216+
"""
217+
Streaming bulk service - memory efficient for large datasets.
218+
"""
219+
query = MustQuery(field=PluginField(Plugin.GitConfigHttpPlugin))
220+
for event in CLIENT.bulk_service_stream(queries=[query]):
221+
print(event.ip)
222+
223+
159224
if __name__ == "__main__":
160225
example_get_host_filter_plugin()
161226
example_get_service_filter_plugin()
@@ -165,4 +230,9 @@ if __name__ == "__main__":
165230
example_get_leak_plugins_with_time()
166231
example_get_leak_raw_query()
167232
example_get_plugins()
233+
example_search_simple()
234+
example_search_service()
235+
example_get_domain()
236+
example_bulk_stream()
237+
example_bulk_service_stream()
168238
```

0 commit comments

Comments
 (0)