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
31 changes: 31 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to PyPI in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/CASParser/cas-parser-python/actions/workflows/publish-pypi.yml
name: Publish PyPI
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Publish to PyPI
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.CAS_PARSER_PYPI_TOKEN || secrets.PYPI_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release Doctor
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'CASParser/cas-parser-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.CAS_PARSER_PYPI_TOKEN || secrets.PYPI_TOKEN }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.0.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: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-b7fdba3d3f97c7debc22c7ca30b828bce81bcd64648df8c94029b27a3321ebb9.yml
openapi_spec_hash: 03f1315f1d32ada42445ca920f047dff
config_hash: 2632d49bed76591e5ca0ddf94f518f17
config_hash: a09a453fc58f48d89b5b8fce49bfb354
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

## 1.0.0 (2025-08-18)

Full Changelog: [v0.0.1...v1.0.0](https://github.com/CASParser/cas-parser-python/compare/v0.0.1...v1.0.0)

### Features

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


### Chores

* configure new SDK language ([5748dab](https://github.com/CASParser/cas-parser-python/commit/5748dab8b8241dc537456d9b8c1dae3c0e4a5d5a))
* update SDK settings ([13b5c47](https://github.com/CASParser/cas-parser-python/commit/13b5c470a31ac72d95078236e0e16b76e753939e))
* update SDK settings ([25126eb](https://github.com/CASParser/cas-parser-python/commit/25126eb2330f0e84bd4dd9e814e6a2e5b2ebbddc))
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```sh
$ pip install git+ssh://git@github.com/stainless-sdks/cas-parser-python.git
$ pip install git+ssh://git@github.com/CASParser/cas-parser-python.git
```

Alternatively, you can build from source and install the wheel file:
Expand Down Expand Up @@ -120,7 +120,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/stainless-sdks/cas-parser-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.
You can release to package managers by using [the `Publish PyPI` GitHub action](https://www.github.com/CASParser/cas-parser-python/actions/workflows/publish-pypi.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
63 changes: 40 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ The REST API documentation can be found on [docs.casparser.in](https://docs.casp
## Installation

```sh
# install from this staging repo
pip install git+ssh://git@github.com/stainless-sdks/cas-parser-python.git
# install from PyPI
pip install cas_parser
```

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

## Usage

The full API of this library can be found in [api.md](api.md).
Expand All @@ -33,11 +30,12 @@ from cas_parser import CasParser

client = CasParser(
api_key=os.environ.get("CAS_PARSER_API_KEY"), # This is the default and can be omitted
# defaults to "production".
environment="local",
)

unified_response = client.cas_parser.cams_kfintech()
unified_response = client.cas_parser.smart_parse(
password="ABCDF",
pdf_url="https://your-cas-pdf-url-here.com",
)
print(unified_response.demat_accounts)
```

Expand All @@ -57,13 +55,14 @@ from cas_parser import AsyncCasParser

client = AsyncCasParser(
api_key=os.environ.get("CAS_PARSER_API_KEY"), # This is the default and can be omitted
# defaults to "production".
environment="local",
)


async def main() -> None:
unified_response = await client.cas_parser.cams_kfintech()
unified_response = await client.cas_parser.smart_parse(
password="ABCDF",
pdf_url="https://your-cas-pdf-url-here.com",
)
print(unified_response.demat_accounts)


Expand All @@ -79,8 +78,8 @@ By default, the async client uses `httpx` for HTTP requests. However, for improv
You can enable this by installing `aiohttp`:

```sh
# install from this staging repo
pip install 'cas_parser[aiohttp] @ git+ssh://git@github.com/stainless-sdks/cas-parser-python.git'
# install from PyPI
pip install cas_parser[aiohttp]
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
Expand All @@ -96,7 +95,10 @@ async def main() -> None:
api_key="My API Key",
http_client=DefaultAioHttpClient(),
) as client:
unified_response = await client.cas_parser.cams_kfintech()
unified_response = await client.cas_parser.smart_parse(
password="ABCDF",
pdf_url="https://your-cas-pdf-url-here.com",
)
print(unified_response.demat_accounts)


Expand Down Expand Up @@ -128,7 +130,10 @@ from cas_parser import CasParser
client = CasParser()

try:
client.cas_parser.cams_kfintech()
client.cas_parser.smart_parse(
password="ABCDF",
pdf_url="https://you-cas-pdf-url-here.com",
)
except cas_parser.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
Expand Down Expand Up @@ -171,7 +176,10 @@ client = CasParser(
)

# Or, configure per-request:
client.with_options(max_retries=5).cas_parser.cams_kfintech()
client.with_options(max_retries=5).cas_parser.smart_parse(
password="ABCDF",
pdf_url="https://you-cas-pdf-url-here.com",
)
```

### Timeouts
Expand All @@ -194,7 +202,10 @@ client = CasParser(
)

# Override per-request:
client.with_options(timeout=5.0).cas_parser.cams_kfintech()
client.with_options(timeout=5.0).cas_parser.smart_parse(
password="ABCDF",
pdf_url="https://you-cas-pdf-url-here.com",
)
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -235,16 +246,19 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
from cas_parser import CasParser

client = CasParser()
response = client.cas_parser.with_raw_response.cams_kfintech()
response = client.cas_parser.with_raw_response.smart_parse(
password="ABCDF",
pdf_url="https://you-cas-pdf-url-here.com",
)
print(response.headers.get('X-My-Header'))

cas_parser = response.parse() # get the object that `cas_parser.cams_kfintech()` would have returned
cas_parser = response.parse() # get the object that `cas_parser.smart_parse()` would have returned
print(cas_parser.demat_accounts)
```

These methods return an [`APIResponse`](https://github.com/stainless-sdks/cas-parser-python/tree/main/src/cas_parser/_response.py) object.
These methods return an [`APIResponse`](https://github.com/CASParser/cas-parser-python/tree/main/src/cas_parser/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/stainless-sdks/cas-parser-python/tree/main/src/cas_parser/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/CASParser/cas-parser-python/tree/main/src/cas_parser/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand All @@ -253,7 +267,10 @@ 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.cas_parser.with_streaming_response.cams_kfintech() as response:
with client.cas_parser.with_streaming_response.smart_parse(
password="ABCDF",
pdf_url="https://you-cas-pdf-url-here.com",
) as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
Expand Down Expand Up @@ -348,7 +365,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/cas-parser-python/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/CASParser/cas-parser-python/issues) with questions, bugs, or suggestions.

### Determining the installed version

Expand Down
21 changes: 21 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

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
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "cas_parser"
version = "0.0.1"
version = "1.0.0"
description = "The official Python library for the CAS Parser API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -35,8 +35,8 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/stainless-sdks/cas-parser-python"
Repository = "https://github.com/stainless-sdks/cas-parser-python"
Homepage = "https://github.com/CASParser/cas-parser-python"
Repository = "https://github.com/CASParser/cas-parser-python"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.8"]
Expand Down Expand Up @@ -125,7 +125,7 @@ path = "README.md"
[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
# replace relative links with absolute links
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
replacement = '[\1](https://github.com/stainless-sdks/cas-parser-python/tree/main/\g<2>)'
replacement = '[\1](https://github.com/CASParser/cas-parser-python/tree/main/\g<2>)'

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
66 changes: 66 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"packages": {
".": {}
},
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
"include-v-in-tag": true,
"include-component-in-tag": false,
"versioning": "prerelease",
"prerelease": true,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"pull-request-header": "Automated Release PR",
"pull-request-title-pattern": "release: ${version}",
"changelog-sections": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "chore",
"section": "Chores"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"section": "Styles"
},
{
"type": "refactor",
"section": "Refactors"
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
],
"release-type": "python",
"extra-files": [
"src/cas_parser/_version.py"
]
}
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
from ._utils import file_from_path
from ._client import (
ENVIRONMENTS,
Client,
Stream,
Timeout,
Expand Down Expand Up @@ -72,7 +71,6 @@
"AsyncStream",
"CasParser",
"AsyncCasParser",
"ENVIRONMENTS",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
Expand Down
Loading
Loading