Skip to content

Commit 4fa81d7

Browse files
Add example snippet for query function
1 parent 6b28ca1 commit 4fa81d7

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

README.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,36 @@ if __name__ == "__main__":
2828

2929
### Other API interactions
3030

31-
This module also provides a client for other API interactions with Elimity Insights. The snippet below shows how to
32-
authenticate with an API token and list sources at an Elimity Insights server. You can generate a token identifier and
33-
secret by visiting the 'API tokens' page in Elimity Insights and clicking the 'CREATE API TOKEN' button.
31+
This module also provides a client for other API interactions with Elimity Insights. The snippets below show how to
32+
execute queries and list sources respectively. Both use an API token for authentication. You can generate a token
33+
identifier and secret by visiting the 'API tokens' page in Elimity Insights and clicking the 'CREATE API TOKEN' button.
34+
35+
#### Executing queries
36+
37+
```python3
38+
from elimity_insights_client.api import Config, query
39+
from elimity_insights_client.api.expression import AttributeBooleanExpression
40+
from elimity_insights_client.query import AnyExpression, DirectLinkGroupByQuery, DirectLinkQuery, LinkGroupByQuery, Ordering, Query
41+
42+
if __name__ == "__main__":
43+
config = Config(token_id="1", token_secret="my-secret-value", url="https://example.elimity.com", verify_ssl=True)
44+
condition = AttributeBooleanExpression("isShareByEmailGuestUser", "u")
45+
direct_link_group_by_queries: list[DirectLinkGroupByQuery] = []
46+
direct_link_queries: list[DirectLinkQuery] = []
47+
include: list[AnyExpression] = []
48+
link_group_by_queries: list[LinkGroupByQuery] = []
49+
link_queries: list[Query] = []
50+
orderings: list[Ordering] = []
51+
q = Query(
52+
"u", condition, direct_link_group_by_queries, direct_link_queries, "user", include, 10, link_group_by_queries,
53+
link_queries, 0, orderings, 1
54+
)
55+
queries = [q]
56+
pages = query(config, queries)
57+
print(pages)
58+
```
59+
60+
#### Listing sources
3461

3562
```python3
3663
from elimity_insights_client.api import Config, sources

0 commit comments

Comments
 (0)