From 01b280f87181c917e788f218a5ceae7e0338d89d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 17 Mar 2026 13:36:13 +0100 Subject: [PATCH 1/2] README: replace inline examples with links to example directory --- README.md | 117 ++---------------------------------------------------- 1 file changed, 4 insertions(+), 113 deletions(-) diff --git a/README.md b/README.md index ddaa9f7..fc2d8e4 100644 --- a/README.md +++ b/README.md @@ -53,116 +53,7 @@ If you need commercial support, have a look at https://leakix.net/plans. ## Examples -```python -import decouple -from leakix import Client -from leakix.query import MustQuery, MustNotQuery, RawQuery -from leakix.field import PluginField, CountryField, TimeField, Operator -from leakix.plugin import Plugin -from datetime import datetime, timedelta - - -API_KEY = decouple.config("API_KEY") -BASE_URL = decouple.config("LEAKIX_HOST", default=None) -CLIENT = Client(api_key=API_KEY) - - -def example_get_host_filter_plugin(): - response = CLIENT.get_host(ipv4="33.33.33.33") - assert response.status_code() == 200 - - -def example_get_service_filter_plugin(): - """ - Filter by fields. In this example, we want to have the NTLM services. - A list of plugins can be found in leakix.plugin - """ - query_http_ntlm = MustQuery(field=PluginField(Plugin.HttpNTLM)) - response = CLIENT.get_service(queries=[query_http_ntlm]) - assert response.status_code() == 200 - # check we only get NTML related services - assert all((i.tags == ["ntlm"] for i in response.json())) - - -def example_get_service_filter_plugin_with_pagination(): - """ - Filter by fields. In this example, we want to have the NTLM services. - A list of plugins can be found in leakix.plugin. - Ask for page 1 (starts at 0) - """ - query_http_ntlm = MustQuery(field=PluginField(Plugin.HttpNTLM)) - response = CLIENT.get_service(queries=[query_http_ntlm], page=1) - assert response.status_code() == 200 - # check we only get NTML related services - assert all((i.tags == ["ntlm"] for i in response.json())) - - -def example_get_leaks_filter_multiple_plugins(): - query_http_ntlm = MustQuery(field=PluginField(Plugin.HttpNTLM)) - query_country = MustQuery(field=CountryField("France")) - response = CLIENT.get_leak(queries=[query_http_ntlm, query_country]) - assert response.status_code() == 200 - assert all( - ( - i.geoip.country_name == "France" and i.tags == ["ntlm"] - for i in response.json() - ) - ) - - -def example_get_leaks_multiple_filter_plugins_must_not(): - query_http_ntlm = MustQuery(field=PluginField(Plugin.HttpNTLM)) - query_country = MustNotQuery(field=CountryField("France")) - response = CLIENT.get_leak(queries=[query_http_ntlm, query_country]) - assert response.status_code() == 200 - assert all( - ( - i.geoip.country_name != "France" and i.tags == ["ntlm"] - for i in response.json() - ) - ) - - -def example_get_leak_raw_query(): - raw_query = '+plugin:HttpNTLM +country:"France"' - query = RawQuery(raw_query) - response = CLIENT.get_leak(queries=[query]) - assert response.status_code() == 200 - assert all( - ( - i.geoip.country_name == "France" and i.tags == ["ntlm"] - for i in response.json() - ) - ) - - -def example_get_leak_plugins_with_time(): - query_plugin = MustQuery(field=PluginField(Plugin.GitConfigHttpPlugin)) - today = datetime.now() - one_month_ago = today - timedelta(days=30) - query_today = MustQuery(field=TimeField(today, Operator.StrictlySmaller)) - query_yesterday = MustQuery( - field=TimeField(one_month_ago, Operator.StrictlyGreater) - ) - queries = [query_today, query_yesterday, query_plugin] - response = CLIENT.get_leak(queries=queries) - assert response.status_code() == 200 - - -def example_get_plugins(): - response = CLIENT.get_plugins() - for p in response.json(): - print(p.name) - print(p.description) - - -if __name__ == "__main__": - example_get_host_filter_plugin() - example_get_service_filter_plugin() - example_get_service_filter_plugin_with_pagination() - example_get_leaks_filter_multiple_plugins() - example_get_leaks_multiple_filter_plugins_must_not() - example_get_leak_plugins_with_time() - example_get_leak_raw_query() - example_get_plugins() -``` +See the [example/](example/) directory for complete usage examples: + +- [Sync client](example/example_client.py) +- [Async client](example/example_async_client.py) From d1b953f273fce9da40ff971cd64fca5b25d82b5c Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 17 Mar 2026 13:37:15 +0100 Subject: [PATCH 2/2] CHANGELOG: redirect README examples to example directory --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cca268c..087cc79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ and this project adheres to - Updated l9format requirement from =2.0.0 to =2.0.1 ([5764b2f], [#74]) - Use explicit include lists instead of exclude lists for hatch build targets (sdist and wheel) in `pyproject.toml` ([aa9cc03], [#75]) +- README: replace inline examples with links to `example/` directory + ([01b280f], [#76]) ### Fixed @@ -84,6 +86,7 @@ and this project adheres to [0.1.9]: https://github.com/LeakIX/LeakIXClient-Python/releases/tag/v0.1.9 +[01b280f]: https://github.com/LeakIX/LeakIXClient-Python/commit/01b280f [aa9cc03]: https://github.com/LeakIX/LeakIXClient-Python/commit/aa9cc03 [5764b2f]: https://github.com/LeakIX/LeakIXClient-Python/commit/5764b2f [cfa8b6c]: https://github.com/LeakIX/LeakIXClient-Python/commit/cfa8b6c @@ -111,3 +114,4 @@ and this project adheres to [#72]: https://github.com/LeakIX/LeakIXClient-Python/pull/72 [#74]: https://github.com/LeakIX/LeakIXClient-Python/pull/74 [#75]: https://github.com/LeakIX/LeakIXClient-Python/pull/75 +[#76]: https://github.com/LeakIX/LeakIXClient-Python/pull/76