Skip to content

ScrapeGraphAI/scrapegraphai-c

Repository files navigation

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.

The Scrapegraphai C# SDK provides convenient access to the Scrapegraphai REST API from applications written in C#.

It is generated with Stainless.

The REST API documentation can be found on scrapegraphai.com.

Installation

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 directory for complete and runnable examples.

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:

using Scrapegraphai;

// Configured using the SCRAPEGRAPHAI_API_KEY and SCRAPEGRAPHAI_BASE_URL environment variables
ScrapegraphaiClient client = new();

Or manually:

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<CompletedSmartscraper>.

Semantic versioning

This package generally follows SemVer 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 with questions, bugs, or suggestions.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published