@@ -32,8 +32,11 @@ from neptune_api_v2 import NeptuneAPIV2
3232
3333client = NeptuneAPIV2()
3434
35- response = client.status.check_health()
36- print (response.status)
35+ response = client.markets.get_overview(
36+ with_text = True ,
37+ with_value = True ,
38+ )
39+ print (response.data)
3740```
3841
3942## Async usage
@@ -48,8 +51,11 @@ client = AsyncNeptuneAPIV2()
4851
4952
5053async def main () -> None :
51- response = await client.status.check_health()
52- print (response.status)
54+ response = await client.markets.get_overview(
55+ with_text = True ,
56+ with_value = True ,
57+ )
58+ print (response.data)
5359
5460
5561asyncio.run(main())
@@ -80,8 +86,11 @@ async def main() -> None:
8086 async with AsyncNeptuneAPIV2(
8187 http_client = DefaultAioHttpClient(),
8288 ) as client:
83- response = await client.status.check_health()
84- print (response.status)
89+ response = await client.markets.get_overview(
90+ with_text = True ,
91+ with_value = True ,
92+ )
93+ print (response.data)
8594
8695
8796asyncio.run(main())
@@ -107,16 +116,14 @@ from neptune_api_v2 import NeptuneAPIV2
107116
108117client = NeptuneAPIV2()
109118
110- all_assets = []
119+ all_users = []
111120# Automatically fetches more pages as needed.
112- for asset in client.assets.get_price_history(
113- end = 0 ,
114- period = " h" ,
115- start = 0 ,
121+ for user in client.user.get_tx_history(
122+ address = " injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0" ,
116123):
117- # Do something with asset here
118- all_assets .append(asset )
119- print (all_assets )
124+ # Do something with user here
125+ all_users .append(user )
126+ print (all_users )
120127```
121128
122129Or, asynchronously:
@@ -129,15 +136,13 @@ client = AsyncNeptuneAPIV2()
129136
130137
131138async def main () -> None :
132- all_assets = []
139+ all_users = []
133140 # Iterate through items across all pages, issuing requests as needed.
134- async for asset in client.assets.get_price_history(
135- end = 0 ,
136- period = " h" ,
137- start = 0 ,
141+ async for user in client.user.get_tx_history(
142+ address = " injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0" ,
138143 ):
139- all_assets .append(asset )
140- print (all_assets )
144+ all_users .append(user )
145+ print (all_users )
141146
142147
143148asyncio.run(main())
@@ -146,33 +151,27 @@ asyncio.run(main())
146151Alternatively, you can use the ` .has_next_page() ` , ` .next_page_info() ` , or ` .get_next_page() ` methods for more granular control working with pages:
147152
148153``` python
149- first_page = await client.assets.get_price_history(
150- end = 0 ,
151- period = " h" ,
152- start = 0 ,
154+ first_page = await client.user.get_tx_history(
155+ address = " injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0" ,
153156)
154157if first_page.has_next_page():
155158 print (f " will fetch next page using these details: { first_page.next_page_info()} " )
156159 next_page = await first_page.get_next_page()
157- print (f " number of items we just fetched: { len (next_page.data.series )} " )
160+ print (f " number of items we just fetched: { len (next_page.data)} " )
158161
159162# Remove `await` for non-async usage.
160163```
161164
162165Or just work directly with the returned data:
163166
164167``` python
165- first_page = await client.assets.get_price_history(
166- end = 0 ,
167- period = " h" ,
168- start = 0 ,
168+ first_page = await client.user.get_tx_history(
169+ address = " injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0" ,
169170)
170171
171- print (
172- f " the current start offset for this page: { first_page.data.pagination.next_offset} "
173- ) # => "the current start offset for this page: 1"
174- for asset in first_page.data.series:
175- print (asset.asset)
172+ print (f " next page cursor: { first_page.prev_event_uuid} " ) # => "next page cursor: ..."
173+ for user in first_page.data:
174+ print (user.event_uuid)
176175
177176# Remove `await` for non-async usage.
178177```
@@ -193,7 +192,10 @@ from neptune_api_v2 import NeptuneAPIV2
193192client = NeptuneAPIV2()
194193
195194try :
196- client.status.check_health()
195+ client.markets.get_overview(
196+ with_text = True ,
197+ with_value = True ,
198+ )
197199except neptune_api_v2.APIConnectionError as e:
198200 print (" The server could not be reached" )
199201 print (e.__cause__) # an underlying Exception, likely raised within httpx.
@@ -236,7 +238,10 @@ client = NeptuneAPIV2(
236238)
237239
238240# Or, configure per-request:
239- client.with_options(max_retries = 5 ).status.check_health()
241+ client.with_options(max_retries = 5 ).markets.get_overview(
242+ with_text = True ,
243+ with_value = True ,
244+ )
240245```
241246
242247### Timeouts
@@ -259,7 +264,10 @@ client = NeptuneAPIV2(
259264)
260265
261266# Override per-request:
262- client.with_options(timeout = 5.0 ).status.check_health()
267+ client.with_options(timeout = 5.0 ).markets.get_overview(
268+ with_text = True ,
269+ with_value = True ,
270+ )
263271```
264272
265273On timeout, an ` APITimeoutError ` is thrown.
@@ -300,11 +308,14 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
300308from neptune_api_v2 import NeptuneAPIV2
301309
302310client = NeptuneAPIV2()
303- response = client.status.with_raw_response.check_health()
311+ response = client.markets.with_raw_response.get_overview(
312+ with_text = True ,
313+ with_value = True ,
314+ )
304315print (response.headers.get(' X-My-Header' ))
305316
306- status = response.parse() # get the object that `status.check_health ()` would have returned
307- print (status.status )
317+ market = response.parse() # get the object that `markets.get_overview ()` would have returned
318+ print (market.data )
308319```
309320
310321These methods return an [ ` APIResponse ` ] ( https://github.com/cryptechdev/neptune-api-v2-python/tree/main/src/neptune_api_v2/_response.py ) object.
@@ -318,7 +329,10 @@ The above interface eagerly reads the full response body when you make the reque
318329To stream the response body, use ` .with_streaming_response ` instead, which requires a context manager and only reads the response body once you call ` .read() ` , ` .text() ` , ` .json() ` , ` .iter_bytes() ` , ` .iter_text() ` , ` .iter_lines() ` or ` .parse() ` . In the async client, these are async methods.
319330
320331``` python
321- with client.status.with_streaming_response.check_health() as response:
332+ with client.markets.with_streaming_response.get_overview(
333+ with_text = True ,
334+ with_value = True ,
335+ ) as response:
322336 print (response.headers.get(" X-My-Header" ))
323337
324338 for line in response.iter_lines():
0 commit comments