Skip to content

Get started with ShopifySharp

ShopifySharp is a .NET library that helps developers like you build custom Shopify apps using C#, .NET and GraphQL. It handles the tricky parts of OAuth, authentication and request validation for you, so you can quickly get up and running with Shopify’s API.

This package supports Shopify’s GraphQL API, along with the (now deprecated) Rest API. For the GraphQL API, types are pre-generated from Shopify’s GraphQL schema and provided as serialization/deserialization targets for your queries and mutations. The library also provides fully-typed fluent query builders for every query and mutation in Shopify’s schema, built-in request execution policies to handle Shopify’s API rate limits, and an optional companion library to support dependency injection.

ShopifySharp supports .NET 10, .NET Standard 2.0 and .NET Framework 4.7.2.

Install the ShopifySharp NuGet package:

Install via dotnet CLI
dotnet add package ShopifySharp

And optionally install the Dependency Injection package:

Install via dotnet CLI
dotnet add package ShopifySharp.Extensions.DependencyInjection
Calling Shopify's GraphQL API
var credentials = new ShopifyApiCredentials("example.myshopify.com", "some-access-token");
var service = new GraphService(credentials);
var request = new GraphRequest
{
Query = """
query listProducts($limit: Int!, $query: String!) {
products(first: $limit, query: $query) {
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
nodes {
id
title
handle
hasOnlyDefaultVariant
variantsCount {
count
}
}
}
}
""",
Variables = new Dictionary<string, object>
{
{"limit", 3},
{"query", "status:" + ProductStatus.ACTIVE}
}
};
var listProductsResult = await graphService.PostAsync<ListProductsResult>(graphRequest);

Not sure where to start? Here’s what I recommend: