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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.prism.log
.vscode
_dev

__pycache__
Expand Down
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.7.0"
".": "0.8.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: 27
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-c74e7376ab152155b24a3f8f21fa43709cbc94b6e8b33a6ed48a23a62f976d1a.yml
openapi_spec_hash: f430c7e1c4f367245df8145df75fb443
config_hash: e88d2c04584e96ef1e76c72156c3c186
configured_endpoints: 33
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nen-labs%2Fsteel-44f289567c281ce445273c28f44fe7ccd44979172c4933bfbfe63bb5f119640c.yml
openapi_spec_hash: 449cf480b2d477ef67ff32992734fb8c
config_hash: 3dda15a7a3da8ba8e97a8ec239cbcb80
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.analysis.importFormat": "relative",
}
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 0.8.0 (2025-08-21)

Full Changelog: [v0.7.0...v0.8.0](https://github.com/steel-dev/steel-python/compare/v0.7.0...v0.8.0)

### Features

* **api:** api update ([49f5992](https://github.com/steel-dev/steel-python/commit/49f59927bd2ba1e9a6e6a1cbef93dd84cbc6eef7))
* **api:** api update ([2055ec7](https://github.com/steel-dev/steel-python/commit/2055ec74b1351d0cd32c2f0b090aea60472bb083))
* **api:** api update ([17e78ce](https://github.com/steel-dev/steel-python/commit/17e78ced5dcc03291fc901db0a709f9163f088e4))
* **api:** api update ([ac8847c](https://github.com/steel-dev/steel-python/commit/ac8847c5159a11f64e07b3dbe6e9734195324dbb))
* **client:** support file upload requests ([f39ab33](https://github.com/steel-dev/steel-python/commit/f39ab33ad139f97dbded281ae95816c46b8067f1))


### Bug Fixes

* **parsing:** ignore empty metadata ([49e1aa7](https://github.com/steel-dev/steel-python/commit/49e1aa7d8c13615fea92180a934a7611f90f2453))
* **parsing:** parse extra field types ([2e73fc7](https://github.com/steel-dev/steel-python/commit/2e73fc78a36fa3045cfd38d7cc3abdc7d9547c8b))


### Chores

* **internal:** fix ruff target version ([b686aa3](https://github.com/steel-dev/steel-python/commit/b686aa3294ca45632e573a9bc567341544f3c4e8))
* **internal:** update comment in script ([fdaf7d9](https://github.com/steel-dev/steel-python/commit/fdaf7d9f40f5b3aaceb39e2017b2ac4677644498))
* **project:** add settings file for vscode ([077b238](https://github.com/steel-dev/steel-python/commit/077b2387b888f5ba82e209ea307e6dd633c39e3c))
* update @stainless-api/prism-cli to v5.15.0 ([b6cb1cd](https://github.com/steel-dev/steel-python/commit/b6cb1cdf5282c29c021a2b7a3b139e613686e8e8))

## 0.7.0 (2025-07-12)

Full Changelog: [v0.6.0...v0.7.0](https://github.com/steel-dev/steel-python/compare/v0.6.0...v0.7.0)
Expand Down
24 changes: 24 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,27 @@ Methods:

- <code title="post /v1/sessions/{sessionId}/captchas/solve-image">client.sessions.captchas.<a href="./src/steel/resources/sessions/captchas.py">solve_image</a>(session_id, \*\*<a href="src/steel/types/sessions/captcha_solve_image_params.py">params</a>) -> <a href="./src/steel/types/sessions/captcha_solve_image_response.py">CaptchaSolveImageResponse</a></code>
- <code title="get /v1/sessions/{sessionId}/captchas/status">client.sessions.captchas.<a href="./src/steel/resources/sessions/captchas.py">status</a>(session_id) -> <a href="./src/steel/types/sessions/captcha_status_response.py">CaptchaStatusResponse</a></code>

# Extensions

Types:

```python
from steel.types import (
ExtensionUpdateResponse,
ExtensionListResponse,
ExtensionDeleteResponse,
ExtensionDeleteAllResponse,
ExtensionDownloadResponse,
ExtensionUploadResponse,
)
```

Methods:

- <code title="put /v1/extensions/{extensionId}">client.extensions.<a href="./src/steel/resources/extensions.py">update</a>(extension_id) -> <a href="./src/steel/types/extension_update_response.py">ExtensionUpdateResponse</a></code>
- <code title="get /v1/extensions">client.extensions.<a href="./src/steel/resources/extensions.py">list</a>() -> <a href="./src/steel/types/extension_list_response.py">ExtensionListResponse</a></code>
- <code title="delete /v1/extensions/{extensionId}">client.extensions.<a href="./src/steel/resources/extensions.py">delete</a>(extension_id) -> <a href="./src/steel/types/extension_delete_response.py">ExtensionDeleteResponse</a></code>
- <code title="delete /v1/extensions">client.extensions.<a href="./src/steel/resources/extensions.py">delete_all</a>() -> <a href="./src/steel/types/extension_delete_all_response.py">ExtensionDeleteAllResponse</a></code>
- <code title="get /v1/extensions/{extensionId}">client.extensions.<a href="./src/steel/resources/extensions.py">download</a>(extension_id) -> str</code>
- <code title="post /v1/extensions">client.extensions.<a href="./src/steel/resources/extensions.py">upload</a>() -> <a href="./src/steel/types/extension_upload_response.py">ExtensionUploadResponse</a></code>
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "steel-sdk"
version = "0.7.0"
version = "0.8.0"
description = "The official Python library for the steel API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -159,7 +159,7 @@ reportPrivateUsage = false
[tool.ruff]
line-length = 120
output-format = "grouped"
target-version = "py37"
target-version = "py38"

[tool.ruff.format]
docstring-code-format = true
Expand Down
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
fi
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elif ! prism_is_running ; then
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
Expand Down
5 changes: 4 additions & 1 deletion src/steel/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ def _build_request(
is_body_allowed = options.method.lower() != "get"

if is_body_allowed:
kwargs["json"] = json_data if is_given(json_data) else None
if isinstance(json_data, bytes):
kwargs["content"] = json_data
else:
kwargs["json"] = json_data if is_given(json_data) else None
kwargs["files"] = files
else:
headers.pop("Content-Type", None)
Expand Down
34 changes: 33 additions & 1 deletion src/steel/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from .resources import files, credentials
from .resources import files, extensions, credentials
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError
from ._base_client import (
Expand All @@ -57,6 +57,7 @@ class Steel(SyncAPIClient):
credentials: credentials.CredentialsResource
files: files.FilesResource
sessions: sessions.SessionsResource
extensions: extensions.ExtensionsResource
with_raw_response: SteelWithRawResponse
with_streaming_response: SteelWithStreamedResponse

Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(
self.credentials = credentials.CredentialsResource(self)
self.files = files.FilesResource(self)
self.sessions = sessions.SessionsResource(self)
self.extensions = extensions.ExtensionsResource(self)
self.with_raw_response = SteelWithRawResponse(self)
self.with_streaming_response = SteelWithStreamedResponse(self)

Expand Down Expand Up @@ -194,6 +196,7 @@ def pdf(
*,
url: str,
delay: float | NotGiven = NOT_GIVEN,
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
use_proxy: bool | NotGiven = NOT_GIVEN,
# 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.
Expand All @@ -210,6 +213,8 @@ def pdf(

delay: Delay before generating the PDF (in milliseconds)

region: The desired region for the action to be performed in

use_proxy: Use a Steel-provided residential proxy for generating the PDF

extra_headers: Send extra headers
Expand All @@ -226,6 +231,7 @@ def pdf(
{
"url": url,
"delay": delay,
"region": region,
"use_proxy": use_proxy,
},
client_pdf_params.ClientPdfParams,
Expand All @@ -243,6 +249,7 @@ def scrape(
delay: float | NotGiven = NOT_GIVEN,
format: List[Literal["html", "readability", "cleaned_html", "markdown"]] | NotGiven = NOT_GIVEN,
pdf: bool | NotGiven = NOT_GIVEN,
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
screenshot: bool | NotGiven = NOT_GIVEN,
use_proxy: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -264,6 +271,8 @@ def scrape(

pdf: Include a PDF in the response

region: The desired region for the action to be performed in

screenshot: Include a screenshot in the response

use_proxy: Use a Steel-provided residential proxy for the scrape
Expand All @@ -284,6 +293,7 @@ def scrape(
"delay": delay,
"format": format,
"pdf": pdf,
"region": region,
"screenshot": screenshot,
"use_proxy": use_proxy,
},
Expand All @@ -301,6 +311,7 @@ def screenshot(
url: str,
delay: float | NotGiven = NOT_GIVEN,
full_page: bool | NotGiven = NOT_GIVEN,
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
use_proxy: bool | NotGiven = NOT_GIVEN,
# 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.
Expand All @@ -319,6 +330,8 @@ def screenshot(

full_page: Capture the full page screenshot. Default is `false`.

region: The desired region for the action to be performed in

use_proxy: Use a Steel-provided residential proxy for capturing the screenshot

extra_headers: Send extra headers
Expand All @@ -336,6 +349,7 @@ def screenshot(
"url": url,
"delay": delay,
"full_page": full_page,
"region": region,
"use_proxy": use_proxy,
},
client_screenshot_params.ClientScreenshotParams,
Expand Down Expand Up @@ -384,6 +398,7 @@ class AsyncSteel(AsyncAPIClient):
credentials: credentials.AsyncCredentialsResource
files: files.AsyncFilesResource
sessions: sessions.AsyncSessionsResource
extensions: extensions.AsyncExtensionsResource
with_raw_response: AsyncSteelWithRawResponse
with_streaming_response: AsyncSteelWithStreamedResponse

Expand Down Expand Up @@ -440,6 +455,7 @@ def __init__(
self.credentials = credentials.AsyncCredentialsResource(self)
self.files = files.AsyncFilesResource(self)
self.sessions = sessions.AsyncSessionsResource(self)
self.extensions = extensions.AsyncExtensionsResource(self)
self.with_raw_response = AsyncSteelWithRawResponse(self)
self.with_streaming_response = AsyncSteelWithStreamedResponse(self)

Expand Down Expand Up @@ -521,6 +537,7 @@ async def pdf(
*,
url: str,
delay: float | NotGiven = NOT_GIVEN,
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
use_proxy: bool | NotGiven = NOT_GIVEN,
# 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.
Expand All @@ -537,6 +554,8 @@ async def pdf(

delay: Delay before generating the PDF (in milliseconds)

region: The desired region for the action to be performed in

use_proxy: Use a Steel-provided residential proxy for generating the PDF

extra_headers: Send extra headers
Expand All @@ -553,6 +572,7 @@ async def pdf(
{
"url": url,
"delay": delay,
"region": region,
"use_proxy": use_proxy,
},
client_pdf_params.ClientPdfParams,
Expand All @@ -570,6 +590,7 @@ async def scrape(
delay: float | NotGiven = NOT_GIVEN,
format: List[Literal["html", "readability", "cleaned_html", "markdown"]] | NotGiven = NOT_GIVEN,
pdf: bool | NotGiven = NOT_GIVEN,
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
screenshot: bool | NotGiven = NOT_GIVEN,
use_proxy: bool | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
Expand All @@ -591,6 +612,8 @@ async def scrape(

pdf: Include a PDF in the response

region: The desired region for the action to be performed in

screenshot: Include a screenshot in the response

use_proxy: Use a Steel-provided residential proxy for the scrape
Expand All @@ -611,6 +634,7 @@ async def scrape(
"delay": delay,
"format": format,
"pdf": pdf,
"region": region,
"screenshot": screenshot,
"use_proxy": use_proxy,
},
Expand All @@ -628,6 +652,7 @@ async def screenshot(
url: str,
delay: float | NotGiven = NOT_GIVEN,
full_page: bool | NotGiven = NOT_GIVEN,
region: Literal["lax", "ord", "iad", "bom", "scl", "fra", "hkg"] | NotGiven = NOT_GIVEN,
use_proxy: bool | NotGiven = NOT_GIVEN,
# 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.
Expand All @@ -646,6 +671,8 @@ async def screenshot(

full_page: Capture the full page screenshot. Default is `false`.

region: The desired region for the action to be performed in

use_proxy: Use a Steel-provided residential proxy for capturing the screenshot

extra_headers: Send extra headers
Expand All @@ -663,6 +690,7 @@ async def screenshot(
"url": url,
"delay": delay,
"full_page": full_page,
"region": region,
"use_proxy": use_proxy,
},
client_screenshot_params.ClientScreenshotParams,
Expand Down Expand Up @@ -712,6 +740,7 @@ def __init__(self, client: Steel) -> None:
self.credentials = credentials.CredentialsResourceWithRawResponse(client.credentials)
self.files = files.FilesResourceWithRawResponse(client.files)
self.sessions = sessions.SessionsResourceWithRawResponse(client.sessions)
self.extensions = extensions.ExtensionsResourceWithRawResponse(client.extensions)

self.pdf = to_raw_response_wrapper(
client.pdf,
Expand All @@ -729,6 +758,7 @@ def __init__(self, client: AsyncSteel) -> None:
self.credentials = credentials.AsyncCredentialsResourceWithRawResponse(client.credentials)
self.files = files.AsyncFilesResourceWithRawResponse(client.files)
self.sessions = sessions.AsyncSessionsResourceWithRawResponse(client.sessions)
self.extensions = extensions.AsyncExtensionsResourceWithRawResponse(client.extensions)

self.pdf = async_to_raw_response_wrapper(
client.pdf,
Expand All @@ -746,6 +776,7 @@ def __init__(self, client: Steel) -> None:
self.credentials = credentials.CredentialsResourceWithStreamingResponse(client.credentials)
self.files = files.FilesResourceWithStreamingResponse(client.files)
self.sessions = sessions.SessionsResourceWithStreamingResponse(client.sessions)
self.extensions = extensions.ExtensionsResourceWithStreamingResponse(client.extensions)

self.pdf = to_streamed_response_wrapper(
client.pdf,
Expand All @@ -763,6 +794,7 @@ def __init__(self, client: AsyncSteel) -> None:
self.credentials = credentials.AsyncCredentialsResourceWithStreamingResponse(client.credentials)
self.files = files.AsyncFilesResourceWithStreamingResponse(client.files)
self.sessions = sessions.AsyncSessionsResourceWithStreamingResponse(client.sessions)
self.extensions = extensions.AsyncExtensionsResourceWithStreamingResponse(client.extensions)

self.pdf = async_to_streamed_response_wrapper(
client.pdf,
Expand Down
8 changes: 4 additions & 4 deletions src/steel/_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes:
return file

if is_tuple_t(file):
return (file[0], _read_file_content(file[1]), *file[2:])
return (file[0], read_file_content(file[1]), *file[2:])

raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")


def _read_file_content(file: FileContent) -> HttpxFileContent:
def read_file_content(file: FileContent) -> HttpxFileContent:
if isinstance(file, os.PathLike):
return pathlib.Path(file).read_bytes()
return file
Expand Down Expand Up @@ -111,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes:
return file

if is_tuple_t(file):
return (file[0], await _async_read_file_content(file[1]), *file[2:])
return (file[0], await async_read_file_content(file[1]), *file[2:])

raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple")


async def _async_read_file_content(file: FileContent) -> HttpxFileContent:
async def async_read_file_content(file: FileContent) -> HttpxFileContent:
if isinstance(file, os.PathLike):
return await anyio.Path(file).read_bytes()

Expand Down
Loading