Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
00653bc
chore: update SDK settings
stainless-app[bot] Aug 12, 2025
30ebeb9
chore(internal): codegen related update
stainless-app[bot] Aug 13, 2025
1529f4f
fix(docs): re-order using statements
stainless-app[bot] Aug 13, 2025
da2adae
chore(internal): remove unnecessary internal aliasing
stainless-app[bot] Aug 17, 2025
3d59690
docs: fix installation instructions
stainless-app[bot] Aug 17, 2025
ccad199
feat(client): add switch and match helpers for unions
stainless-app[bot] Aug 20, 2025
f427733
refactor(client): refine enum representation
stainless-app[bot] Aug 20, 2025
6472558
codegen metadata
stainless-app[bot] Aug 20, 2025
3af2386
feat(client): improve signature of `trypickx` methods
stainless-app[bot] Aug 21, 2025
19debc8
feat(internal): add dedicated build job in ci
stainless-app[bot] Aug 21, 2025
cf7d535
feat(client): allow omitting all params object when all optional
stainless-app[bot] Aug 21, 2025
136affb
chore(internal): rename parameters
stainless-app[bot] Aug 21, 2025
198d17a
fix(client): better type names
stainless-app[bot] Aug 23, 2025
5d8fbc6
feat(client): shorten union variant names
stainless-app[bot] Aug 23, 2025
4625b19
fix(internal): remove unused null class
stainless-app[bot] Aug 23, 2025
fc4a269
fix(client): handle multiple auth options gracefully
stainless-app[bot] Sep 11, 2025
29c70b5
fix(internal): remove example csproj
stainless-app[bot] Sep 18, 2025
223ca7f
feat(client): refactor exceptions
stainless-app[bot] Oct 2, 2025
09e44c5
feat(internal): add dev container
stainless-app[bot] Oct 3, 2025
67d49b4
feat(client): refactor unions
stainless-app[bot] Oct 8, 2025
6488efb
release: 0.1.0
stainless-app[bot] Oct 8, 2025
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
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet
{
"name": "C# (.NET)",
"image": "mcr.microsoft.com/devcontainers/dotnet:1-9.0-noble",
"postAttachCommand": "cat .vscode/extensions.json | jq -r .recommendations[] | xargs -n 1 code --install-extension",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}"
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ insert_final_newline = true

dotnet_diagnostic.IDE0060.severity = none # Caused by resource with no methods and no subresources
dotnet_diagnostic.IDE1006.severity = none # Some names may not match up with C# conventions
dotnet_diagnostic.IDE0290.severity = none # Don't prefer primary constructors
dotnet_diagnostic.IDE0290.severity = none # Don't prefer primary constructors
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ jobs:

- name: Run lints
run: ./scripts/lint
build:
timeout-minutes: 10
name: build
runs-on: ${{ github.repository == 'stainless-sdks/scrapegraphai-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork

steps:
- uses: actions/checkout@v4

- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Build SDK
run: ./scripts/build

test:
timeout-minutes: 10
name: test
Expand Down
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/scrapegraphai%2Fscrapegraphai-969ebada41127057e4cda129b2e7206224743b5c7fd33aa8ae062ff71b775ac9.yml
openapi_spec_hash: 2b2c2c684e6f6885398efca5f2b1f854
config_hash: 30d69c79e34a1ea6a0405573ce30d927
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/scrapegraphai%2Fscrapegraphai-633fdeab6abaefbe666099e8f86ce6b2acc9dacff1c33a80813bb04e8e437229.yml
openapi_spec_hash: f41ec90694ca8e7233bd20cc7ff1afbf
config_hash: 6889576ba0fdc14f2c71cea09a60a0f6
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"recommendations": [
"ms-dotnettools.csharp",
"editorconfig.editorconfig",
"github.vscode-github-actions",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.csdevkit"
],
"unwantedRecommendations": []
}
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Changelog

## 0.1.0 (2025-10-08)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/ScrapeGraphAI/scrapegraphai-c/compare/v0.0.1...v0.1.0)

### Features

* add files ([d02f336](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/d02f3362c13702753d986b0d0c35a753e3d28136))
* **client:** add switch and match helpers for unions ([ccad199](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/ccad1993a305c58d2595477e5ecc171dd798de9d))
* **client:** allow omitting all params object when all optional ([cf7d535](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/cf7d535c8802a1328e22dbccd58bff9186029827))
* **client:** improve signature of `trypickx` methods ([3af2386](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/3af2386fb58dc706227669f721e42ef5f45c72f6))
* **client:** refactor exceptions ([223ca7f](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/223ca7f992e4c17f97aa5ab7a16ec15cb1557aa9))
* **client:** refactor unions ([67d49b4](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/67d49b454eb8aa021ccaadf2f55e82352b9e61a5))
* **client:** shorten union variant names ([5d8fbc6](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/5d8fbc62da23aadf61ee88248acb409fec9c8bad))
* **internal:** add dedicated build job in ci ([19debc8](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/19debc832713e17708c2524bb9a09c1b967b36e5))
* **internal:** add dev container ([09e44c5](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/09e44c597ff8074834cc50dc8ee291ec649f22f4))


### Bug Fixes

* **client:** better type names ([198d17a](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/198d17a1e81f613235b5de7413ebe317c0965af0))
* **client:** handle multiple auth options gracefully ([fc4a269](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/fc4a26933e1a20388a8102170fac78b3f74e2c22))
* **docs:** re-order using statements ([1529f4f](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/1529f4fa633537e3dfcf942d3898b400b074009c))
* **internal:** remove example csproj ([29c70b5](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/29c70b55ea868332d230cba9fa9978f46db01301))
* **internal:** remove unused null class ([4625b19](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/4625b19d0f56f102c6e2a7cb8e953e8f83956e37))


### Chores

* configure new SDK language ([f87e130](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/f87e1302fbf8f0911a99c6ac94b704df8952798b))
* **internal:** codegen related update ([30ebeb9](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/30ebeb9bd332cb0a60dd013238811b8b7c2e781c))
* **internal:** remove unnecessary internal aliasing ([da2adae](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/da2adaed4478e4c9dea6629e9d5f30a1c1693267))
* **internal:** rename parameters ([136affb](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/136affb4677cc727730d120abf6f9232eda5d9b8))
* update SDK settings ([00653bc](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/00653bcbabf976cabc53a46e0ad4c6045f559509))


### Documentation

* **client:** add more property comments ([f427733](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/f427733d982b19d0cc1012be19978f34ae729f6f))
* fix installation instructions ([3d59690](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/3d5969023ab80e6e87b6770f15de1c4248fe5cf1))


### Refactors

* **client:** refine enum representation ([f427733](https://github.com/ScrapeGraphAI/scrapegraphai-c/commit/f427733d982b19d0cc1012be19978f34ae729f6f))
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
>
> This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code.
>
> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/scrapegraphai-csharp/issues/new).
> **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/ScrapeGraphAI/scrapegraphai-c/issues/new).

The Scrapegraphai C# SDK provides convenient access to the [Scrapegraphai REST API](https://scrapegraphai.com) from applications written in C#.

Expand All @@ -16,7 +16,8 @@ The REST API documentation can be found on [scrapegraphai.com](https://scrapegra
## Installation

```bash
dotnet add package Scrapegraphai
git clone [email protected]:ScrapeGraphAI/scrapegraphai-c.git
dotnet add reference scrapegraphai-c/src/Scrapegraphai
```

## Requirements
Expand All @@ -31,9 +32,9 @@ This library requires .NET 8 or later.
See the [`examples`](examples) directory for complete and runnable examples.

```csharp
using System;
using Scrapegraphai;
using Scrapegraphai.Models.Smartscraper;
using System;

// Configured using the SCRAPEGRAPHAI_API_KEY and SCRAPEGRAPHAI_BASE_URL environment variables
ScrapegraphaiClient client = new();
Expand Down Expand Up @@ -82,6 +83,33 @@ To send a request to the Scrapegraphai API, build an instance of some `Params` c

For example, `client.Smartscraper.Create` should be called with an instance of `SmartscraperCreateParams`, and it will return an instance of `Task<CompletedSmartscraper>`.

## Error handling

The SDK throws custom unchecked exception types:

- `ScrapegraphaiApiException`: Base class for API errors. See this table for which exception subclass is thrown for each HTTP status code:

| Status | Exception |
| ------ | -------------------------------------------- |
| 400 | `ScrapegraphaiBadRequestException` |
| 401 | `ScrapegraphaiUnauthorizedException` |
| 403 | `ScrapegraphaiForbiddenException` |
| 404 | `ScrapegraphaiNotFoundException` |
| 422 | `ScrapegraphaiUnprocessableEntityException` |
| 429 | `ScrapegraphaiRateLimitException` |
| 5xx | `Scrapegraphai5xxException` |
| others | `ScrapegraphaiUnexpectedStatusCodeException` |

Additionally, all 4xx errors inherit from `Scrapegraphai4xxException`.

false

- `ScrapegraphaiIOException`: I/O networking errors.

- `ScrapegraphaiInvalidDataException`: Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response.

- `ScrapegraphaiException`: Base class for all exceptions.

## Semantic versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
Expand All @@ -91,4 +119,4 @@ 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/scrapegraphai-csharp/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/ScrapeGraphAI/scrapegraphai-c/issues) with questions, bugs, or suggestions.
Empty file added examples/.keep
Empty file.
71 changes: 71 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"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": "simple",
"extra-files": [
"README.md",
{
"type": "xml",
"path": "src/Scrapegraphai/Scrapegraphai.csproj",
"xpath": "//Project/PropertyGroup/VersionPrefix"
}
]
}
2 changes: 2 additions & 0 deletions src/Scrapegraphai.Tests/Scrapegraphai.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<ImplicitUsings>disable</ImplicitUsings>
<!-- Disable skipped tests warnings -->
<NoWarn>$(NoWarn),xUnit1004</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class CreditServiceTest : TestBase
[Fact(Skip = "Prism tests are disabled")]
public async Task Retrieve_Works()
{
var credit = await this.client.Credits.Retrieve(new());
var credit = await this.client.Credits.Retrieve();
credit.Validate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class HealthzServiceTest : TestBase
[Fact(Skip = "Prism tests are disabled")]
public async Task Check_Works()
{
var response = await this.client.Healthz.Check(new());
var response = await this.client.Healthz.Check();
response.Validate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task Retrieve_Works()
[Fact(Skip = "Prism tests are disabled")]
public async Task List_Works()
{
var smartscrapers = await this.client.Smartscraper.List(new());
var smartscrapers = await this.client.Smartscraper.List();
smartscrapers.Validate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class ValidateServiceTest : TestBase
[Fact(Skip = "Prism tests are disabled")]
public async Task APIKey_Works()
{
var response = await this.client.Validate.APIKey(new());
var response = await this.client.Validate.APIKey();
response.Validate();
}
}
59 changes: 59 additions & 0 deletions src/Scrapegraphai/Core/ApiEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Scrapegraphai.Exceptions;

namespace Scrapegraphai.Core;

public record struct ApiEnum<TRaw, TEnum>(JsonElement Json)
where TEnum : struct, Enum
{
public readonly TRaw Raw() =>
JsonSerializer.Deserialize<TRaw>(this.Json, ModelBase.SerializerOptions)
?? throw new ScrapegraphaiInvalidDataException(
string.Format("{0} cannot be null", nameof(this.Json))
);

public readonly TEnum Value() =>
JsonSerializer.Deserialize<TEnum>(this.Json, ModelBase.SerializerOptions);

public readonly void Validate()
{
if (!Enum.IsDefined(Value()))
{
throw new ScrapegraphaiInvalidDataException("Invalid enum value");
}
}

public static implicit operator TRaw(ApiEnum<TRaw, TEnum> value) => value.Raw();

public static implicit operator TEnum(ApiEnum<TRaw, TEnum> value) => value.Value();

public static implicit operator ApiEnum<TRaw, TEnum>(TRaw value) =>
new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions));

public static implicit operator ApiEnum<TRaw, TEnum>(TEnum value) =>
new(JsonSerializer.SerializeToElement(value, ModelBase.SerializerOptions));
}

sealed class ApiEnumConverter<TRaw, TEnum> : JsonConverter<ApiEnum<TRaw, TEnum>>
where TEnum : struct, Enum
{
public override ApiEnum<TRaw, TEnum> Read(
ref Utf8JsonReader reader,
Type typeToConvert,
JsonSerializerOptions options
)
{
return new(JsonSerializer.Deserialize<JsonElement>(ref reader, options));
}

public override void Write(
Utf8JsonWriter writer,
ApiEnum<TRaw, TEnum> value,
JsonSerializerOptions options
)
{
JsonSerializer.Serialize(writer, value.Json, options);
}
}
11 changes: 11 additions & 0 deletions src/Scrapegraphai/Core/HttpRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Net.Http;

namespace Scrapegraphai.Core;

public sealed class HttpRequest<P>
where P : ParamsBase
{
public required HttpMethod Method { get; init; }

public required P Params { get; init; }
}
Loading
Loading