1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Storefront API client for Shopify.
//!
//! This module provides clients for interacting with the Shopify Storefront API,
//! which is used for building custom storefronts and headless commerce applications.
//!
//! # Overview
//!
//! The main types in this module are:
//!
//! - [`StorefrontClient`]: The GraphQL client for Storefront API operations
//! - [`StorefrontToken`]: Token type for Storefront API authentication
//!
//! # Storefront vs Admin API
//!
//! The Storefront API differs from the Admin API in several key ways:
//!
//! - **Endpoint**: Uses `/api/{version}/graphql.json` (no `/admin` prefix)
//! - **Authentication**: Uses different headers depending on token type:
//! - Public: `X-Shopify-Storefront-Access-Token`
//! - Private: `Shopify-Storefront-Private-Token`
//! - **Access Level**: Limited to storefront data (products, collections, cart)
//! - **Tokenless Access**: Supports unauthenticated access for basic features
//!
//! # Token Types
//!
//! The Storefront API supports two types of access tokens:
//!
//! - **Public tokens**: Safe for client-side use, limited access
//! - **Private tokens**: Server-side only, elevated access
//!
//! # Tokenless Access
//!
//! Some Storefront API operations can be performed without authentication:
//! - Product and collection queries
//! - Cart operations
//! - Search queries
//!
//! To use tokenless access, pass `None` as the token parameter.
//!
//! # Example
//!
//! ```rust,ignore
//! use shopify_sdk::{StorefrontClient, StorefrontToken, ShopDomain};
//! use serde_json::json;
//!
//! // Create a shop domain
//! let shop = ShopDomain::new("my-store").unwrap();
//!
//! // With a public token
//! let token = StorefrontToken::Public("public-access-token".to_string());
//! let client = StorefrontClient::new(&shop, Some(token), None);
//!
//! // Query products
//! let response = client.query(
//! "query { products(first: 10) { edges { node { title } } } }",
//! None,
//! None,
//! None
//! ).await?;
//!
//! // Tokenless access for basic features
//! let client = StorefrontClient::new(&shop, None, None);
//! let response = client.query(
//! "query { shop { name } }",
//! None,
//! None,
//! None
//! ).await?;
//! ```
pub use StorefrontClient;
pub use StorefrontToken;