Skip to content

feat: add .NET client for the Apify API (spec v2-2026-07-02T131926Z) - #1

Merged
Pijukatel merged 5 commits into
masterfrom
claude/adoring-ritchie-7s05ro
Jul 5, 2026
Merged

Pijukatel merged 5 commits into
masterfrom
claude/adoring-ritchie-7s05ro

Conversation

@Pijukatel

Copy link
Copy Markdown
Collaborator

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

  • Resource-oriented ApifyClient with 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, plus SetStatusMessageAsync and actor ValidateInputAsync.
  • Replaceable HTTP transport via an interface with a default HttpClient-based implementation.
  • Cross-cutting behaviour on every call: bearer auth, the mandated User-Agent, exponential-backoff-with-jitter retries (429/5xx/transport) with a growing-but-capped per-attempt timeout, and 404 → null on single-resource GETs.
  • Binary-safe payloads: key-value-store records and dataset downloads are byte[] (so images/gzip/XLSX round-trip intact), matching the Java/Go/JS reference behaviour.
  • Convenience helpers matching the reference client: Actor(...).CallAsync/Task(...).CallAsync, WaitForFinishAsync, DefaultBuildAsync, Metamorph/Reboot/Resurrect/Charge, run-nested storages, lazy Store().IterateAsync() and RequestQueue(...).PaginateRequestsAsync(), dataset download/statistics/public URLs, key-value-store record & key-list public URLs with HMAC-SHA256 signing, and request-queue batch add with uniqueKey validation, byte-size-bounded chunking, and bounded-parallel dispatch.
  • Public version constants (ClientVersion, ApiSpecVersion); models capture unmodelled API fields for forward compatibility.

Tests, docs & CI

  • xUnit unit tests (mock transport: auth/UA, envelope, 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.
  • Quality gates: dotnet format, .NET analyzers, and warnings-as-errors solution-wide (public XML docs compiler-enforced).
  • GitHub Actions: .NET integration tests (format + build + unit + integration + Test examples, path-filtered PR-to-master + manual dispatch, APIFY_TOKEN guard) and a manual Publish .NET client workflow to NuGet (API key from repo secrets) that tags a GitHub release.

Verification

  • dotnet format --verify-no-changes — clean
  • dotnet build -c Release — 0 warnings / 0 errors (warnings-as-errors + analyzers)
  • Tests — 50 unit + live integration + 7 example programs, 0 failures (APIFY_TOKEN set)

Scope notes

  • Endpoint scope tracks the JS reference; for in-scope endpoints all OpenAPI parameters are covered.
  • Nested actor/task Webhooks() are read-only, matching the spec (those nested endpoints are GET-only).

Generated by Claude Code

claude and others added 2 commits July 3, 2026 15:43
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.
@Pijukatel Pijukatel changed the title feat: add .NET client for the Apify API (spec v2-2026-07-01T115402Z) feat: add .NET client for the Apify API (spec v2-2026-07-02T131926Z) Jul 4, 2026
claude added 3 commits July 4, 2026 19:22
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
@Pijukatel
Pijukatel merged commit 047a6f0 into master Jul 5, 2026
2 checks passed
@Pijukatel
Pijukatel deleted the claude/adoring-ritchie-7s05ro branch July 8, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants