Shopify API
#Shopify #JQuery #GraphQL
Storefront API
https://shopify.dev/docs/storefront-api/getting-started
X-Shopify-Storefront-Access-Token
アクセストークンでアクセス可能
GraphQL推奨
customer note以外の顧客情報はアップデートできる?
Customer Access Tokenがある
Customer用?
CustomerAccessToken
https://shopify.dev/api/storefront/reference/customers/customeraccesstokencreate
StoreFrontリファレンス
https://shopify.dev/api/storefront/reference
エンドポイント
https://shopify.dev/api/storefront/reference/customers/customeraddressupdate
mutation customerAddressUpdate($customerAccessToken: String!, $id: ID!, $address: MailingAddressInput!) {
基本inputにcustomerAccessTokenが必要
StorefrontAccessToken
ユーザー側の通常のアクセスをshopify外からでも使えるようにするもの?
token発行ページに以下の文言があった。
ストアフロントAPIのアクセストークンは公開されています。それらをJavaScriptファイルまたは任意のHTMLドキュメントに配置することができます。
customerAccessTokenCreate
https://shopify.dev/api/storefront/reference/customers/customeraccesstokencreate
unauthenticated_write_customersスコープが必要
https://shopify.dev/api/storefront/reference/common-objects/queryroot#customer-2020-10
customerを見つける
unauthenticated_write_customersスコープは不要
code:js
queryCustomer: `query ($token: String!) {
customer(customerAccessToken: $token) {
email
}
}`,
customerAccessTokenCreate
headerにstorefront_access_tokenが必要
emailとpasswordをinputにセット
Display dynamic store data with app proxies
Shopify Partner で作成
shopifyデータの表示用?
Liquidレスポンス
CORS警告無しでリクエストできる。
online store 2.0
スペックの増加
アプリがカプセル化される
GraphQL
queryシンタックス
https://shopify.dev/api/usage/search-syntax
Admin API
Graphql リファレンス
https://shopify.dev/docs/admin-api/graphql/reference
query root
https://shopify.dev/docs/admin-api/graphql/reference/common-objects/queryroot/index#connections-2020-10
トップレベル
https://shopify.dev/api/admin/graphql/reference/customers/customer
customer
スコープ: read_customers
Query
email:${eamil}
first
検索されたlistの内、最初の一つを取得
customer update
https://shopify.dev/api/admin/graphql/reference/customers/customerupdate
Ajax API
Cart
https://shopify.dev/api/ajax/reference/cart
/cart/update.js
現在のcartをアップデートするAPI
Cart Attributeなどをアップデート
code:js
{
attributes: {
'Gift wrap': 'Yes'
}
}
Jquery post
https://api.jquery.com/jquery.post/
その他
レスポンスコード
https://shopify.dev/api/usage/response-codes
どのAPI?
https://www.shopify.jp/blog/partner-shopify-app-development
Admin
PolarisでUIを作成。
Webhook