ForeverTools.Apify 1.0.0

dotnet add package ForeverTools.Apify --version 1.0.0
                    
NuGet\Install-Package ForeverTools.Apify -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ForeverTools.Apify" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ForeverTools.Apify" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ForeverTools.Apify" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ForeverTools.Apify --version 1.0.0
                    
#r "nuget: ForeverTools.Apify, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ForeverTools.Apify@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ForeverTools.Apify&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ForeverTools.Apify&version=1.0.0
                    
Install as a Cake Tool

ForeverTools.Apify

Lightweight Apify client for .NET. Web scraping and automation platform with 1,600+ ready-made actors for Amazon, Google, Instagram, Twitter, and more.

NuGet

Features

  • 1,600+ Ready-Made Scrapers - Amazon, Google, Instagram, Twitter, LinkedIn, and more
  • Run Any Actor - Execute pre-built or custom actors with one method
  • Datasets - Store and retrieve structured scraping results
  • Key-Value Stores - Save files, screenshots, and JSON data
  • Schedules - Automate recurring scrapes with cron expressions
  • Async Operations - Start jobs and check status later
  • ASP.NET Core Ready - Built-in dependency injection
  • Multi-Target - .NET 8, .NET 6, .NET Standard 2.0

Quick Start

Install

dotnet add package ForeverTools.Apify

Get Your API Token

Sign up at Apify to get your API token with free monthly credits.

Basic Usage

using ForeverTools.Apify;
using ForeverTools.Apify.Constants;

var client = new ApifyClient("your-api-token");

// Run a web scraper and get results
var results = await client.ScrapeAsync<Dictionary<string, object>>(
    PopularActors.WebScraper,
    new
    {
        startUrls = new[] { new { url = "https://example.com" } },
        maxPagesPerCrawl = 10
    });

foreach (var item in results)
{
    Console.WriteLine(item["url"]);
}

Use pre-built scrapers from the Apify Store:

using ForeverTools.Apify.Constants;

// E-Commerce
var amazonProducts = await client.ScrapeAsync<AmazonProduct>(
    PopularActors.AmazonScraper,
    new { keyword = "laptop", maxItems = 100 });

// Social Media
var instagramPosts = await client.ScrapeAsync<InstagramPost>(
    PopularActors.InstagramScraper,
    new { usernames = new[] { "nasa" }, resultsLimit = 50 });

// Search Engines
var googleResults = await client.ScrapeAsync<SearchResult>(
    PopularActors.GoogleSearchScraper,
    new { queries = "web scraping tools", maxPagesPerQuery = 1 });

// Google Maps
var places = await client.ScrapeAsync<Place>(
    PopularActors.GoogleMapsScraper,
    new { searchStringsArray = new[] { "restaurants in New York" } });

Available Actor Constants

Category Actors
Web Scraping WebScraper, CheerioScraper, PuppeteerScraper, PlaywrightScraper
E-Commerce AmazonScraper, EbayScraper, WalmartScraper, ShopifyScraper, EtsyScraper
Social Media InstagramScraper, TwitterScraper, TikTokScraper, YouTubeScraper, LinkedInScraper
Search GoogleSearchScraper, GoogleMapsScraper, BingSearchScraper
Travel BookingScraper, AirbnbScraper, TripAdvisorScraper
Jobs IndeedScraper, GlassdoorScraper
Reviews TrustpilotScraper, YelpScraper, AppStoreScraper

Advanced Usage

Run Actor and Wait

// Start actor and wait for completion
var run = await client.RunActorAsync(
    "apify/web-scraper",
    new { startUrls = new[] { new { url = "https://example.com" } } },
    new ActorRunOptions
    {
        MemoryMb = 1024,
        TimeoutSeconds = 300
    });

Console.WriteLine($"Run status: {run.Status}");
Console.WriteLine($"Dataset ID: {run.DefaultDatasetId}");

// Get results from the dataset
var items = await client.GetDatasetItemsAsync<MyDataClass>(run.DefaultDatasetId);

Start Actor Without Waiting

// Start actor and get run ID immediately
var run = await client.StartActorAsync("apify/web-scraper", input);
Console.WriteLine($"Started run: {run.Id}");

// Check status later
var status = await client.GetRunAsync(run.Id);
if (status.IsSucceeded)
{
    var items = await client.GetRunDatasetItemsAsync<MyData>(run.Id);
}

Get Run Output from Key-Value Store

// Some actors store their output in key-value stores instead of datasets
var output = await client.RunAndGetOutputAsync<MyOutput>(
    "apify/some-actor",
    new { url = "https://example.com" },
    outputKey: "OUTPUT");

Dataset Operations

// Get items with pagination
var items = await client.GetDatasetItemsAsync<Product>(
    datasetId,
    new DatasetItemsOptions
    {
        Offset = 0,
        Limit = 100,
        Clean = true,
        Fields = new List<string> { "title", "price", "url" }
    });

// Push items to a dataset
await client.PushDatasetItemsAsync(datasetId, new[]
{
    new { title = "Product 1", price = 29.99 },
    new { title = "Product 2", price = 39.99 }
});

// List all datasets
var datasets = await client.ListDatasetsAsync();

Key-Value Store Operations

// Get a JSON record
var data = await client.GetKeyValueRecordAsync<MyData>(storeId, "my-key");

// Get a screenshot or file as bytes
var screenshot = await client.GetKeyValueRecordBytesAsync(storeId, "screenshot.png");
File.WriteAllBytes("screenshot.png", screenshot);

// Store data
await client.SetKeyValueRecordAsync(storeId, "my-key", new { foo = "bar" });

// Store a file
var imageBytes = File.ReadAllBytes("image.png");
await client.SetKeyValueRecordAsync(storeId, "image.png", imageBytes, "image/png");

// List all keys
var keys = await client.ListKeyValueStoreKeysAsync(storeId);

Schedule Recurring Runs

// Create a schedule to run an actor daily at 9 AM
var schedule = await client.CreateScheduleAsync(new ScheduleRequest
{
    Name = "Daily Amazon Scrape",
    CronExpression = "0 9 * * *",
    Timezone = "America/New_York",
    IsEnabled = true,
    Actions = new List<ScheduleAction>
    {
        new ScheduleAction
        {
            Type = ScheduleActionTypes.RunActor,
            ActorId = "junglee/amazon-crawler",
            RunInput = new ScheduleRunInput
            {
                ContentType = "application/json",
                Body = JsonSerializer.Serialize(new { keyword = "laptop" })
            }
        }
    }
});

// List schedules
var schedules = await client.ListSchedulesAsync();

// Update schedule
await client.UpdateScheduleAsync(schedule.Id, new ScheduleRequest
{
    IsEnabled = false
});

// Delete schedule
await client.DeleteScheduleAsync(schedule.Id);

Get User Information

var user = await client.GetUserAsync();
Console.WriteLine($"Username: {user.Username}");
Console.WriteLine($"Plan: {user.Plan?.Name}");
Console.WriteLine($"Max concurrent runs: {user.Limits?.MaxConcurrentActorJobs}");

ASP.NET Core Integration

// Program.cs
builder.Services.AddForeverToolsApify("your-api-token");

// Or with full configuration
builder.Services.AddForeverToolsApify(options =>
{
    options.Token = "your-api-token";
    options.DefaultMemoryMb = 512;
    options.DefaultTimeoutSeconds = 600;
    options.TimeoutSeconds = 300;
});

// Or from appsettings.json
builder.Services.AddForeverToolsApify(builder.Configuration);
// appsettings.json
{
  "Apify": {
    "Token": "your-api-token",
    "DefaultMemoryMb": 512,
    "DefaultTimeoutSeconds": 600
  }
}
// Inject and use
public class ProductScraperService
{
    private readonly ApifyClient _apify;

    public ProductScraperService(ApifyClient apify)
    {
        _apify = apify;
    }

    public async Task<List<Product>> ScrapeAmazonAsync(string keyword)
    {
        return await _apify.ScrapeAsync<Product>(
            PopularActors.AmazonScraper,
            new { keyword, maxItems = 100 });
    }
}

Environment Variables

// Uses APIFY_TOKEN by default
var client = ApifyClient.FromEnvironment();

// Or specify custom variable name
var client = ApifyClient.FromEnvironment("MY_APIFY_TOKEN");

Error Handling

try
{
    var results = await client.ScrapeAsync<Product>(actorId, input);
}
catch (ApifyException ex)
{
    Console.WriteLine($"Apify error: {ex.Message}");
    Console.WriteLine($"Status code: {ex.StatusCode}");
}

Why Apify?

Apify is the leading web scraping and automation platform:

  • 1,600+ ready-made scrapers - No coding required for common sites
  • Powerful infrastructure - Runs in the cloud with automatic scaling
  • Proxy management - Built-in residential and datacenter proxies
  • Data storage - Datasets and key-value stores included
  • Scheduling - Automate recurring scrapes
  • Free tier - Get started with free monthly credits

Other ForeverTools Packages

Package Description NuGet
ForeverTools.AIML Access 400+ AI models (GPT-4, Claude, Llama, Gemini, DALL-E) NuGet
ForeverTools.APILayer IP geolocation, currency exchange, phone & email validation NuGet
ForeverTools.Captcha Multi-provider captcha solving (2Captcha, CapSolver, Anti-Captcha) NuGet
ForeverTools.ImageGen AI image generation with social media presets (DALL-E, Flux, SD) NuGet
ForeverTools.OCR AI-powered OCR using GPT-4 Vision, Claude 3, and Gemini NuGet
ForeverTools.Postmark Transactional email sending with templates and tracking NuGet
ForeverTools.Proxy Premium proxy rotation with BrightData (Residential, ISP, Mobile) NuGet
ForeverTools.ScraperAPI Web scraping with proxy rotation and CAPTCHA solving NuGet
ForeverTools.STT Speech-to-Text using Whisper (transcription, subtitles, language detection) NuGet
ForeverTools.Translate AI-powered translation with 100+ languages (GPT-4, Claude) NuGet

Requirements

  • .NET 8.0, .NET 6.0, or .NET Standard 2.0 compatible framework
  • Apify account with API token

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 235 12/15/2025