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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.5.0"
".": "1.6.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 21
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-d9763d006969b49a1473851069fdfa429eb13133b64103a62963bb70ddb22305.yml
openapi_spec_hash: 6aee689b7a759b12c85c088c15e29bc0
config_hash: 4ab3e1ee76a463e0ed214541260ee12e
config_hash: 5509bb7a961ae2e79114b24c381606d4
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.6.0 (2026-02-23)

Full Changelog: [v1.5.0...v1.6.0](https://github.com/CASParser/cas-parser-python/compare/v1.5.0...v1.6.0)

### Features

* **api:** manual updates ([6551087](https://github.com/CASParser/cas-parser-python/commit/6551087fbe4480228ebfd967674eddf89c006684))

## 1.5.0 (2026-02-23)

Full Changelog: [v1.4.1...v1.5.0](https://github.com/CASParser/cas-parser-python/compare/v1.4.1...v1.5.0)
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use the Cas Parser MCP Server to enable AI assistants to interact with this API,

## Documentation

The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). The full API of this library can be found in [api.md](api.md).
The REST API documentation can be found on [casparser.in](https://casparser.in/docs). The full API of this library can be found in [api.md](api.md).

## Installation

Expand All @@ -39,8 +39,6 @@ from cas_parser import CasParser

client = CasParser(
api_key=os.environ.get("CAS_PARSER_API_KEY"), # This is the default and can be omitted
# or 'production' | 'environment_2'; defaults to "production".
environment="environment_1",
)

response = client.credits.check()
Expand All @@ -63,8 +61,6 @@ from cas_parser import AsyncCasParser

client = AsyncCasParser(
api_key=os.environ.get("CAS_PARSER_API_KEY"), # This is the default and can be omitted
# or 'production' | 'environment_2'; defaults to "production".
environment="environment_1",
)


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 = "cas-parser-python"
version = "1.5.0"
version = "1.6.0"
description = "The official Python library for the cas-parser API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 0 additions & 2 deletions src/cas_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
from ._utils import file_from_path
from ._client import (
ENVIRONMENTS,
Client,
Stream,
Timeout,
Expand Down Expand Up @@ -74,7 +73,6 @@
"AsyncStream",
"CasParser",
"AsyncCasParser",
"ENVIRONMENTS",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
Expand Down
83 changes: 12 additions & 71 deletions src/cas_parser/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import annotations

import os
from typing import TYPE_CHECKING, Any, Dict, Mapping, cast
from typing_extensions import Self, Literal, override
from typing import TYPE_CHECKING, Any, Mapping
from typing_extensions import Self, override

import httpx

Expand Down Expand Up @@ -59,7 +59,6 @@
from .resources.inbound_email import InboundEmailResource, AsyncInboundEmailResource

__all__ = [
"ENVIRONMENTS",
"Timeout",
"Transport",
"ProxiesTypes",
Expand All @@ -70,25 +69,16 @@
"AsyncClient",
]

ENVIRONMENTS: Dict[str, str] = {
"production": "https://portfolio-parser.api.casparser.in",
"environment_1": "https://client-apis.casparser.in",
"environment_2": "http://localhost:5000",
}


class CasParser(SyncAPIClient):
# client options
api_key: str

_environment: Literal["production", "environment_1", "environment_2"] | NotGiven

def __init__(
self,
*,
api_key: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | NotGiven = not_given,
base_url: str | httpx.URL | None | NotGiven = not_given,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
Expand Down Expand Up @@ -119,31 +109,10 @@ def __init__(
)
self.api_key = api_key

self._environment = environment

base_url_env = os.environ.get("CAS_PARSER_BASE_URL")
if is_given(base_url) and base_url is not None:
# cast required because mypy doesn't understand the type narrowing
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
elif is_given(environment):
if base_url_env and base_url is not None:
raise ValueError(
"Ambiguous URL; The `CAS_PARSER_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
)

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
if base_url is None:
base_url = os.environ.get("CAS_PARSER_BASE_URL")
if base_url is None:
base_url = f"https://api.casparser.in"

super().__init__(
version=__version__,
Expand Down Expand Up @@ -260,7 +229,6 @@ def copy(
self,
*,
api_key: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.Client | None = None,
Expand Down Expand Up @@ -296,7 +264,6 @@ def copy(
return self.__class__(
api_key=api_key or self.api_key,
base_url=base_url or self.base_url,
environment=environment or self._environment,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
Expand Down Expand Up @@ -347,14 +314,11 @@ class AsyncCasParser(AsyncAPIClient):
# client options
api_key: str

_environment: Literal["production", "environment_1", "environment_2"] | NotGiven

def __init__(
self,
*,
api_key: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | NotGiven = not_given,
base_url: str | httpx.URL | None | NotGiven = not_given,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
default_headers: Mapping[str, str] | None = None,
Expand Down Expand Up @@ -385,31 +349,10 @@ def __init__(
)
self.api_key = api_key

self._environment = environment

base_url_env = os.environ.get("CAS_PARSER_BASE_URL")
if is_given(base_url) and base_url is not None:
# cast required because mypy doesn't understand the type narrowing
base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
elif is_given(environment):
if base_url_env and base_url is not None:
raise ValueError(
"Ambiguous URL; The `CAS_PARSER_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
)

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
elif base_url_env is not None:
base_url = base_url_env
else:
self._environment = environment = "production"

try:
base_url = ENVIRONMENTS[environment]
except KeyError as exc:
raise ValueError(f"Unknown environment: {environment}") from exc
if base_url is None:
base_url = os.environ.get("CAS_PARSER_BASE_URL")
if base_url is None:
base_url = f"https://api.casparser.in"

super().__init__(
version=__version__,
Expand Down Expand Up @@ -526,7 +469,6 @@ def copy(
self,
*,
api_key: str | None = None,
environment: Literal["production", "environment_1", "environment_2"] | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
http_client: httpx.AsyncClient | None = None,
Expand Down Expand Up @@ -562,7 +504,6 @@ def copy(
return self.__class__(
api_key=api_key or self.api_key,
base_url=base_url or self.base_url,
environment=environment or self._environment,
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
http_client=http_client,
max_retries=max_retries if is_given(max_retries) else self.max_retries,
Expand Down
2 changes: 1 addition & 1 deletion src/cas_parser/_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__ = "cas_parser"
__version__ = "1.5.0" # x-release-please-version
__version__ = "1.6.0" # x-release-please-version
24 changes: 0 additions & 24 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,18 +691,6 @@ def test_base_url_env(self) -> None:
client = CasParser(api_key=api_key, _strict_response_validation=True)
assert client.base_url == "http://localhost:5000/from/env/"

# explicit environment arg requires explicitness
with update_env(CAS_PARSER_BASE_URL="http://localhost:5000/from/env"):
with pytest.raises(ValueError, match=r"you must pass base_url=None"):
CasParser(api_key=api_key, _strict_response_validation=True, environment="production")

client = CasParser(
base_url=None, api_key=api_key, _strict_response_validation=True, environment="production"
)
assert str(client.base_url).startswith("https://portfolio-parser.api.casparser.in")

client.close()

@pytest.mark.parametrize(
"client",
[
Expand Down Expand Up @@ -1592,18 +1580,6 @@ async def test_base_url_env(self) -> None:
client = AsyncCasParser(api_key=api_key, _strict_response_validation=True)
assert client.base_url == "http://localhost:5000/from/env/"

# explicit environment arg requires explicitness
with update_env(CAS_PARSER_BASE_URL="http://localhost:5000/from/env"):
with pytest.raises(ValueError, match=r"you must pass base_url=None"):
AsyncCasParser(api_key=api_key, _strict_response_validation=True, environment="production")

client = AsyncCasParser(
base_url=None, api_key=api_key, _strict_response_validation=True, environment="production"
)
assert str(client.base_url).startswith("https://portfolio-parser.api.casparser.in")

await client.close()

@pytest.mark.parametrize(
"client",
[
Expand Down