/go-etsyv3

Primary LanguageShell

Go API client for openapi

Etsy's Open API provides a simple RESTful interface for various Etsy.com features. The API endpoints are meant to replace Etsy's Open API v2, which is scheduled to end service in 2022.

All of the endpoints are callable and the majority of the API endpoints are now in a beta phase. This means we do not expect to make any breaking changes before our general release. A handful of endpoints are currently interface stubs (labeled “Feedback Only”) and returns a \"501 Not Implemented\" response code when called.

If you'd like to report an issue or provide feedback on the API design, please add an issue in Github.

© 2021-2023 Etsy, Inc. All Rights Reserved. Use of this code is subject to Etsy's API Developer Terms of Use.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 3.0.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/l4u/go-etsyv3"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://openapi.etsy.com

Class Method HTTP request Description
BuyerTaxonomyApi GetBuyerTaxonomyNodes Get /v3/application/buyer-taxonomy/nodes
BuyerTaxonomyApi GetPropertiesByBuyerTaxonomyId Get /v3/application/buyer-taxonomy/nodes/{taxonomy_id}/properties
LedgerEntryApi GetShopPaymentAccountLedgerEntries Get /v3/application/shops/{shop_id}/payment-account/ledger-entries
LedgerEntryApi GetShopPaymentAccountLedgerEntry Get /v3/application/shops/{shop_id}/payment-account/ledger-entries/{ledger_entry_id}
OtherApi Ping Get /v3/application/openapi-ping
OtherApi TokenScopes Post /v3/application/scopes
PaymentApi GetPaymentAccountLedgerEntryPayments Get /v3/application/shops/{shop_id}/payment-account/ledger-entries/payments
PaymentApi GetPayments Get /v3/application/shops/{shop_id}/payments
PaymentApi GetShopPaymentByReceiptId Get /v3/application/shops/{shop_id}/receipts/{receipt_id}/payments
ReviewApi GetReviewsByListing Get /v3/application/listings/{listing_id}/reviews
ReviewApi GetReviewsByShop Get /v3/application/shops/{shop_id}/reviews
SellerTaxonomyApi GetPropertiesByTaxonomyId Get /v3/application/seller-taxonomy/nodes/{taxonomy_id}/properties
SellerTaxonomyApi GetSellerTaxonomyNodes Get /v3/application/seller-taxonomy/nodes
ShopApi FindShops Get /v3/application/shops
ShopApi GetShop Get /v3/application/shops/{shop_id}
ShopApi GetShopByOwnerUserId Get /v3/application/users/{user_id}/shops
ShopApi UpdateShop Put /v3/application/shops/{shop_id}
ShopListingApi CreateDraftListing Post /v3/application/shops/{shop_id}/listings
ShopListingApi DeleteListing Delete /v3/application/listings/{listing_id}
ShopListingApi DeleteListingProperty Delete /v3/application/shops/{shop_id}/listings/{listing_id}/properties/{property_id}
ShopListingApi FindAllActiveListingsByShop Get /v3/application/shops/{shop_id}/listings/active
ShopListingApi FindAllListingsActive Get /v3/application/listings/active
ShopListingApi GetFeaturedListingsByShop Get /v3/application/shops/{shop_id}/listings/featured
ShopListingApi GetListing Get /v3/application/listings/{listing_id}
ShopListingApi GetListingProperties Get /v3/application/shops/{shop_id}/listings/{listing_id}/properties
ShopListingApi GetListingProperty Get /v3/application/listings/{listing_id}/properties/{property_id}
ShopListingApi GetListingsByListingIds Get /v3/application/listings/batch
ShopListingApi GetListingsByShop Get /v3/application/shops/{shop_id}/listings
ShopListingApi GetListingsByShopReceipt Get /v3/application/shops/{shop_id}/receipts/{receipt_id}/listings
ShopListingApi GetListingsByShopReturnPolicy Get /v3/application/shops/{shop_id}/policies/return/{return_policy_id}/listings
ShopListingApi GetListingsByShopSectionId Get /v3/application/shops/{shop_id}/shop-sections/listings
ShopListingApi UpdateListing Patch /v3/application/shops/{shop_id}/listings/{listing_id}
ShopListingApi UpdateListingDeprecated Put /v3/application/shops/{shop_id}/listings/{listing_id}
ShopListingApi UpdateListingProperty Put /v3/application/shops/{shop_id}/listings/{listing_id}/properties/{property_id}
ShopListingFileApi DeleteListingFile Delete /v3/application/shops/{shop_id}/listings/{listing_id}/files/{listing_file_id}
ShopListingFileApi GetAllListingFiles Get /v3/application/shops/{shop_id}/listings/{listing_id}/files
ShopListingFileApi GetListingFile Get /v3/application/shops/{shop_id}/listings/{listing_id}/files/{listing_file_id}
ShopListingFileApi UploadListingFile Post /v3/application/shops/{shop_id}/listings/{listing_id}/files
ShopListingImageApi DeleteListingImage Delete /v3/application/shops/{shop_id}/listings/{listing_id}/images/{listing_image_id}
ShopListingImageApi GetListingImage Get /v3/application/listings/{listing_id}/images/{listing_image_id}
ShopListingImageApi GetListingImageDeprecated Get /v3/application/shops/{shop_id}/listings/{listing_id}/images/{listing_image_id}
ShopListingImageApi GetListingImages Get /v3/application/listings/{listing_id}/images
ShopListingImageApi GetListingImagesDeprecated Get /v3/application/shops/{shop_id}/listings/{listing_id}/images
ShopListingImageApi UploadListingImage Post /v3/application/shops/{shop_id}/listings/{listing_id}/images
ShopListingInventoryApi GetListingInventory Get /v3/application/listings/{listing_id}/inventory
ShopListingInventoryApi UpdateListingInventory Put /v3/application/listings/{listing_id}/inventory
ShopListingOfferingApi GetListingOffering Get /v3/application/listings/{listing_id}/products/{product_id}/offerings/{product_offering_id}
ShopListingProductApi GetListingProduct Get /v3/application/listings/{listing_id}/inventory/products/{product_id}
ShopListingTranslationApi CreateListingTranslation Post /v3/application/shops/{shop_id}/listings/{listing_id}/translations/{language}
ShopListingTranslationApi GetListingTranslation Get /v3/application/shops/{shop_id}/listings/{listing_id}/translations/{language}
ShopListingTranslationApi UpdateListingTranslation Put /v3/application/shops/{shop_id}/listings/{listing_id}/translations/{language}
ShopListingVariationImageApi GetListingVariationImages Get /v3/application/shops/{shop_id}/listings/{listing_id}/variation-images
ShopListingVariationImageApi UpdateVariationImages Post /v3/application/shops/{shop_id}/listings/{listing_id}/variation-images
ShopListingVideoApi DeleteListingVideo Delete /v3/application/shops/{shop_id}/listings/{listing_id}/videos/{video_id}
ShopListingVideoApi GetListingVideo Get /v3/application/listings/{listing_id}/videos/{video_id}
ShopListingVideoApi GetListingVideos Get /v3/application/listings/{listing_id}/videos
ShopListingVideoApi UploadListingVideo Post /v3/application/shops/{shop_id}/listings/{listing_id}/videos
ShopProductionPartnerApi GetShopProductionPartners Get /v3/application/shops/{shop_id}/production-partners
ShopReceiptApi CreateReceiptShipment Post /v3/application/shops/{shop_id}/receipts/{receipt_id}/tracking
ShopReceiptApi GetShopReceipt Get /v3/application/shops/{shop_id}/receipts/{receipt_id}
ShopReceiptApi GetShopReceipts Get /v3/application/shops/{shop_id}/receipts
ShopReceiptApi UpdateShopReceipt Put /v3/application/shops/{shop_id}/receipts/{receipt_id}
ShopReceiptTransactionsApi GetShopReceiptTransaction Get /v3/application/shops/{shop_id}/transactions/{transaction_id}
ShopReceiptTransactionsApi GetShopReceiptTransactionsByListing Get /v3/application/shops/{shop_id}/listings/{listing_id}/transactions
ShopReceiptTransactionsApi GetShopReceiptTransactionsByReceipt Get /v3/application/shops/{shop_id}/receipts/{receipt_id}/transactions
ShopReceiptTransactionsApi GetShopReceiptTransactionsByShop Get /v3/application/shops/{shop_id}/transactions
ShopReturnPolicyApi ConsolidateShopReturnPolicies Post /v3/application/shops/{shop_id}/policies/return/consolidate
ShopReturnPolicyApi CreateShopReturnPolicy Post /v3/application/shops/{shop_id}/policies/return
ShopReturnPolicyApi DeleteShopReturnPolicy Delete /v3/application/shops/{shop_id}/policies/return/{return_policy_id}
ShopReturnPolicyApi GetShopReturnPolicies Get /v3/application/shops/{shop_id}/policies/return
ShopReturnPolicyApi GetShopReturnPolicy Get /v3/application/shops/{shop_id}/policies/return/{return_policy_id}
ShopReturnPolicyApi UpdateShopReturnPolicy Put /v3/application/shops/{shop_id}/policies/return/{return_policy_id}
ShopSectionApi CreateShopSection Post /v3/application/shops/{shop_id}/sections
ShopSectionApi DeleteShopSection Delete /v3/application/shops/{shop_id}/sections/{shop_section_id}
ShopSectionApi GetShopSection Get /v3/application/shops/{shop_id}/sections/{shop_section_id}
ShopSectionApi GetShopSections Get /v3/application/shops/{shop_id}/sections
ShopSectionApi UpdateShopSection Put /v3/application/shops/{shop_id}/sections/{shop_section_id}
ShopShippingProfileApi CreateShopShippingProfile Post /v3/application/shops/{shop_id}/shipping-profiles
ShopShippingProfileApi CreateShopShippingProfileDestination Post /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/destinations
ShopShippingProfileApi CreateShopShippingProfileUpgrade Post /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/upgrades
ShopShippingProfileApi DeleteShopShippingProfile Delete /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}
ShopShippingProfileApi DeleteShopShippingProfileDestination Delete /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/destinations/{shipping_profile_destination_id}
ShopShippingProfileApi DeleteShopShippingProfileUpgrade Delete /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/upgrades/{upgrade_id}
ShopShippingProfileApi GetShippingCarriers Get /v3/application/shipping-carriers
ShopShippingProfileApi GetShopShippingProfile Get /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}
ShopShippingProfileApi GetShopShippingProfileDestinationsByShippingProfile Get /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/destinations
ShopShippingProfileApi GetShopShippingProfileUpgrades Get /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/upgrades
ShopShippingProfileApi GetShopShippingProfiles Get /v3/application/shops/{shop_id}/shipping-profiles
ShopShippingProfileApi UpdateShopShippingProfile Put /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}
ShopShippingProfileApi UpdateShopShippingProfileDestination Put /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/destinations/{shipping_profile_destination_id}
ShopShippingProfileApi UpdateShopShippingProfileUpgrade Put /v3/application/shops/{shop_id}/shipping-profiles/{shipping_profile_id}/upgrades/{upgrade_id}
UserApi GetMe Get /v3/application/users/me
UserApi GetUser Get /v3/application/users/{user_id}
UserAddressApi DeleteUserAddress Delete /v3/application/user/addresses/{user_address_id}
UserAddressApi GetUserAddress Get /v3/application/user/addresses/{user_address_id}
UserAddressApi GetUserAddresses Get /v3/application/user/addresses

Documentation For Models

Documentation For Authorization

api_key

  • Type: API key
  • API key parameter name: x-api-key
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: x-api-key and passed in as the auth context for each request.

oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://www.etsy.com/oauth/connect
  • Scopes:
  • address_r: see billing and shipping addresses
  • address_w: update billing and shipping addresses
  • billing_r: see all billing statement data
  • cart_r: read shopping carts
  • cart_w: add/remove from shopping carts
  • email_r: Read a member's email address
  • favorites_r: see private favorites
  • favorites_w: add/remove favorites
  • feedback_r: see purchase info in feedback
  • listings_d: delete listings
  • listings_r: see all listings (including expired etc)
  • listings_w: create/edit listings
  • profile_r: see all profile data
  • profile_w: update user profile, avatar, etc
  • recommend_r: see recommended listings
  • recommend_w: accept/reject recommended listings
  • shops_r: see private shop info
  • shops_w: update shop
  • transactions_r: see all checkout/payment data
  • transactions_w: update receipts

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

developers@etsy.com