Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Golang wrapper for the WooCommerce API.

License

NotificationsYou must be signed in to change notification settings

darh/wc-api-golang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Golang wrapper for the WooCommerce REST API. Easily interact with the WooCommerce REST API using this library.This is a fork ofmikespook/wc-api-golang. Main difference: get/post/put/delete accepts context and package useshttp.DefaultClient andhttp.DefaultTransport.

This lib isnot backward compatible with mikespook/wc-api-golang`!

Installation

$ go get github.com/darh/wc-api-golang/woocommerce

Getting started

Generate API credentials (Consumer Key & Consumer Secret) following this instructionshttp://docs.woocommerce.com/document/woocommerce-rest-api/.

Check out the WooCommerce API endpoints and data that can be manipulated inhttps://woocommerce.github.io/woocommerce-rest-api-docs/.

Setup

Setup for the new WP REST API integration (WooCommerce 2.6 or later):

import (  wc"github.com/darh/wc-api-golang/woocommerce")varwoocommerce=wc.NewClient("http://example.com","ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",&wc.Options {API:true,Version:"wc/v1",    },);

Paramaters

OptionTypeDescription
storestringYour Store URL, example:http://woo.dev/
ckstringYour API consumer key
csstringYour API consumer secret
options*wc.OptionsExtra arguments (see client options table)

Client options

OptionTypeDescription
APIboolAllow make requests to the new WP REST API integration (WooCommerce 2.6 or later)
APIPrefixstringCustom WP REST API URL prefix, used to support custom prefixes created with therest_url_prefix filter
VersionstringAPI version, default isv3
Timeouttime.DurationRequest timeout, default is15
VerifySSLboolVerify SSL when connect, use this option asfalse when need to test with self-signed certificates, default istrue
QueryStringAuthboolForce Basic Authentication as query string whentrue and using under HTTPS, default isfalse
OauthTimestamptime.TimeCustom oAuth timestamp, default istime.Now()

Methods

ParamsTypeDescription
endpointstringWooCommerce API endpoint, example:customers ororder/12
datainterface{}Only for POST and PUT, data that will be converted to JSON
parametersurl.ValuesOnly for GET and DELETE, request query string

GET

rc,err:=woocommerce.Get(ctx,endpoint,parameters)

POST

rc,err:=woocommerce.Post(ctx,endpoint,data)

PUT

rc,err:=woocommerce.Put(ctx,endpoint,data)

DELETE

rc,err:=woocommerce.Delete(ctx,endpoint,parameters)

OPTIONS

rc,err:=woocommerce.Options(ctx,endpoint)

Response

All methods will return aio.ReadCloser andnil on success or anerror on failure.

Release History

About

A Golang wrapper for the WooCommerce API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go100.0%

[8]ページ先頭

©2009-2025 Movatter.jp