Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
publish:
name: publish
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v6
Expand All @@ -24,5 +28,3 @@ jobs:
- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.NEPTUNE_API_V2_PYPI_TOKEN || secrets.PYPI_TOKEN }}
5 changes: 2 additions & 3 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Release Doctor
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
Expand All @@ -9,6 +9,7 @@ jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
environment: production
if: github.repository == 'cryptechdev/neptune-api-v2-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
Expand All @@ -17,5 +18,3 @@ jobs:
- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.NEPTUNE_API_V2_PYPI_TOKEN || secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.2.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 48
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cryptech%2Fneptune-api-v2-5768d4f43166406f5b74235f2dd9e91082bd67a7b182ca05d5df55604ebedd7e.yml
openapi_spec_hash: 2c5da98fd945fbfc68611634b7aa7042
config_hash: fa0efc29593602eac57523d55bc83fa6
configured_endpoints: 50
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cryptech%2Fneptune-api-v2-cd88dd75403e620991c3659cd7e9278f9c8c439f3857c25db8634dfc7e77a9b9.yml
openapi_spec_hash: 35a0cbd0262458d633e38fc5ba442118
config_hash: a79df81e5bba11abab18a84163248141
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.2.0 (2026-04-03)

Full Changelog: [v0.1.0...v0.2.0](https://github.com/cryptechdev/neptune-api-v2-python/compare/v0.1.0...v0.2.0)

### Features

* **api:** add missing models, pagination impls ([1aa9a59](https://github.com/cryptechdev/neptune-api-v2-python/commit/1aa9a590bdc800e554100b00a41b552add478bce))
* **api:** add python publishing config ([72173a4](https://github.com/cryptechdev/neptune-api-v2-python/commit/72173a429dddb88648a29991c1870d86dd8c6b0a))
* **api:** api update ([ebee3a7](https://github.com/cryptechdev/neptune-api-v2-python/commit/ebee3a79f42790d9fba6fced90848e432581817f))
* **api:** api update ([a2daaa3](https://github.com/cryptechdev/neptune-api-v2-python/commit/a2daaa306f5c0ea3c17d2816d25ab9eaf90f058c))
* **api:** api update ([64bfdf0](https://github.com/cryptechdev/neptune-api-v2-python/commit/64bfdf0f0f702d71e05b37a490f1ced871af27d0))
* **api:** disable series pagn, update example requests ([9d71f0b](https://github.com/cryptechdev/neptune-api-v2-python/commit/9d71f0b3d797212151cb8d65c5ff72886904a6e9))
* **api:** Fix readme title, fix inverted example params ([c90715f](https://github.com/cryptechdev/neptune-api-v2-python/commit/c90715f3ad82baedeb47f32889d7aba4404d5114))
* **api:** manual updates ([3424a81](https://github.com/cryptechdev/neptune-api-v2-python/commit/3424a811af4205ad9396f23f7fd56055f6e2fb35))
* **api:** manual updates ([f1f5aae](https://github.com/cryptechdev/neptune-api-v2-python/commit/f1f5aaef9e720cdb0933330c9836e8a666b806b4))


### Chores

* remove custom code ([d81def3](https://github.com/cryptechdev/neptune-api-v2-python/commit/d81def31c6a38ad5972605a6054bf701bcaad6be))
* update SDK settings ([3ea9109](https://github.com/cryptechdev/neptune-api-v2-python/commit/3ea910942b953e7ee8f5ed1baa371d72df8dfaf6))
* update SDK settings ([3b2c9f9](https://github.com/cryptechdev/neptune-api-v2-python/commit/3b2c9f9b390aa03d3601dea10cb69133568726fd))
* update SDK settings ([a41b0dd](https://github.com/cryptechdev/neptune-api-v2-python/commit/a41b0dd737f1ca76a0af6af4792c05dac3ea0b93))
* update SDK settings ([5759a86](https://github.com/cryptechdev/neptune-api-v2-python/commit/5759a869889951c83f68dfc8d7df247c81fe6cd1))

## 0.1.0 (2026-03-30)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/cryptechdev/neptune-api-v2-python/compare/v0.0.1...v0.1.0)
Expand Down
117 changes: 97 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ The full API of this library can be found in [api.md](api.md).
## Installation

```sh
# install from the production repo
pip install git+ssh://git@github.com/cryptechdev/neptune-api-v2-python.git
# install from PyPI
pip install neptune_api_v2
```

> [!NOTE]
> Once this package is [published to PyPI](https://www.stainless.com/docs/guides/publish), this will become: `pip install neptune_api_v2`

## Usage

The full API of this library can be found in [api.md](api.md).
Expand All @@ -32,8 +29,11 @@ from neptune_api_v2 import NeptuneAPIV2

client = NeptuneAPIV2()

response = client.status.check_health()
print(response.status)
response = client.markets.get_overview(
with_text=True,
with_value=True,
)
print(response.data)
```

## Async usage
Expand All @@ -48,8 +48,11 @@ client = AsyncNeptuneAPIV2()


async def main() -> None:
response = await client.status.check_health()
print(response.status)
response = await client.markets.get_overview(
with_text=True,
with_value=True,
)
print(response.data)


asyncio.run(main())
Expand All @@ -64,8 +67,8 @@ By default, the async client uses `httpx` for HTTP requests. However, for improv
You can enable this by installing `aiohttp`:

```sh
# install from the production repo
pip install 'neptune_api_v2[aiohttp] @ git+ssh://git@github.com/cryptechdev/neptune-api-v2-python.git'
# install from PyPI
pip install neptune_api_v2[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
Expand All @@ -80,8 +83,11 @@ async def main() -> None:
async with AsyncNeptuneAPIV2(
http_client=DefaultAioHttpClient(),
) as client:
response = await client.status.check_health()
print(response.status)
response = await client.markets.get_overview(
with_text=True,
with_value=True,
)
print(response.data)


asyncio.run(main())
Expand All @@ -96,6 +102,77 @@ Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typ

Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.

## Pagination

List methods in the Neptune API V2 API are paginated.

This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:

```python
from neptune_api_v2 import NeptuneAPIV2

client = NeptuneAPIV2()

all_users = []
# Automatically fetches more pages as needed.
for user in client.user.get_tx_history(
address="injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0",
):
# Do something with user here
all_users.append(user)
print(all_users)
```

Or, asynchronously:

```python
import asyncio
from neptune_api_v2 import AsyncNeptuneAPIV2

client = AsyncNeptuneAPIV2()


async def main() -> None:
all_users = []
# Iterate through items across all pages, issuing requests as needed.
async for user in client.user.get_tx_history(
address="injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0",
):
all_users.append(user)
print(all_users)


asyncio.run(main())
```

Alternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:

```python
first_page = await client.user.get_tx_history(
address="injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0",
)
if first_page.has_next_page():
print(f"will fetch next page using these details: {first_page.next_page_info()}")
next_page = await first_page.get_next_page()
print(f"number of items we just fetched: {len(next_page.data)}")

# Remove `await` for non-async usage.
```

Or just work directly with the returned data:

```python
first_page = await client.user.get_tx_history(
address="injvalcons1a03k0ztfyjnd70apawva003pkh0adqmau0a9q0",
)

print(f"next page cursor: {first_page.prev_event_uuid}") # => "next page cursor: ..."
for user in first_page.data:
print(user.event_uuid)

# Remove `await` for non-async usage.
```

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `neptune_api_v2.APIConnectionError` is raised.
Expand All @@ -112,7 +189,7 @@ from neptune_api_v2 import NeptuneAPIV2
client = NeptuneAPIV2()

try:
client.status.check_health()
client.markets.get_overview()
except neptune_api_v2.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -155,7 +232,7 @@ client = NeptuneAPIV2(
)

# Or, configure per-request:
client.with_options(max_retries=5).status.check_health()
client.with_options(max_retries=5).markets.get_overview()
```

### Timeouts
Expand All @@ -178,7 +255,7 @@ client = NeptuneAPIV2(
)

# Override per-request:
client.with_options(timeout=5.0).status.check_health()
client.with_options(timeout=5.0).markets.get_overview()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -219,11 +296,11 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from neptune_api_v2 import NeptuneAPIV2

client = NeptuneAPIV2()
response = client.status.with_raw_response.check_health()
response = client.markets.with_raw_response.get_overview()
print(response.headers.get('X-My-Header'))

status = response.parse() # get the object that `status.check_health()` would have returned
print(status.status)
market = response.parse() # get the object that `markets.get_overview()` would have returned
print(market.data)
```

These methods return an [`APIResponse`](https://github.com/cryptechdev/neptune-api-v2-python/tree/main/src/neptune_api_v2/_response.py) object.
Expand All @@ -237,7 +314,7 @@ The above interface eagerly reads the full response body when you make the reque
To 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.

```python
with client.status.with_streaming_response.check_health() as response:
with client.markets.with_streaming_response.get_overview() as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down
38 changes: 26 additions & 12 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ from neptune_api_v2.types import (
ErrorData,
ErrorDataVariants,
ErrorKind,
ErrorResponseVariants,
ErrorResponse,
ErrorScope,
FieldValidationError,
Interval,
IntervalUnit,
ListErrorResponse,
ObjErrorResponse,
ValidationErrorData,
ValidationFieldSource,
)
Expand Down Expand Up @@ -186,18 +184,12 @@ Methods:
Types:

```python
from neptune_api_v2.types import (
EventAction,
User,
UserTx,
UserGetTxHistoryResponse,
UserGetUserResponse,
)
from neptune_api_v2.types import EventAction, User, UserTx, UserGetUserResponse
```

Methods:

- <code title="get /api/v1/users/{address}/tx-history">client.user.<a href="./src/neptune_api_v2/resources/user/user.py">get_tx_history</a>(address, \*\*<a href="src/neptune_api_v2/types/user_get_tx_history_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/user_get_tx_history_response.py">UserGetTxHistoryResponse</a></code>
- <code title="get /api/v1/users/{address}/tx-history">client.user.<a href="./src/neptune_api_v2/resources/user/user.py">get_tx_history</a>(address, \*\*<a href="src/neptune_api_v2/types/user_get_tx_history_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/user_tx.py">SyncTxHistoryPage[UserTx]</a></code>
- <code title="get /api/v1/users/{address}/user">client.user.<a href="./src/neptune_api_v2/resources/user/user.py">get_user</a>(address, \*\*<a href="src/neptune_api_v2/types/user_get_user_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/user_get_user_response.py">UserGetUserResponse</a></code>

## Market
Expand Down Expand Up @@ -226,7 +218,10 @@ Types:

```python
from neptune_api_v2.types.user.market import (
UserLendAssetPool,
UserLendMarket,
UserLendOriginAmounts,
UserLendReceiptAmounts,
LendListResponse,
LendGetByAssetResponse,
)
Expand Down Expand Up @@ -379,7 +374,7 @@ from neptune_api_v2.types.analytics.market import (

Methods:

- <code title="get /api/v1/analytics/market/history/loans-originated">client.analytics.market.history.<a href="./src/neptune_api_v2/resources/analytics/market/history.py">get_loans_originated</a>(\*\*<a href="src/neptune_api_v2/types/analytics/market/history_get_loans_originated_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/analytics/market/history_get_loans_originated_response.py">HistoryGetLoansOriginatedResponse</a></code>
- <code title="get /api/v1/analytics/market/history/loans-originated">client.analytics.market.history.<a href="./src/neptune_api_v2/resources/analytics/market/history.py">get_loans_originated</a>(\*\*<a href="src/neptune_api_v2/types/analytics/market/history_get_loans_originated_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/analytics/market/history_get_loans_originated_response.py">SyncIntervalSinglePage[HistoryGetLoansOriginatedResponse]</a></code>
- <code title="get /api/v1/analytics/market/history/loans-originated/by-asset">client.analytics.market.history.<a href="./src/neptune_api_v2/resources/analytics/market/history.py">get_loans_originated_by_asset</a>(\*\*<a href="src/neptune_api_v2/types/analytics/market/history_get_loans_originated_by_asset_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/analytics/market/history_get_loans_originated_by_asset_response.py">HistoryGetLoansOriginatedByAssetResponse</a></code>

## Nept
Expand Down Expand Up @@ -407,3 +402,22 @@ from neptune_api_v2.types.integrations import BantrGetTransactionsResponse
Methods:

- <code title="get /api/v1/integrations/bantr/transactions">client.integrations.bantr.<a href="./src/neptune_api_v2/resources/integrations/bantr.py">get_transactions</a>(\*\*<a href="src/neptune_api_v2/types/integrations/bantr_get_transactions_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/integrations/bantr_get_transactions_response.py">BantrGetTransactionsResponse</a></code>

# Swap

## Routes

Types:

```python
from neptune_api_v2.types.swap import (
SwapRouteTargetSet,
RouteListAllResponse,
RouteListByDenomResponse,
)
```

Methods:

- <code title="get /api/v1/swap/routes/all">client.swap.routes.<a href="./src/neptune_api_v2/resources/swap/routes.py">list_all</a>(\*\*<a href="src/neptune_api_v2/types/swap/route_list_all_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/swap/route_list_all_response.py">RouteListAllResponse</a></code>
- <code title="get /api/v1/swap/routes">client.swap.routes.<a href="./src/neptune_api_v2/resources/swap/routes.py">list_by_denom</a>(\*\*<a href="src/neptune_api_v2/types/swap/route_list_by_denom_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/swap/route_list_by_denom_response.py">RouteListByDenomResponse</a></code>
4 changes: 0 additions & 4 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

errors=()

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
Expand Down
6 changes: 5 additions & 1 deletion bin/publish-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ set -eux
rm -rf dist
mkdir -p dist
uv build
uv publish --token=$PYPI_TOKEN
if [ -n "${PYPI_TOKEN:-}" ]; then
uv publish --token=$PYPI_TOKEN
else
uv publish
fi
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "neptune_api_v2"
version = "0.1.0"
version = "0.2.0"
description = "The official Python library for the neptune-api-v2 API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
Loading
Loading