AnointedAutomation.Shopify
2.1.0
dotnet add package AnointedAutomation.Shopify --version 2.1.0
NuGet\Install-Package AnointedAutomation.Shopify -Version 2.1.0
<PackageReference Include="AnointedAutomation.Shopify" Version="2.1.0" />
<PackageVersion Include="AnointedAutomation.Shopify" Version="2.1.0" />
<PackageReference Include="AnointedAutomation.Shopify" />
paket add AnointedAutomation.Shopify --version 2.1.0
#r "nuget: AnointedAutomation.Shopify, 2.1.0"
#:package AnointedAutomation.Shopify@2.1.0
#addin nuget:?package=AnointedAutomation.Shopify&version=2.1.0
#tool nuget:?package=AnointedAutomation.Shopify&version=2.1.0
AnointedAutomation.Shopify
Jesus is King ✝️
Plain POCO models for the Shopify Admin REST API, with Newtonsoft.Json attributes. Customers, addresses, marketing consent, orders, line items, refunds, transactions, products, variants, images, fulfillments, fulfillment orders, inventory items and levels, locations, webhooks, price rules, gift cards, payouts, disputes and the rest of the REST resource set.
Models plus two small helpers: ShopifyGid (format and parse gid://shopify/<Resource>/<id>) and ShopifyMoney (read a GraphQL MoneyBag from a System.Text.Json JsonElement). Since 2.0.0 ShopifyMoney.Read throws a FormatException naming the missing field and TryRead/TryReadAmount return false; a missing or unparseable amount is never 0 (see CHANGELOG.md). Deserialize the JSON you already have:
using AnointedAutomation.Shopify;
using Newtonsoft.Json;
Customer customer = JsonConvert.DeserializeObject<Customer>(json);
long? id = customer.Id;
- Target framework:
net10.0 - Dependencies:
Newtonsoft.Json,Microsoft.Extensions.Logging.Abstractions,AnointedAutomation.Serialization - Namespace:
AnointedAutomation.Shopify(converters inAnointedAutomation.Shopify.Converters)
GraphQL client (AnointedAutomation.Shopify.GraphQL)
A transport-neutral Admin GraphQL client over your own HttpClient. Tenancy and token storage stay in your code: implement IShopifyStoreContext (shop domain, API version, access-token provider).
using AnointedAutomation.Shopify.GraphQL;
ShopifyGraphQlClient client = new ShopifyGraphQlClient(httpClient, storeContext, logger);
ShopifyGraphQlResponse shop = await client.QueryAsync(new ShopifyGraphQlRequest("query Shop { shop { name } }", null), ct);
await foreach (JsonElement order in ShopifyPager.EnumerateNodesAsync(client,
"query Orders($first: Int!, $after: String) { orders(first: $first, after: $after) { nodes { id } pageInfo { hasNextPage endCursor } } }",
null, data => data.GetProperty("orders"), 250, ct))
{
}
SendAsyncreturns the raw envelope;QueryAsyncthrows on top-level errors without data;MutateAsyncthrows onuserErrorsand returns the payload.- Pacing:
ShopifyCostBucket(one per shop,ShopifyCostBucketRegistry) waits onextensions.cost.throttleStatusbefore each send. - Retries (
ShopifyRetryPolicy): 429 honorsRetry-After; HTTP 200THROTTLEDwaits what the bucket needs, on its own round budget; 5xx and network failures back off exponentially. - A mutation is resent after a 5xx or network failure ONLY when it carries an
@idempotentkey (ShopifyIdempotency). Otherwise the client throwsShopifyGraphQlExceptionwithOutcome = Indeterminate: it may have applied, so read the store before acting again. IShopifyRequestSchedulerwraps each send so you can plug in your own queue (default: run now). Cancellation is rethrown; every failure is logged with the operation name and status, never the token.
Bulk operations (AnointedAutomation.Shopify.Bulk)
ShopifyBulkOperationRunner bulk = new ShopifyBulkOperationRunner(client, plainHttpClient, logger);
ShopifyBulkOperation op = await bulk.RunQueryAsync("{ products { edges { node { id title } } } }", ct);
await foreach (JsonElement line in bulk.ReadResultsAsync(op, ct)) { } // streamed, never loaded whole
ShopifyBulkOperation m = await bulk.RunMutationAsync(mutationText, jsonlStream, "updates.jsonl", ct);
ShopifyStagedUploadsis the onestagedUploadsCreatebuilder; the JSONL is uploaded once and itskeybecomesstagedUploadPath.- The start mutations are unkeyed, so an unknown outcome throws
Indeterminateand is never resent. Only a definite "already in progress" refusal is retried, after a backoff wait. - Polling reads
node(id:)of YOUR operation with backoff (2 s doubling to 30 s, 25 h budget). The terminal state is returned: checkIsCompleted; FAILED, CANCELED and EXPIRED carryErrorCode, andResultUrlfalls back topartialDataUrl.
Webhooks (AnointedAutomation.Shopify.Webhooks)
ShopifyWebhookHmac.Verify(rawBodyBytes, request.Headers["X-Shopify-Hmac-Sha256"], secret): base64 HMAC-SHA256 of the RAW body, constant-time compare. A missing or malformed header isfalse; a missing secret throws.ShopifyWebhookRegistrar.SyncAsync(wanted, managedUriPrefix, ct): lists every subscription, keeps matches, creates missing ones and deletes stale ones ONLY under your prefix.Diffis the pure plan. UsesWebhookSubscription.uri(2025-04 and newer).
Typed operations and models (AnointedAutomation.Shopify.Operations, .GraphQL.Models)
await client.ExecuteAsync(ShopifyCatalogOperations.TagsAdd(productGid, new[] { "sale" }), ct);
ShopifyProduct p = await client.ExecuteAsync(ShopifyCatalogOperations.ProductById(productGid), ct); // null when not found
await foreach (ShopifyOrder o in ShopifyCatalogOperations.EnumerateOrdersAsync(client, "status:open", 250, ct)) { }
- Builders:
TagsAdd,TagsRemove,MetafieldsSet,ProductUpdate,ProductSet,ProductVariantsBulkUpdate,CustomerUpdate,InventoryActivate,InventorySetQuantities,ProductById,OrderById,CustomerById, plus paged product/order/customer enumeration. Each pins its query text (tests assert it byte for byte). ShopifyPublishingOperations(2.1.0):Publish/Unpublish(Publication gids only, validated),ProductPublications,CollectionPublications,SellingPlanGroupCreate/SellingPlanGroupUpdate/SellingPlanGroupDelete,OrderFulfillmentOrders. Run them withclient.ExecuteAsynclike the catalog builders.ShopifyStagedUploadsstays the onestagedUploadsCreatebuilder.- Money paths (
orderCancel,refundCreate,orderCapture,orderEdit*,draftOrderCreate) are deliberately not included. - Schema target 2026-10. On older versions:
productUpdate(product:)needs 2024-10+;@idempotentis accepted from 2026-01 and required for the inventory mutations from 2026-04;changeFromQuantityreplacesignoreCompareQuantityfrom 2026-04. - Models (
ShopifyProduct,ShopifyProductVariant,ShopifyMetafield,ShopifyCustomer,ShopifyOrder,ShopifyUserError,ShopifyConnection<T>withShopifyPageInfo,ShopifyMoneyV2/ShopifyMoneyBag; cost staysShopifyQueryCost) read withShopifyGraphQlJson.Options. Money isdecimal;NumericIdusesShopifyGid. - Hand-written, not schema-generated (decision): a generated Admin schema is thousands of types and changes every quarter, while consumers only need the fields these operations select. Small hand-written models stay stable, reviewable and dependency-free. Revisit if the operation set grows past what is reasonable to keep by hand.
License
MIT. The models are derived from ShopifySharp (Copyright (c) 2015 Joshua Harms, MIT). See THIRD-PARTY-NOTICES.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- AnointedAutomation.Serialization (>= 1.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AnointedAutomation.Shopify:
| Package | Downloads |
|---|---|
|
AnointedAutomation.Objects
Plain POCO models for user accounts, billing and payments, single sign-on identities (Google, Microsoft, Apple, Facebook, Discord, GitHub, LinkedIn, Twitch, Yahoo, Amazon, Reddit, Shopify), and standard API response envelopes. |
GitHub repositories
This package is not used by any popular GitHub repositories.