Can you use the Shopify API in C#? Yes, and you don't need much to do it. Using the Shopify GraphQL API in C# is simpler than it sounds: the GraphQL Admin API
is one HTTPS endpoint that takes a POST with a query in it, so the HttpClient and
System.Text.Json that come with .NET 8 are all you need. This is the practical version: how to get an access
token, which API version to call, and C# code for queries, pagination, rate limits and mutations.
I build all my Shopify apps in .NET and C# (I explain why in why I build Shopify apps with .NET instead of Node.js), so this is the guide I wish I'd had at the start. Every Shopify rule in it was checked against Shopify's developer documentation in November 2026.
Is there a Shopify C# SDK?
Not an official one. Shopify's own libraries and templates page lists official libraries for Ruby, Node.js, PHP and Python, but not .NET. The .NET option it does list is ShopifySharp, a community library that Shopify says it doesn't maintain.
You don't need a library to get started. GraphQL means one URL and one request shape for everything, so a small client class of your own is enough, and you can see exactly what goes over the wire. That is the approach below.
What you need before you write any code
- A store. Your own store or a development store, with the subdomain to hand (the
your-storepart ofyour-store.myshopify.com). - An app. Every Admin API call is made by an app, even a script that only ever runs on your own store. The app gives you a client ID and client secret.
- The right access scopes. Each query and mutation needs a scope. For example,
productUpdateneedswrite_products. - An access token. Every request carries one in the
X-Shopify-Access-Tokenheader. How you get it depends on what you are building, which is the next section.
Getting a Shopify access token in .NET
Shopify's authentication docs describe three ways to get an access token. Pick the one that matches where your code runs:
| What you're building | How it gets a token | Good to know |
|---|---|---|
| A server-side job or integration on a store in your own Shopify organisation | Client credentials grant: your client ID and secret are swapped for a token | Only works when the app and the store belong to the same organisation. Tokens expire after 24 hours. |
| An app that runs outside the Shopify admin, such as a client's store | Authorisation code grant: the merchant approves access on Shopify, and your app swaps the returned code for a token | The classic OAuth install flow. |
| An embedded app inside the Shopify admin | Token exchange: your app swaps an ID token for an access token, with no redirect | The ID token itself never goes to the API. |
Two terms trip people up. An ID token, which older App Bridge docs call a session token,
is a short-lived JWT that proves a request to your backend came from a signed-in Shopify user. It expires one minute
after it's issued, carries no permissions, and
can't be used to
call a Shopify API. You validate it (HS256 signed with your client secret, aud equal to your client ID,
exp in the future and nbf in the past) and exchange it for an access token.
Access tokens are either online or offline. Online tokens last for a staff member's session, at most 24 hours. Offline tokens are the default and keep working when nobody is logged in, which is what background jobs need. Shopify's access token docs also describe expiring offline tokens: they last an hour, come with a refresh token that lasts 90 days, and have been required for public apps since 1 April 2026. Apps created on or after 1 December 2026 must use them. If you're building a public app, plan for refresh from day one.
Client credentials in C#
For your own store this is the simplest route. It's the honest answer to "can you use .NET for a personal Shopify
store?": yes, with an app in the same organisation and a few lines of C#. The
client
credentials grant is a form POST to /admin/oauth/access_token, and the answer holds the token and its
lifetime in seconds. This class caches the token and fetches a new one a minute before it runs out:
using System.Net.Http.Json;
using System.Text.Json;
public sealed class ShopifyTokenSource(HttpClient http, string shop, string clientId, string clientSecret)
{
private string? _token;
private DateTimeOffset _expires;
public async Task<string> GetAsync(CancellationToken ct = default)
{
if (_token != null && DateTimeOffset.UtcNow < _expires.AddSeconds(-60)) return _token;
var form = new FormUrlEncodedContent(new Dictionary<string, string>
{
["grant_type"] = "client_credentials",
["client_id"] = clientId,
["client_secret"] = clientSecret
});
using var res = await http.PostAsync($"https://{shop}.myshopify.com/admin/oauth/access_token", form, ct);
res.EnsureSuccessStatusCode();
var body = await res.Content.ReadFromJsonAsync<JsonElement>(ct);
_token = body.GetProperty("access_token").GetString()!;
_expires = DateTimeOffset.UtcNow.AddSeconds(body.GetProperty("expires_in").GetInt32());
return _token;
}
}
Keep the client secret out of your code: user secrets on your PC, and environment variables or a key vault on the
server. Shopify's docs say Shopify ignores a scope parameter on this call, so don't bother sending one.
Shopify API versions: which one to call
The API version is part of the URL. According to Shopify's versioning docs:
- Versions are named by date, such as
2026-10, and a new one is released every three months. - Each stable version is supported for at least 12 months.
- If you call a version that is no longer available, Shopify falls forward and answers with the oldest version that still is.
- Every response has an
X-Shopify-API-Versionheader showing the version that actually answered.
At the time of writing the latest stable version is 2026-10. Put the version in configuration rather than
code, and log a warning when the header doesn't match what you asked for. That is your early sign that an upgrade is
due.
GraphQL or REST?
GraphQL. Shopify's REST Admin API page says REST has been a legacy API since 1 October 2024, and that new public apps must be built only with the GraphQL Admin API from 1 April 2025. A lot of older C# examples online use REST endpoints, so check the date on anything you copy. Custom apps for a single store use the same Shopify API; I explain how those differ from public apps in what a custom Shopify app is.
Calling the Shopify GraphQL Admin API from C#
Every query and mutation is a POST to https://your-store.myshopify.com/admin/api/2026-10/graphql.json with
a JSON body holding the query and its variables. Here is a small client that sends a request, checks which version
answered, throws on GraphQL errors and slows down before the rate limit bucket runs dry (more on that below):
public sealed class ShopifyAdminClient(HttpClient http, ShopifyTokenSource tokens, string shop, string apiVersion)
{
public async Task<JsonElement> QueryAsync(string query, object? variables = null, CancellationToken ct = default)
{
var url = $"https://{shop}.myshopify.com/admin/api/{apiVersion}/graphql.json";
using var req = new HttpRequestMessage(HttpMethod.Post, url)
{
Content = JsonContent.Create(new { query, variables })
};
req.Headers.Add("X-Shopify-Access-Token", await tokens.GetAsync(ct));
using var res = await http.SendAsync(req, ct);
res.EnsureSuccessStatusCode();
if (res.Headers.TryGetValues("X-Shopify-API-Version", out var used) && used.First() != apiVersion)
Console.WriteLine($"Shopify answered with {used.First()}, not {apiVersion}. Time to upgrade.");
var json = await res.Content.ReadFromJsonAsync<JsonElement>(ct);
if (json.TryGetProperty("errors", out var errors))
throw new InvalidOperationException($"Shopify GraphQL error: {errors}");
await WaitIfBucketLowAsync(json, ct);
return json.GetProperty("data");
}
// Uses the cost figures Shopify returns with every response (see "Rate limits" below).
private static async Task WaitIfBucketLowAsync(JsonElement json, CancellationToken ct)
{
if (!json.TryGetProperty("extensions", out var ext) || !ext.TryGetProperty("cost", out var cost)) return;
var status = cost.GetProperty("throttleStatus");
var available = status.GetProperty("currentlyAvailable").GetDouble();
var restoreRate = status.GetProperty("restoreRate").GetDouble();
var nextCost = cost.GetProperty("requestedQueryCost").GetDouble();
if (available < nextCost)
await Task.Delay(TimeSpan.FromSeconds(Math.Ceiling((nextCost - available) / restoreRate)), ct);
}
}
Wiring it up is three lines. In an ASP.NET Core app you would register these with dependency injection and
IHttpClientFactory instead, but the classes don't change:
var http = new HttpClient();
var tokens = new ShopifyTokenSource(http, "your-store", clientId, clientSecret);
var shopify = new ShopifyAdminClient(http, tokens, "your-store", "2026-10");
I've kept the results as JsonElement so the examples stay short. In a real app, deserialise into your own
record types, which gives you the type safety that is one of the best reasons to use C# for this in the first place.
Paging through products with cursors
Lists in the GraphQL Admin API are connections, and they are paged with cursors, not page numbers. You ask for
first N items, and each page returns pageInfo with hasNextPage and
endCursor. To get the next page, pass that endCursor back as after. Shopify's
pagination docs put the maximum at
250 items per page.
const string ProductsQuery = """
query Products($cursor: String) {
products(first: 250, after: $cursor) {
nodes { id title }
pageInfo { hasNextPage endCursor }
}
}
""";
string? cursor = null;
do
{
var data = await shopify.QueryAsync(ProductsQuery, new { cursor });
var products = data.GetProperty("products");
foreach (var p in products.GetProperty("nodes").EnumerateArray())
Console.WriteLine($"{p.GetProperty("id").GetString()} {p.GetProperty("title").GetString()}");
var page = products.GetProperty("pageInfo");
cursor = page.GetProperty("hasNextPage").GetBoolean() ? page.GetProperty("endCursor").GetString() : null;
}
while (cursor != null);
On the first request cursor is null, and Shopify ignores the after argument, so you start at
the beginning. C# 11 raw string literals (the """ blocks) make GraphQL in C# far more readable than
escaped strings, and .NET 8 supports them out of the box.
Shopify GraphQL rate limits, in plain English
The GraphQL Admin API doesn't count requests. It counts cost points. Each app and store pair gets a bucket that refills at a rate set by the store's plan, and each query takes points out of it. From Shopify's GraphQL Admin rate limits page:
| Store plan | Points per second |
|---|---|
| Standard | 100 |
| Advanced Shopify | 200 |
| Shopify Plus | 1,000 |
| Shopify for enterprise (Commerce Components) | 2,000 |
- A single query can't cost more than 1,000 points, whatever the plan.
- By default an object costs 1 point, a scalar or enum field costs nothing, a mutation costs 10, and a connection
costs more the bigger your
firstorlast. - Every response includes
extensions.cost, withrequestedQueryCost,actualQueryCostand athrottleStatusholdingmaximumAvailable,currentlyAvailableandrestoreRate. That is whatWaitIfBucketLowAsyncabove reads.
If you do get throttled, Shopify's general rate limit guidance recommends backing off for one second. In practice, asking only for the fields you need is the best rate limit fix there is: a query for 250 products with three fields costs far less than one that pulls every variant, image and metafield as well.
Updating data: a mutation in C#
Mutations go through the same client. This one renames a product with
productUpdate,
which needs the write_products scope. Products are identified by global IDs such as
gid://shopify/Product/123, which is what the id field in the products query returns.
const string UpdateTitle = """
mutation UpdateTitle($product: ProductUpdateInput) {
productUpdate(product: $product) {
product { id title }
userErrors { field message }
}
}
""";
var result = await shopify.QueryAsync(UpdateTitle, new
{
product = new { id = "gid://shopify/Product/PRODUCT_ID", title = "Your new title" }
});
var userErrors = result.GetProperty("productUpdate").GetProperty("userErrors");
if (userErrors.GetArrayLength() > 0)
throw new InvalidOperationException($"Shopify rejected the update: {userErrors}");
Always ask for userErrors and check them. A mutation can come back without a top-level
errors block and still have refused the change, and userErrors is where Shopify tells you
which field was wrong and why.
Mistakes I see in Shopify C# code
- Hard-coding the API version and forgetting it. Twelve months later Shopify falls forward and the app is suddenly running against a version nobody tested.
- Sending the ID token to the Admin API. It is for your own backend only. Exchange it first.
- Treating every token as permanent. Client credentials tokens last 24 hours, online tokens at most 24 hours, and expiring offline tokens one hour. Cache them and refresh them.
- Asking for every field. Big queries burn rate limit points and slow everything down.
- Copying REST examples. REST is legacy. New public apps must use GraphQL.
- Secrets in source control. The client secret can mint tokens for your store. Treat it like a password.
The same rules apply when the thing calling the Shopify API is an AI feature: batch the work, respect the cost limit and never write to the store without a check. I go through how that works in a live app in Shopify AI app development: how I build AI apps with Claude. And badly behaved API code isn't only a back-office problem: apps that load heavy scripts on the storefront slow it down, as I explain in your Shopify apps are slowing down your store.

A production Shopify app on .NET 8
Intellify is one of my Shopify apps written in .NET 8 and C# on the Shopify Admin API. It reads products, collections, blog posts and pages, scores them with fixed rules and writes changes back only when the merchant clicks Apply, keeping every original value so each change can be undone.
When to hand it to a developer
A script that reads products from your own store is a good afternoon's work. A connector that keeps Shopify and an ERP, warehouse or accounts system in step, with webhooks, retries and nobody watching, is a different job. If that's what you need, my Shopify API and ERP integration service builds exactly that in .NET, and you can tell me about it here. Before you do, it's worth reading how much a Shopify developer costs and how to hire a Shopify app developer. My own apps, SmartTrade Pro and Schema Clinic included, are built on this same API from .NET.
Frequently asked questions
Can I use C# with the Shopify API?
Yes. The GraphQL Admin API is a single HTTPS endpoint that takes a POST with a JSON body,
so HttpClient and System.Text.Json in .NET 8 are enough. Only Shopify Functions need a
language that compiles to WebAssembly.
Is there an official Shopify .NET SDK?
No. Shopify's official libraries cover Ruby, Node.js, PHP and Python. ShopifySharp is a community .NET library that Shopify lists but doesn't maintain.
Which Shopify API version should I use?
The latest stable version, which was 2026-10 when I wrote this. A new version comes out every
three months and each is supported for at least 12 months, so keep the version in config and check the
X-Shopify-API-Version response header.
Should I use the REST or GraphQL Admin API from .NET?
GraphQL. REST has been a legacy API since 1 October 2024, and new public apps have had to use GraphQL only since 1 April 2025.
What is a Shopify session token?
It's the old name for an ID token: a JWT that lasts one minute and proves a request to your embedded app's backend came from a signed-in Shopify user. It can't call the Shopify API. Your app exchanges it for an access token.
How many requests can I make to the Shopify GraphQL API?
It's measured in cost points, not requests: 100 points a second on Standard plans, 200 on Advanced, 1,000 on Plus and 2,000 for enterprise, with no single query over 1,000 points.