feat: add .NET client for the Apify API (spec v2-2026-07-02T131926Z) - #1
Merged
Merged
Conversation
Bespoke, idiomatic C#/.NET 8 client (Apify.Client) mirroring the reference JS client: resource clients for actors (+versions, env vars), builds, runs, datasets, key-value stores, request queues, tasks, schedules, webhooks, dispatches, store, users and logs, plus SetStatusMessage and actor ValidateInput. Replaceable HttpClient-based transport, bearer auth, mandated User-Agent, exponential-backoff retries, 404->null, HMAC storage URL signing, binary-safe key-value records and dataset downloads (byte[]), and batch request add with uniqueKey validation and byte-size-bounded, parallelism-limited chunking. Includes xUnit unit tests (mock transport), live integration tests, runnable documentation examples with a CI test step, docs/, CHANGELOG, analyzers + warnings-as-errors + dotnet format gates, and CI workflows for integration tests and NuGet publishing.
…131926Z) Client is already on the latest spec; this is a compliance/review pass: - Publishing workflow: use NuGet Trusted Publishing (OIDC via NuGet/login) with a short-lived key instead of a long-lived NUGET_API_KEY. - Forward last-run status/origin filters to nested dataset/key-value-store/ request-queue/log accessors (and route Dataset list/download/push through MergedParams) so a filtered last-run resolves the correct run. - Add lazy auto-paging IterateAsync to collection clients and DatasetClient.IterateItemsAsync (JS PaginatedIterator parity). - Add run-log redirection: public StreamedLog, RunClient.GetStreamedLog(sink), and a log sink parameter on Actor/Task CallAsync. - Add DefaultBuild integration test; docs/CHANGELOG/comment cleanups.
Add offline unit tests for 429 retry, doNotRetryTimeouts, per-attempt timeout doubling/cap, retry exhaustion, bounded-parallelism over the limit, CSV/double query encoding, KVS binary write shape, and IsNotFound/null-omit branches (unit tests 50 -> 65). Align ApiSpecVersion + CHANGELOG to v2-2026-07-01T115402Z (match the sibling clients). Document the public namespaces (incl. Apify.Client.Resources) and add using System; to Console snippets; drop the unused id-token permission from the publish workflow.
- Bump ApiSpecVersion + CHANGELOG to v2-2026-07-02T131926Z (current latest info.version; matches the Java/PHP/Rust/Go siblings). - Publish via NuGet API key (NUGET_API_KEY repo secret) instead of Trusted Publishing OIDC: per the updated requirement, Trusted Publisher is used only when officially supported, and NuGet.org Trusted Publishing is not yet GA. Adds a fail-fast guard when the secret is missing; drops id-token permission.
- tests: add ActorRunIntegrationTests.UpdateAndDeleteRun (start, wait terminal, UpdateAsync statusMessage, DeleteAsync) and UserIntegrationTests.GetPublicUserById (Me() then User(id).GetAsync(), asserting on spec-guaranteed Username since UserPublicInfo has no id) - docs: add docs/models.md data-model property reference; add option-field descriptions and field tables (DownloadItemsFormat, DatasetDownloadOptions, ActorBuildOptions, Metamorph/RunResurrect/RunCharge/ValidateInput/LastRun options, ApifyApiException); document BatchDeleteRequestsAsync + WithClientKey; normalize optional-parameter notation; add method return types - changelog: mention docs/models.md Spec v2-2026-07-02T131926Z (unchanged). No public-interface changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017sJGjCxFP3bpbeF4LsVqK3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the official (experimental, AI-generated and AI-maintained) .NET client for the Apify API, built from scratch and verified against the Apify OpenAPI specification. Idiomatic C# targeting .NET 8; the public interface mirrors the JavaScript reference client and is consistent with the Java/PHP/Rust/Go siblings.
What's included
ApifyClientwith accessors for Actors (+ versions & env vars), builds, runs, datasets, key-value stores, request queues, tasks, schedules, webhooks, webhook dispatches, the Apify Store, users, and logs, plusSetStatusMessageAsyncand actorValidateInputAsync.HttpClient-based implementation.User-Agent, exponential-backoff-with-jitter retries (429/5xx/transport) with a growing-but-capped per-attempt timeout, and404 → nullon single-resource GETs.byte[](so images/gzip/XLSX round-trip intact), matching the Java/Go/JS reference behaviour.Actor(...).CallAsync/Task(...).CallAsync,WaitForFinishAsync,DefaultBuildAsync,Metamorph/Reboot/Resurrect/Charge, run-nested storages, lazyStore().IterateAsync()andRequestQueue(...).PaginateRequestsAsync(), dataset download/statistics/public URLs, key-value-store record & key-list public URLs with HMAC-SHA256 signing, and request-queue batch add withuniqueKeyvalidation, byte-size-bounded chunking, and bounded-parallel dispatch.ClientVersion,ApiSpecVersion); models capture unmodelled API fields for forward compatibility.Tests, docs & CI
404→null, retries, error parsing, batch chunking/parallelism/retry semantics, signature known-answer vectors, binary round-trips), a live integration suite (one GET + one CRUD/complex flow per resource), runnable documentation examples executed in CI.docs/reference for every resource (with a fully runnable example set),CHANGELOG.md, README.dotnet format, .NET analyzers, and warnings-as-errors solution-wide (public XML docs compiler-enforced)..NET integration tests(format + build + unit + integration +Test examples, path-filtered PR-to-master + manual dispatch,APIFY_TOKENguard) and a manualPublish .NET clientworkflow to NuGet (API key from repo secrets) that tags a GitHub release.Verification
dotnet format --verify-no-changes— cleandotnet build -c Release— 0 warnings / 0 errors (warnings-as-errors + analyzers)APIFY_TOKENset)Scope notes
Webhooks()are read-only, matching the spec (those nested endpoints are GET-only).Generated by Claude Code