Idiomatic Shopify API client & app helper in Go
Initialize an api client and fetch products
import (
"github.com/boourns/go_shopify"
)
func main() {
api = shopify.API{
Shop: "shopname.myshopify.com",
Token: "(api client token)",
Secret: "(api client secret for this shop)",
}
products := api.Products()
// or
product := api.Product(12345)
}
Create a new Product
product := api.NewProduct()
product.Title = "T-shirt"
product.PublishedAt = time.Now()
product.ProductType = "shirts"
err := product.Save()
if err != nil {
fmt.Printf("Error saving product: %s", err)
}
fmt.Printf("New product ID is: %d\n", product.Id)
App example See https://github.com/boourns/go_shopify/blob/master/example/main.go for an example Shopify application that handles oauth install flow, can serve admin and storefront proxy requests.
- App install flow (see example/main.go)
- Check signatures for admin and API proxy requests coming from Shopify
- store session for users
- store API keys for installed shops
- API client doesn't support all endpoints, or all actions, yet.