Skip to content

Commit 7997143

Browse files
committed
add async usage to readme
1 parent b8ca5cb commit 7997143

File tree

1 file changed

+8
-41
lines changed

1 file changed

+8
-41
lines changed

README.md

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pip install metabase-api
1010
```
1111

1212
## Initializing
13+
14+
#### Synchronous
1315
```python
1416
from metabase_api import Metabase_API
1517

@@ -20,51 +22,16 @@ mb = Metabase_API('https://...', 'username', 'password') # if password is not g
2022
mb = Metabase_API('https://...', api_key='YOUR_API_KEY')
2123
```
2224

23-
## Asynchronous Usage
24-
The library now supports asynchronous operations using `httpx`:
25+
#### Async
2526

2627
```python
27-
import asyncio
2828
from metabase_api import Metabase_API_Async
2929

30-
async def main():
31-
# authentication using username/password
32-
mb_async = Metabase_API_Async('https://...', 'username', 'password')
33-
34-
# authentication using API key
35-
# mb_async = Metabase_API_Async('https://...', api_key='YOUR_API_KEY')
36-
37-
# Get data from a card
38-
data = await mb_async.get_card_data_async(card_id=123)
39-
print(data)
40-
41-
# Search for items
42-
search_results = await mb_async.search_async('query_term')
43-
print(search_results)
44-
45-
# Create a card
46-
card = await mb_async.create_card(
47-
card_name='My Async Card',
48-
table_name='my_table',
49-
collection_name='My Collection'
50-
)
51-
52-
# Copy a dashboard
53-
new_dashboard_id = await mb_async.copy_dashboard(
54-
source_dashboard_name='Source Dashboard',
55-
destination_collection_name='Destination Collection',
56-
deepcopy=True
57-
)
58-
59-
# Copy a collection
60-
await mb_async.copy_collection(
61-
source_collection_name='Source Collection',
62-
destination_parent_collection_name='Destination Parent',
63-
deepcopy_dashboards=True
64-
)
65-
66-
# Run the async function
67-
asyncio.run(main())
30+
# authentication using username/password
31+
mb = Metabase_API_Async('https://...', 'username', 'password') # if password is not given, it will prompt for password
32+
33+
# authentication using API key
34+
mb = Metabase_API_Async('https://...', api_key='YOUR_API_KEY')
6835
```
6936

7037
## Functions

0 commit comments

Comments
 (0)