Skip to content
Open
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
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.6.0"
".": "0.6.1"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 49
configured_endpoints: 50
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cryptech%2Fneptune-api-v2-05e0ec4b9b945a8c8e3542d34f0759f4eed2046a37750700fd40619f8a0cd6d7.yml
openapi_spec_hash: 3911018927f898449898cc6cc5685273
config_hash: f5ca3bc259f95069f0db4114d34e29ef
config_hash: fdcc5ae6c783dda7176ace266f7ad0fd
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.6.1 (2026-04-23)

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

### Performance Improvements

* **client:** optimize file structure copying in multipart requests ([e3b4463](https://github.com/cryptechdev/neptune-api-v2-python/commit/e3b44635c279a772f8626572cd192601b0b4d62f))


### Chores

* **internal:** fix ([6d99eaa](https://github.com/cryptechdev/neptune-api-v2-python/commit/6d99eaacc946f60cc38e251e74d3df1878c85231))
* **internal:** more robust bootstrap script ([f0b98d2](https://github.com/cryptechdev/neptune-api-v2-python/commit/f0b98d296af0176f85591c6a2cabd1a32bcb56ec))

## 0.6.0 (2026-04-17)

Full Changelog: [v0.5.0...v0.6.0](https://github.com/cryptechdev/neptune-api-v2-python/compare/v0.5.0...v0.6.0)
Expand Down
8 changes: 8 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ Types:
from neptune_api_v2.types import (
GlobalMarketConfig,
MarketRate,
MarketSupplyPool,
MergedMarket,
Tvl,
MarketGetMergedResponse,
MarketGetMergedByAssetResponse,
MarketGetOverviewResponse,
MarketGetParamsResponse,
MarketGetSupplyResponse,
)
```

Expand All @@ -77,6 +79,7 @@ Methods:
- <code title="get /api/v1/markets/merged/lookup">client.markets.<a href="./src/neptune_api_v2/resources/markets/markets.py">get_merged_by_asset</a>(\*\*<a href="src/neptune_api_v2/types/market_get_merged_by_asset_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/market_get_merged_by_asset_response.py">MarketGetMergedByAssetResponse</a></code>
- <code title="get /api/v1/markets">client.markets.<a href="./src/neptune_api_v2/resources/markets/markets.py">get_overview</a>(\*\*<a href="src/neptune_api_v2/types/market_get_overview_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/market_get_overview_response.py">MarketGetOverviewResponse</a></code>
- <code title="get /api/v1/markets/config">client.markets.<a href="./src/neptune_api_v2/resources/markets/markets.py">get_params</a>(\*\*<a href="src/neptune_api_v2/types/market_get_params_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/market_get_params_response.py">MarketGetParamsResponse</a></code>
- <code title="get /api/v1/markets/supply">client.markets.<a href="./src/neptune_api_v2/resources/markets/markets.py">get_supply</a>(\*\*<a href="src/neptune_api_v2/types/market_get_supply_params.py">params</a>) -> <a href="./src/neptune_api_v2/types/market_get_supply_response.py">MarketGetSupplyResponse</a></code>

## Lend

Expand All @@ -87,6 +90,8 @@ from neptune_api_v2.types.markets import (
LendMarket,
LendMarketData,
LendMarketState,
LendMarketSupply,
LendOverview,
LendListResponse,
LendGetByAssetResponse,
LendGetRateHistoryResponse,
Expand Down Expand Up @@ -125,6 +130,8 @@ from neptune_api_v2.types.markets.borrow import (
BorrowCollateralConfig,
BorrowCollateralMarket,
BorrowCollateralMarketData,
BorrowCollateralMarketSupply,
BorrowCollateralOverview,
BorrowCollateralState,
CollateralListResponse,
CollateralGetByAssetResponse,
Expand All @@ -145,6 +152,7 @@ from neptune_api_v2.types.markets.borrow import (
BorrowDebtConfig,
BorrowDebtMarket,
BorrowDebtMarketData,
BorrowDebtOverview,
BorrowDebtState,
DebtListResponse,
DebtGetByAssetResponse,
Expand Down
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.6.0"
version = "0.6.1"
description = "The official Python library for the neptune-api-v2 API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
Expand Down
56 changes: 53 additions & 3 deletions src/neptune_api_v2/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io
import os
import pathlib
from typing import overload
from typing_extensions import TypeGuard
from typing import Sequence, cast, overload
from typing_extensions import TypeVar, TypeGuard

import anyio

Expand All @@ -17,7 +17,9 @@
HttpxFileContent,
HttpxRequestFiles,
)
from ._utils import is_tuple_t, is_mapping_t, is_sequence_t
from ._utils import is_list, is_mapping, is_tuple_t, is_mapping_t, is_sequence_t

_T = TypeVar("_T")


def is_base64_file_input(obj: object) -> TypeGuard[Base64FileInput]:
Expand Down Expand Up @@ -121,3 +123,51 @@ async def async_read_file_content(file: FileContent) -> HttpxFileContent:
return await anyio.Path(file).read_bytes()

return file


def deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]]) -> _T:
"""Copy only the containers along the given paths.

Used to guard against mutation by extract_files without copying the entire structure.
Only dicts and lists that lie on a path are copied; everything else
is returned by reference.

For example, given paths=[["foo", "files", "file"]] and the structure:
{
"foo": {
"bar": {"baz": {}},
"files": {"file": <content>}
}
}
The root dict, "foo", and "files" are copied (they lie on the path).
"bar" and "baz" are returned by reference (off the path).
"""
return _deepcopy_with_paths(item, paths, 0)


def _deepcopy_with_paths(item: _T, paths: Sequence[Sequence[str]], index: int) -> _T:
if not paths:
return item
if is_mapping(item):
key_to_paths: dict[str, list[Sequence[str]]] = {}
for path in paths:
if index < len(path):
key_to_paths.setdefault(path[index], []).append(path)

# if no path continues through this mapping, it won't be mutated and copying it is redundant
if not key_to_paths:
return item

result = dict(item)
for key, subpaths in key_to_paths.items():
if key in result:
result[key] = _deepcopy_with_paths(result[key], subpaths, index + 1)
return cast(_T, result)
if is_list(item):
array_paths = [path for path in paths if index < len(path) and path[index] == "<array>"]

# if no path expects a list here, nothing will be mutated inside it - return by reference
if not array_paths:
return cast(_T, item)
return cast(_T, [_deepcopy_with_paths(entry, array_paths, index + 1) for entry in item])
return item
1 change: 0 additions & 1 deletion src/neptune_api_v2/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
coerce_integer as coerce_integer,
file_from_path as file_from_path,
strip_not_given as strip_not_given,
deepcopy_minimal as deepcopy_minimal,
get_async_library as get_async_library,
maybe_coerce_float as maybe_coerce_float,
get_required_header as get_required_header,
Expand Down
15 changes: 0 additions & 15 deletions src/neptune_api_v2/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,6 @@ def is_iterable(obj: object) -> TypeGuard[Iterable[object]]:
return isinstance(obj, Iterable)


def deepcopy_minimal(item: _T) -> _T:
"""Minimal reimplementation of copy.deepcopy() that will only copy certain object types:

- mappings, e.g. `dict`
- list

This is done for performance reasons.
"""
if is_mapping(item):
return cast(_T, {k: deepcopy_minimal(v) for k, v in item.items()})
if is_list(item):
return cast(_T, [deepcopy_minimal(entry) for entry in item])
return item


# copied from https://github.com/Rapptz/RoboDanny
def human_join(seq: Sequence[str], *, delim: str = ", ", final: str = "or") -> str:
size = len(seq)
Expand Down
2 changes: 1 addition & 1 deletion src/neptune_api_v2/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "neptune_api_v2"
__version__ = "0.6.0" # x-release-please-version
__version__ = "0.6.1" # x-release-please-version
90 changes: 90 additions & 0 deletions src/neptune_api_v2/resources/markets/markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ...types import (
market_get_merged_params,
market_get_params_params,
market_get_supply_params,
market_get_overview_params,
market_get_merged_by_asset_params,
)
Expand All @@ -39,6 +40,7 @@
from ..._base_client import make_request_options
from ...types.market_get_merged_response import MarketGetMergedResponse
from ...types.market_get_params_response import MarketGetParamsResponse
from ...types.market_get_supply_response import MarketGetSupplyResponse
from ...types.market_get_overview_response import MarketGetOverviewResponse
from ...types.market_get_merged_by_asset_response import MarketGetMergedByAssetResponse

Expand Down Expand Up @@ -252,6 +254,43 @@ def get_params(
cast_to=MarketGetParamsResponse,
)

def get_supply(
self,
*,
with_text: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> MarketGetSupplyResponse:
"""
Get market supply

Args:
with_text: Include text variation fields

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
return self._get(
"/api/v1/markets/supply",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"with_text": with_text}, market_get_supply_params.MarketGetSupplyParams),
),
cast_to=MarketGetSupplyResponse,
)


class AsyncMarketsResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -462,6 +501,45 @@ async def get_params(
cast_to=MarketGetParamsResponse,
)

async def get_supply(
self,
*,
with_text: bool | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> MarketGetSupplyResponse:
"""
Get market supply

Args:
with_text: Include text variation fields

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
return await self._get(
"/api/v1/markets/supply",
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{"with_text": with_text}, market_get_supply_params.MarketGetSupplyParams
),
),
cast_to=MarketGetSupplyResponse,
)


class MarketsResourceWithRawResponse:
def __init__(self, markets: MarketsResource) -> None:
Expand All @@ -479,6 +557,9 @@ def __init__(self, markets: MarketsResource) -> None:
self.get_params = to_raw_response_wrapper(
markets.get_params,
)
self.get_supply = to_raw_response_wrapper(
markets.get_supply,
)

@cached_property
def lend(self) -> LendResourceWithRawResponse:
Expand All @@ -505,6 +586,9 @@ def __init__(self, markets: AsyncMarketsResource) -> None:
self.get_params = async_to_raw_response_wrapper(
markets.get_params,
)
self.get_supply = async_to_raw_response_wrapper(
markets.get_supply,
)

@cached_property
def lend(self) -> AsyncLendResourceWithRawResponse:
Expand All @@ -531,6 +615,9 @@ def __init__(self, markets: MarketsResource) -> None:
self.get_params = to_streamed_response_wrapper(
markets.get_params,
)
self.get_supply = to_streamed_response_wrapper(
markets.get_supply,
)

@cached_property
def lend(self) -> LendResourceWithStreamingResponse:
Expand All @@ -557,6 +644,9 @@ def __init__(self, markets: AsyncMarketsResource) -> None:
self.get_params = async_to_streamed_response_wrapper(
markets.get_params,
)
self.get_supply = async_to_streamed_response_wrapper(
markets.get_supply,
)

@cached_property
def lend(self) -> AsyncLendResourceWithStreamingResponse:
Expand Down
3 changes: 3 additions & 0 deletions src/neptune_api_v2/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .asset_metadata import AssetMetadata as AssetMetadata
from .staking_pool_full import StakingPoolFull as StakingPoolFull
from .asset_rate_history import AssetRateHistory as AssetRateHistory
from .market_supply_pool import MarketSupplyPool as MarketSupplyPool
from .staking_pool_state import StakingPoolState as StakingPoolState
from .asset_list_response import AssetListResponse as AssetListResponse
from .asset_price_history import AssetPriceHistory as AssetPriceHistory
Expand All @@ -35,11 +36,13 @@
from .asset_list_prices_params import AssetListPricesParams as AssetListPricesParams
from .market_get_merged_params import MarketGetMergedParams as MarketGetMergedParams
from .market_get_params_params import MarketGetParamsParams as MarketGetParamsParams
from .market_get_supply_params import MarketGetSupplyParams as MarketGetSupplyParams
from .nept_get_params_response import NeptGetParamsResponse as NeptGetParamsResponse
from .asset_list_prices_response import AssetListPricesResponse as AssetListPricesResponse
from .market_get_merged_response import MarketGetMergedResponse as MarketGetMergedResponse
from .market_get_overview_params import MarketGetOverviewParams as MarketGetOverviewParams
from .market_get_params_response import MarketGetParamsResponse as MarketGetParamsResponse
from .market_get_supply_response import MarketGetSupplyResponse as MarketGetSupplyResponse
from .user_get_tx_history_params import UserGetTxHistoryParams as UserGetTxHistoryParams
from .market_get_overview_response import MarketGetOverviewResponse as MarketGetOverviewResponse
from .status_check_health_response import StatusCheckHealthResponse as StatusCheckHealthResponse
Expand Down
Loading
Loading