https://github.com/scrapegraphai/scrapegraphai-c
https://github.com/scrapegraphai/scrapegraphai-c
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/scrapegraphai/scrapegraphai-c
- Owner: ScrapeGraphAI
- License: apache-2.0
- Created: 2025-08-12T10:39:26.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-08-13T02:09:23.000Z (5 months ago)
- Last Synced: 2025-08-13T04:09:58.381Z (5 months ago)
- Language: C#
- Size: 83 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Scrapegraphai C# API Library
> [!NOTE]
> The Scrapegraphai C# API Library is currently in **beta** and we're excited for you to experiment with it!
>
> 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).
The Scrapegraphai C# SDK provides convenient access to the [Scrapegraphai REST API](https://scrapegraphai.com) from applications written in C#.
It is generated with [Stainless](https://www.stainless.com/).
The REST API documentation can be found on [scrapegraphai.com](https://scrapegraphai.com).
## Installation
```bash
dotnet add package Scrapegraphai
```
## Requirements
This library requires .NET 8 or later.
> [!NOTE]
> The library is currently in **beta**. The requirements will be lowered in the future.
## Usage
See the [`examples`](examples) directory for complete and runnable examples.
```csharp
using Scrapegraphai;
using Scrapegraphai.Models.Smartscraper;
using System;
// Configured using the SCRAPEGRAPHAI_API_KEY and SCRAPEGRAPHAI_BASE_URL environment variables
ScrapegraphaiClient client = new();
SmartscraperCreateParams parameters = new()
{
UserPrompt = "Extract the product name, price, and description"
};
var completedSmartscraper = await client.Smartscraper.Create(parameters);
Console.WriteLine(completedSmartscraper);
```
## Client Configuration
Configure the client using environment variables:
```csharp
using Scrapegraphai;
// Configured using the SCRAPEGRAPHAI_API_KEY and SCRAPEGRAPHAI_BASE_URL environment variables
ScrapegraphaiClient client = new();
```
Or manually:
```csharp
using Scrapegraphai;
ScrapegraphaiClient client = new() { APIKey = "My API Key" };
```
Or using a combination of the two approaches.
See this table for the available options:
| Property | Environment variable | Required | Default value |
| --------- | ------------------------ | -------- | ------------------------------------ |
| `APIKey` | `SCRAPEGRAPHAI_API_KEY` | true | - |
| `BaseUrl` | `SCRAPEGRAPHAI_BASE_URL` | true | `"https://api.scrapegraphai.com/v1"` |
## Requests and responses
To send a request to the Scrapegraphai API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a C# class.
For example, `client.Smartscraper.Create` should be called with an instance of `SmartscraperCreateParams`, and it will return an instance of `Task`.
## 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:
1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
2. Changes that we do not expect to impact the vast majority of users in practice.
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.