{"id":19946856,"url":"https://github.com/datainq/go-shopify","last_synced_at":"2026-05-09T12:37:35.390Z","repository":{"id":131066434,"uuid":"129246470","full_name":"datainq/go-shopify","owner":"datainq","description":"Shopify for Golang (mirror of getconversio/go-shopify)","archived":false,"fork":false,"pushed_at":"2018-04-12T12:54:09.000Z","size":107,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T14:17:36.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datainq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-12T12:18:56.000Z","updated_at":"2018-04-12T14:28:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"48343bda-4125-4234-9846-8c5d93145ecc","html_url":"https://github.com/datainq/go-shopify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/datainq/go-shopify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datainq%2Fgo-shopify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datainq%2Fgo-shopify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datainq%2Fgo-shopify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datainq%2Fgo-shopify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datainq","download_url":"https://codeload.github.com/datainq/go-shopify/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datainq%2Fgo-shopify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32819775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T00:33:03.615Z","updated_at":"2026-05-09T12:37:35.372Z","avatar_url":"https://github.com/datainq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-shopify\n\nAnother Shopify Api Library in Go.\n\n**Note**: The library does not have implementations of all Shopify resources, but it is being used in production by Conversio and should be stable for usage. PRs for new resources and endpoints are welcome, or you can simply implement some yourself as-you-go. See the section \"Using your own models\" for more info.\n\n[![Build Status](https://travis-ci.org/getconversio/go-shopify.svg?branch=master)](https://travis-ci.org/getconversio/go-shopify)\n[![codecov](https://codecov.io/gh/getconversio/go-shopify/branch/master/graph/badge.svg)](https://codecov.io/gh/getconversio/go-shopify)\n\n## Install\n\n```console\n$ go get github.com/getconversio/go-shopify\n```\n\n## Use\n\n```go\nimport \"github.com/getconversio/go-shopify\"\n```\n\nThis gives you access to the `goshopify` package.\n\n#### Oauth\n\nIf you don't have an access token yet, you can obtain one with the oauth flow.\nSomething like this will work:\n\n```go\n// Create an app somewhere.\napp := goshopify.App{\n    ApiKey: \"abcd\",\n    ApiSecret: \"efgh\",\n    RedirectUrl: \"https://example.com/shopify/callback\",\n    Scope: \"read_products,read_orders\",\n}\n\n// Create an oauth-authorize url for the app and redirect to it.\n// In some request handler, you probably want something like this:\nfunc MyHandler(w http.ResponseWriter, r *http.Request) {\n    shopName := r.URL.Query().Get(\"shop\")\n    authUrl := app.AuthorizeURL(shopName)\n    http.Redirect(w, r, authUrl, http.StatusFound)\n}\n\n// Fetch a permanent access token in the callback\nfunc MyCallbackHandler(w http.ResponseWriter, r *http.Request) {\n    // Check that the callback signature is valid\n    if !app.VerifyAuthorizationURL(r.URL) {\n        http.Error(w, \"Invalid Signature\", http.StatusUnauthorized)\n        return\n    }\n\n    query := r.URL.Query()\n    shopName := query.Get(\"shop\")\n    code := query.Get(\"code\")\n    token, err := app.GetAccessToken(shopName, code)\n\n    // Do something with the token, like store it in a DB.\n}\n```\n\n#### Api calls with a token\n\nWith a permanent access token, you can make API calls like this:\n\n```go\n// Create an app somewhere.\napp := goshopify.App{\n    ApiKey: \"abcd\",\n    ApiSecret: \"efgh\",\n    RedirectUrl: \"https://example.com/shopify/callback\",\n    Scope: \"read_products\",\n}\n\n// Create a new API client\nclient := goshopify.NewClient(app, \"shopname\", \"token\")\n\n// Fetch the number of products.\nnumProducts, err := client.Product.Count(nil)\n```\n\n#### Private App Auth\n\nPrivate Shopify apps use basic authentication and do not require going through the OAuth flow. Here is an example:\n\n```go\n// Create an app somewhere.\napp := goshopify.App{\n\tApiKey: \"apikey\",\n\tPassword: \"apipassword\",\n}\n\n// Create a new API client (notice the token parameter is the empty string)\nclient := goshopify.NewClient(app, \"shopname\", \"\")\n\n// Fetch the number of products.\nnumProducts, err := client.Product.Count(nil)\n```\n\n#### Query options\n\nMost API functions take an options `interface{}` as parameter. You can use one\nfrom the library or create your own. For example, to fetch the number of\nproducts created after January 1, 2016, you can do:\n\n```go\n// Create standard CountOptions\ndate := time.Date(2016, time.January, 1, 0, 0, 0, 0, time.UTC)\noptions := goshopify.CountOptions{createdAtMin: date}\n\n// Use the options when calling the API.\nnumProducts, err := client.Product.Count(options)\n```\n\nThe options are parsed with Google's\n[go-querystring](https://github.com/google/go-querystring) library so you can\nuse custom options like this:\n\n```go\n// Create custom options for the orders.\n// Notice the `url:\"status\"` tag\noptions := struct {\n    Status string `url:\"status\"`\n}{\"any\"}\n\n// Fetch the order count for orders with status=\"any\"\norderCount, err := client.Order.Count(options)\n```\n\n#### Using your own models\n\nNot all endpoints are implemented right now. In those case, feel free to\nimplement them and make a PR, or you can create your own struct for the data\nand use `NewRequest` with the API client. This is how the existing endpoints\nare implemented.\n\nFor example, let's say you want to fetch webhooks. There's a helper function\n`Get` specifically for fetching stuff so this will work:\n\n```go\n// Declare a model for the webhook\ntype Webhook struct {\n    ID int         `json:\"id\"`\n    Address string `json:\"address\"`\n}\n\n// Declare a model for the resource root.\ntype WebhooksResource struct {\n    Webhooks []Webhook `json:\"webhooks\"`\n}\n\nfunc FetchWebhooks() ([]Webhook, error) {\n    path := \"admin/webhooks.json\"\n    resource := new(WebhooksResoure)\n    client := goshopify.NewClient(app, \"shopname\", \"token\")\n\n    // resource gets modified when calling Get\n    err := client.Get(path, resource, nil)\n\n    return resource.Webhooks, err\n}\n```\n\n#### Webhooks verification\n\nIn order to be sure that a webhook is sent from ShopifyApi you could easily verify\nit with the `VerifyWebhookRequest` method.\n\nFor example:\n```go\nfunc ValidateWebhook(httpRequest *http.Request) (bool) {\n    shopifyApp := goshopify.App{ApiSecret: \"ratz\"}\n    return shopifyApp.VerifyWebhookRequest(httpRequest)\n}\n```\n\n## Develop and test\n\nThere's nothing special to note about the tests except that if you have Docker\nand Compose installed, you can test like this:\n\n    $ docker-compose build dev\n    $ docker-compose run --rm dev\n\nTesting the package is the default command for the dev container. To create a\ncoverage profile:\n\n    $ docker-compose run --rm dev bash -c 'go test -coverprofile=coverage.out ./... \u0026\u0026 go tool cover -html coverage.out -o coverage.html'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatainq%2Fgo-shopify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatainq%2Fgo-shopify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatainq%2Fgo-shopify/lists"}