CliqtoMedia.Apify
1.0.1
dotnet add package CliqtoMedia.Apify --version 1.0.1
NuGet\Install-Package CliqtoMedia.Apify -Version 1.0.1
<PackageReference Include="CliqtoMedia.Apify" Version="1.0.1" />
<PackageVersion Include="CliqtoMedia.Apify" Version="1.0.1" />
<PackageReference Include="CliqtoMedia.Apify" />
paket add CliqtoMedia.Apify --version 1.0.1
#r "nuget: CliqtoMedia.Apify, 1.0.1"
#:package CliqtoMedia.Apify@1.0.1
#addin nuget:?package=CliqtoMedia.Apify&version=1.0.1
#tool nuget:?package=CliqtoMedia.Apify&version=1.0.1
CliqtoMedia.Apify: run Apify scrapers from C# and .NET
Run any public Apify Actor from C# and get its dataset items in one call: Reddit, YouTube, Trustpilot, Amazon, Google Search, Indeed, Zillow, Booking.com and more. Typed results with System.Text.Json, no extra dependencies.
What you get
ApifyActorClient.RunActorAsyncstarts an Actor, waits for it to finish and returns the dataset items.- Results as
JsonElementor as your own record type (RunActorAsync<T>). - An
Actorsclass with ready names of popular scrapers, so you do not mistype them. - Cost caps:
MaxTotalChargeUsd,MaxItemsandMemoryMbytesgo straight to the Apify run. - A timeout that aborts the run, and clear errors for a missing token, a wrong Actor name and a failed run.
- Targets .NET 8 and .NET 10. No packages besides the .NET base library.
The package works with any public Actor on Apify, not only ours. It reads dataset items with clean=true, so hidden helper fields and empty items are dropped. The Popular Actors section below lists Actors you can run right away.
Install
dotnet add package CliqtoMedia.Apify
Get your Apify token
The package uses your own Apify account. It never ships a token.
- Create a free account at apify.com.
- In Apify Console, open Settings, then API & Integrations. Copy the Personal API token (how to find it).
- Set it as the
APIFY_TOKENenvironment variable:
export APIFY_TOKEN=your_token_here
On Windows PowerShell: $env:APIFY_TOKEN = "your_token_here".
You can also pass the token to the constructor: new ApifyActorClient("your_token_here"). Prefer the environment variable or a secret store such as .NET user secrets. Keep the token out of code you share.
Quick start
using CliqtoMedia.Apify;
using var apify = new ApifyActorClient(); // reads APIFY_TOKEN
var items = await apify.RunActorAsync(
Actors.YoutubeTranscriptScraper,
new { videoUrls = new[] { "jNQXAC9IVRw" } });
foreach (var item in items)
{
Console.WriteLine(item.GetProperty("videoId").GetString());
}
The input is any object that System.Text.Json can serialize: an anonymous object, a record, a Dictionary<string, object> or a JsonElement. Property names are sent in camelCase (MaxReviews becomes maxReviews), and properties set to null are left out so the Actor uses its own defaults. A JsonElement is sent as is. Pass null to use all Actor defaults.
The samples are console apps with the default implicit usings (System, System.Linq, System.IO).
Typed results
Declare a record with the fields you need. Property names match the JSON fields without regard to case, and fields you do not declare are skipped.
using CliqtoMedia.Apify;
using var apify = new ApifyActorClient();
var reviews = await apify.RunActorAsync<Review>(
Actors.TrustpilotReviewsScraper,
new { companyDomains = new[] { "apify.com" }, maxReviews = 5 });
foreach (var r in reviews)
{
Console.WriteLine($"{r.Rating}/5 {r.Title}");
}
record Review(int? Rating, string? Title, string? Text, string? Date, string? Url);
Options
var items = await apify.RunActorAsync(Actors.GoogleSearchScraper, input, new RunOptions
{
Timeout = TimeSpan.FromMinutes(10), // abort the run after this (default 5 minutes)
Limit = 100, // download at most 100 items
MaxTotalChargeUsd = 0.50m, // cost cap for pay-per-event Actors, start fee included
MaxItems = 100, // result cap for pay-per-result Actors
MemoryMbytes = 1024, // run memory, a power of 2
});
| Option | Meaning |
|---|---|
Timeout |
How long to wait for the run. Default 5 minutes. On timeout the run is aborted and ApifyException is thrown |
PollInterval |
Pause between status checks. Default 2 seconds |
Limit |
Download at most N dataset items |
MaxTotalChargeUsd |
Apify maxTotalChargeUsd: the run stops charging at this sum. It includes the Actor start fee, so set it above that fee |
MaxItems |
Apify maxItems: you pay for at most N results |
MemoryMbytes |
Apify memory: 128, 256, 512, 1024 and so on. Default: the Actor's own |
Pass a CancellationToken as the last argument to stop waiting. Cancelling only stops the wait; the run can keep going in Apify Console.
Errors
| Exception | When |
|---|---|
MissingTokenException |
No token passed and APIFY_TOKEN is empty |
ApifyHttpException |
Apify answered with an error. StatusCode holds the HTTP code (401 bad token, 404 Actor not found, 402 not enough credit, 429 too many requests) |
ApifyException |
The run failed, timed out or was aborted, or a RunOptions value is invalid. RunId and RunStatus tell you which run; the message has the Actor's own status message and a link to the run log |
The other two derive from ApifyException, so one catch (ApifyException e) covers them all.
Your own HttpClient
Pass an HttpClient to reuse a connection pool or add a proxy: new ApifyActorClient(token: null, httpClient: myClient). The package does not dispose a client you pass. For IHttpClientFactory, create the client from the factory and pass it the same way.
Examples
YouTube transcript
The YouTube Transcript Scraper returns one item per video:
record Segment(double StartSeconds, double DurationSeconds, string Text);
record Transcript(string Status, string VideoId, List<Segment> Segments);
var videos = await apify.RunActorAsync<Transcript>(
Actors.YoutubeTranscriptScraper,
new { videoUrls = new[] { "jNQXAC9IVRw" } });
foreach (var s in videos[0].Segments)
{
Console.WriteLine($"[{s.StartSeconds:0.0}s] {s.Text}");
}
The main fields of the first item, shortened:
{
"status": "SUCCEEDED",
"complete": true,
"videoId": "jNQXAC9IVRw",
"canonicalUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
"segments": [
{
"sequence": 0,
"text": "All right, so here we are, in front of the elephants",
"startSeconds": 1.2,
"durationSeconds": 2.16
}
],
"segmentCount": 6
}
Trustpilot reviews to CSV
The latest 5 reviews of a company with the Trustpilot Reviews Scraper, saved as a simple CSV:
var reviews = await apify.RunActorAsync<Review>(
Actors.TrustpilotReviewsScraper,
new { companyDomains = new[] { "apify.com" }, maxReviews = 5 });
static string Csv(string? s) => "\"" + (s ?? "").Replace("\"", "\"\"") + "\"";
var lines = reviews.Select(r => string.Join(",", r.Rating, Csv(r.Title), Csv(r.Date), Csv(r.Url)));
File.WriteAllLines("reviews.csv", lines.Prepend("rating,title,date,url"));
record Review(int? Rating, string? Title, string? Text, string? Date, string? Url);
Each item is one review. Main fields: company, companyTrustScore, rating, title, text, language, date, country, verified, replyText, url.
Google search results
Organic results for a query with the Google Search Scraper:
var results = await apify.RunActorAsync<SearchResult>(
Actors.GoogleSearchScraper,
new { queries = new[] { "dotnet web scraping" }, maxPagesPerQuery = 1, includeAds = false });
foreach (var r in results.Where(r => r.Type == "organic"))
{
Console.WriteLine($"{r.Position}. {r.Title} {r.Url}");
}
record SearchResult(string Type, int? Position, string? Title, string? Url, string? Description);
Each item is one result with query, page, type, position, title, url, description and fetchedAt.
Each Actor has its own input and output fields. Read them on the Actor page.
Any other Actor
Use the username/actor-name from the Actor's Apify page:
var items = await apify.RunActorAsync("apify/website-content-crawler",
new { startUrls = new[] { new { url = "https://docs.apify.com" } }, maxCrawlPages = 1 });
Popular Actors
Use the constant from the Actors class or the Actor name as a string. The input fields and an example input are on each Actor page.
Social media and video
| Constant | Actor name | What you get | Details |
|---|---|---|---|
Actors.RedditScraper |
cliqtomedia/reddit-scraper |
Reddit posts, comments and subreddits | Page |
Actors.YoutubeTranscriptScraper |
cliqtomedia/youtube-transcript-scraper |
YouTube transcripts and subtitles with timestamps | Page |
Actors.YoutubeCommentsScraper |
cliqtomedia/youtube-comments-scraper |
YouTube comments and replies | Page |
Actors.YoutubeChannelVideos |
cliqtomedia/youtube-channel-videos |
YouTube channel videos with views, likes and Shorts | Page |
Actors.TiktokTranscript |
cliqtomedia/tiktok-transcript |
TikTok captions and speech to text | Page |
Actors.ThreadsScraper |
cliqtomedia/threads-scraper |
Threads posts, profiles and replies | Page |
Actors.TelegramChannelScraper |
cliqtomedia/telegram-channel-scraper |
Telegram channel posts and views | Page |
Actors.FacebookAdLibrary |
cliqtomedia/facebook-ad-library |
Facebook Ad Library: competitor ads | Page |
Search and web pages
| Constant | Actor name | What you get | Details |
|---|---|---|---|
Actors.GoogleSearchScraper |
cliqtomedia/google-search-scraper |
Google search results (SERP) | Page |
Actors.GoogleNewsScraper |
cliqtomedia/google-news-scraper |
Google News articles with real URLs | Page |
Actors.GoogleTrendsScraper |
cliqtomedia/google-trends-scraper |
Google Trends interest by time, region and query | Page |
Actors.RagWebSearch |
cliqtomedia/rag-web-search |
Google results as clean Markdown for RAG and LLMs | Page |
Actors.WebsiteToMarkdown |
cliqtomedia/website-to-markdown |
Website pages as Markdown for RAG | Page |
Actors.WebsiteContactsScraper |
cliqtomedia/website-contacts-scraper |
Emails, phones and social links from websites | Page |
E-commerce and prices
| Constant | Actor name | What you get | Details |
|---|---|---|---|
Actors.AmazonScraper |
cliqtomedia/amazon-scraper |
Amazon products, prices, reviews and BSR | Page |
Actors.WalmartScraper |
cliqtomedia/walmart-scraper |
Walmart products and reviews | Page |
Actors.EbaySoldListings |
cliqtomedia/ebay-sold-listings |
eBay sold listings with prices and dates | Page |
Actors.ShopifyProductsScraper |
cliqtomedia/shopify-products-scraper |
Products from any Shopify store | Page |
Actors.AliexpressScraper |
cliqtomedia/aliexpress-scraper |
AliExpress products, prices and reviews | Page |
Actors.TemuScraper |
cliqtomedia/temu-scraper |
Temu products, prices, variants and reviews | Page |
Reviews and travel
| Constant | Actor name | What you get | Details |
|---|---|---|---|
Actors.TrustpilotReviewsScraper |
cliqtomedia/trustpilot-reviews-scraper |
Trustpilot reviews, ratings and company replies | Page |
Actors.GooglePlayReviewsScraper |
cliqtomedia/google-play-reviews-scraper |
Google Play app reviews | Page |
Actors.AppleAppStoreReviewsScraper |
cliqtomedia/apple-app-store-reviews-scraper |
Apple App Store app reviews | Page |
Actors.BookingScraper |
cliqtomedia/booking-scraper |
Booking.com hotels, prices and reviews | Page |
Actors.TripadvisorScraper |
cliqtomedia/tripadvisor-scraper |
Tripadvisor places, reviews and hotel prices | Page |
Actors.YelpScraper |
cliqtomedia/yelp-scraper |
Yelp businesses and reviews | Page |
Actors.AirbnbScraper |
cliqtomedia/airbnb-scraper |
Airbnb listings, prices and calendar | Page |
Jobs, companies and real estate
| Constant | Actor name | What you get | Details |
|---|---|---|---|
Actors.IndeedScraper |
cliqtomedia/indeed-scraper |
Indeed jobs with salaries | Page |
Actors.GlassdoorScraper |
cliqtomedia/glassdoor-scraper |
Glassdoor jobs and company reviews | Page |
Actors.UpworkJobsScraper |
cliqtomedia/upwork-jobs-scraper |
Upwork jobs with pay and client details | Page |
Actors.WellfoundJobsScraper |
cliqtomedia/wellfound-jobs-scraper |
Wellfound startup jobs | Page |
Actors.CrunchbaseCompanies |
cliqtomedia/crunchbase-companies |
Crunchbase companies and funding | Page |
Actors.ZillowScraper |
cliqtomedia/zillow-scraper |
Zillow listings with Zestimates | Page |
Actors.IdealistaScraper |
cliqtomedia/idealista-scraper |
Idealista listings in Spain, Italy, Portugal and France | Page |
Actors.EmailVerifier |
cliqtomedia/email-verifier |
Bulk email verification: MX, disposable and role checks | Page |
All 250+ Cliqto Media Actors are in the Actor catalog and on our Apify Store profile.
Control the cost
- Set the Actor's own limit in the input, for example
maxReviewsormaxPosts. The cost depends on the Actor's pricing (per result, per event or compute time), so a smaller input means a smaller bill. - Add a hard cap with
RunOptions.MaxTotalChargeUsd(pay-per-event Actors) orRunOptions.MaxItems(pay-per-result Actors). Apify applies them to the run itself. The cap counts the Actor start fee too: check the fee on the Actor page and set the cap above it. Limitonly trims how many items the package downloads after the run. It does not make the run smaller.- Start with a small test run and check the cost in Apify Console, Runs.
Pricing
This package is free (MIT license). Running an Actor uses your own Apify account, and Apify bills that usage by the Actor's own pricing. The price of each Actor is on its Apify page. The Apify free plan includes a monthly credit. Check the price before you start.
Limits
- It runs one Actor per call and returns when the run ends. It does not stream partial results.
- It waits up to
Timeout(default 5 minutes). If the run is not done by then, the package aborts it and throwsApifyException. RaiseTimeoutfor big runs. - It reads at most
Limitdataset items. WithoutLimit, it reads the whole dataset into memory. - It does not manage tasks, schedules, webhooks or key-value stores. Use the full Apify API for those.
- The run must succeed. If the Actor fails, you get an exception, not partial items.
FAQ
How is it different from Apify.Client? Apify.Client covers the whole Apify API. This package does one thing: run an Actor and give you the items, with typed results, cost caps and ready Actor names. Use both if you like.
Does it work with Actors from other authors?
Yes. Use any Actor name in the form username/actor-name. username~actor-name works too.
Where does the token go?
Into the APIFY_TOKEN environment variable or the constructor. The package sends it only to api.apify.com, in the Authorization header.
Why do I get HTTP 401? Apify rejected the token. Copy it again from Console, Settings, API & Integrations.
Why do I get HTTP 404?
The Actor name is wrong or the Actor is private. Check the spelling, or use a constant from Actors.
Can I use it in ASP.NET Core, Azure Functions or a background service?
Yes. Create one ApifyActorClient, keep it for the app's lifetime (it is thread-safe), and pass a CancellationToken from the request or host.
Does it work with .NET Framework? No. It needs .NET 8 or newer.
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.1: documentation update, the catalog now has 250+ Actors. 1.0.0: first release. ApifyActorClient.RunActorAsync, typed results, cost caps (MaxTotalChargeUsd, MaxItems, MemoryMbytes), Actors name list.