Library / SDK
ArtisanCloud/PowerWeChat avatar
ArtisanCloud/PowerWeChat

PowerWeChat: a Go SDK that hides the crypto inside every WeChat API call

PowerWechat是一款基于WeChat SDK for Golang,支持小程序、微信支付、企业微信、公众号等全微信生态

1,825 stars261 forksGoMIT

At a glance

What is it?
PowerWeChat is a Go framework covering the WeChat ecosystem, from mini programs and WeCom to official accounts and WeChat Pay, and its selling point is that the AES encryption, RSA signing and callback decryption are handled for you. The trade-off is a large dependency surface and an API surface that has already broken once between v2 and v3.
Who is it for?
Adopt PowerWeChat when you are building a Go service on top of WeChat mini programs, official accounts, WeCom or WeChat Pay and you would rather not implement the encryption, signing and notification decryption yourself. Do not adopt it if you need a thin, dependency-light client, since it pulls in PowerLibs, PowerSocialite, a Redis client and a websocket library.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem it removes: crypto at the edge of every WeChat call

Working against the WeChat API in Go is not mostly about HTTP calls. It is about the surrounding protocol work. The project states its purpose plainly: it exists to reduce the difficulty of getting started with WeChat development so that users only need to care about using the API, and not about the AES encryption and decryption, the signing, the verification, or the encrypting and decrypting of callback notifications that the underlying WeChat development requires.

Those are not optional extras. WeChat Pay signs requests and encrypts callbacks, official account messages can arrive encrypted, and mini program sessions are exchanged for tokens that have to be refreshed on a schedule. Getting any of it wrong is a bug that looks like a platform error rather than a bug in your code.

The audience is Go developers shipping a service that talks to WeChat: a mini program backend, an official account service, a WeCom integration or a payment service. It is a single framework covering the whole ecosystem rather than a set of small libraries, and the project describes itself as covering mini programs, WeCom and WeChat Pay, with official accounts among the documented areas as well.

The framework also does the unglamorous work of keeping strongly typed wrappers over most of the interface, which the project lists as one of its features alongside complete test projects that support web API testing.

The layout: one package per WeChat surface over a shared kernel

The repository is a single Go module with a src/ directory at its centre. The top-level entries are main.go, go.mod, go.sum, a Makefile, a resource/ directory, a test/ directory, an .env.local.example file, an .editorconfig and a .github/ directory holding the build and test workflows. The README carries separate build and test badges for the project, which tells you the CI story is a first class concern rather than an afterthought.

The naming of the packages maps onto the WeChat products, and the import path in the quick start example is the clearest evidence of the shape:

go
import (
	"github.com/ArtisanCloud/PowerWeChat/v3/src/miniProgram"
	"os"
)

So the module is github.com/ArtisanCloud/PowerWeChat/v3, and the mini program client lives under src/miniProgram. The documented API navigation follows the same partition, with separate areas for official accounts (basic interfaces, server side, messages, broadcasting, user tags, web authorisation, JSSDK, QR codes, media, menus, cards, customer service, data statistics, auto reply and comment management), the open platform, mini programs (user information, statistics, service and uniform messages, plugin management, mini program codes, message decryption, content security, biometric verification, subscription messages, live, risk control and URL Scheme) and WeChat Pay (orders, refunds, statements, notifications, red pack v2, JSSDK and enterprise payments v2).

Beneath those sits a shared kernel directory, src/kernel/support, which is where the cryptographic primitives live.

Installing the module and making a first session call

The module is a normal Go module, so the install is the standard get command:

bash
go get -u github.com/ArtisanCloud/PowerWeChat/v3

The path ends in /v3, which is the Go convention for a major version. A project that has been on the v2 line cannot simply bump the import path, and that matters for the upgrade described later.

The quick start then shows a two step flow. You construct a client for the WeChat product you are working with, passing a configuration struct that carries the app identifier and the secret, and both are read from environment variables in the example, with the names miniprogram_app_id and miniprogram_secret. The configuration struct also carries two switches, HttpDebug and Debug, which the example sets to true and false respectively.

The second step is the actual call. The mini program client exposes an Auth namespace, and the session method exchanges the one-time code that the mini program front end obtained from WeChat:

go
rs, err := app.Auth.Session(code)

The response carries the OpenID, which the example prints. One small thing to note if you copy the example: it calls printf(rs.OpenID) without importing the fmt package, so that line will not compile as written. The documentation site and the companion tutorial repository are where the fuller examples live.

The environment variables are the pattern to follow for anything beyond a demo, since a WeChat app secret in source code is a credential leak waiting to happen.

The kernel support layer and the tests that guard it

The cryptographic work lives in src/kernel/support, and the Makefile gives it its own test target. The four pairs of files it exercises are worth naming, because they tell you what the framework considers its own responsibility:

bash
	go test -v src/kernel/support/aes.go src/kernel/support/aes_test.go
	go test -v src/kernel/support/helper.go src/kernel/support/helper_test.go
	go test -v src/kernel/support/rsa_oaep.go src/kernel/support/rsa_oaep_test.go
	go test -v src/kernel/support/signer.go src/kernel/support/signer_test.go

AES for payload encryption, a helper module, RSA OAEP for the asymmetric operations WeChat uses, and a signer for request signatures. That is the whole list of primitives, and they are unit tested in isolation.

The Makefile goes further and has targets per product area: test-message, test-external-contact, test-external-contact-message, test-media and test-payment. Each of those runs a set of files under test/featureUnit, so there is a functional test harness for messages, external contacts, media and payment alongside the unit tests.

Two things stand out. The default target is test: test-kernel-support, so a bare make run only checks the kernel. And the product level tests are named after the WeChat surfaces they cover, which means a new API in the WeChat platform is only covered once someone writes the corresponding test file.

The v2 to v3 break: context parameters and a token refresh fix

The project documents its own upgrade path from v2 to v3, and there are only two entries in the list, which is a relief compared with the usual large major version churn.

The first is that interface methods gained a context parameter. This is the standard Go idiom for cancellation and deadlines, and it is the right change, but it is a source breaking change for every call site, and it means a v2 codebase cannot be upgraded by changing an import path alone. The second entry is a fix for an automatic token refresh problem in v2, so applications that were relying on the framework to keep an access token alive were working around a defect that v3 removes.

The version numbering is where the operational cost shows up. The releases are v3.4.56 on 2026-10-14, v3.4.45 on 2026-08-29 and v3.4.44 on 2026-08-28, so the patch number moves quickly, and the default branch is named release/3.4.0 rather than main. A branch named after a point release means the repository's own default branch is a maintenance line, and a team that tracks the default branch is taking the patch stream for a specific minor version rather than the newest work.

The practical advice is to pin an exact version in go.mod and read the release notes for the range you skip, since the difference between v3.4.44 and v3.4.56 is twelve patch releases.

The dependency chain you are taking on

The go.mod file is short and readable, and it tells you what the framework leans on:

go
require (
	github.com/ArtisanCloud/PowerLibs/v3 v3.3.2
	github.com/ArtisanCloud/PowerSocialite/v3 v3.0.11
	github.com/go-playground/assert/v2 v2.0.1
	github.com/gorilla/websocket v1.5.3
	github.com/pkg/errors v0.9.1
	github.com/redis/go-redis/v9 v9.6.3
	github.com/stretchr/testify v1.9.0
)

Two of these are from the same author, and they are the substantive ones. PowerLibs is the shared utility layer the framework builds on, and PowerSocialite is a sibling library from the same author, though its exact role is not described in the documentation. Both are versioned in the same major scheme, so they are released in step with PowerWeChat.

Then there is a Redis client, which points to a design where access tokens and cached state live in Redis rather than in process memory. That is the right call for a multi instance service, and it also means Redis is a runtime dependency of anything that uses token caching, not just an optional extra.

A websocket library covers the message and notification callbacks that arrive as pushed events rather than as request responses. The module targets go 1.23.0, and the file also carries commented out replace directives for PowerLibs and PowerSocialite pointing at local paths, which tells you the author develops against local checkouts of the sibling projects.

The go.mod also shows a fair number of indirect dependencies, including OpenTelemetry, zap, golang.org/x/crypto and yaml libraries, so the transitive footprint of a WeChat backend using this SDK is considerably larger than the seven direct requirements suggest.

Licence, documentation and where the framework stops helping

The project is released under the MIT licence, so the code can be used in commercial products and modified, with the notice retained. That is a permissive licence and it does not obligate you to publish changes back.

The repository is not archived and the last push was on 2026-10-14, the same day as the v3.4.56 tag, so the code in the tree matches the current release. The v3.4.45 and v3.4.44 tags fall on 2026-08-29 and 2026-08-28, so a burst of patch releases in late August was followed by a gap of about six weeks.

Documentation is the project's other contribution. There is a full documentation site at powerwechat.artisan-cloud.com with a start page and an API navigation split by product, a separate tutorial repository that covers the common interfaces, and a set of video tutorials on Bilibili covering the quick start, the framework design, and the use of official accounts, mini programs and WeCom. For a platform with this much surface area, that documentation effort is what makes the SDK usable at all.

The limits are equally clear. The framework is specific to WeChat, so it is the wrong tool if you need one SDK across several messaging platforms, and the strength of the typing is incomplete, since the project claims strong typing for most interfaces rather than all of them, so expect unstructured map responses in the gaps. The dependency on a Redis instance for token handling is a real operational cost for a small service. And the patch release cadence, combined with a default branch named after a maintenance line, means you have to manage versions yourself rather than assume a stable major line.

Editorial conclusion

Adopt PowerWeChat when you are building a Go service on top of WeChat mini programs, official accounts, WeCom or WeChat Pay and you would rather not implement the encryption, signing and notification decryption yourself. Do not adopt it if you need a thin, dependency-light client, since it pulls in PowerLibs, PowerSocialite, a Redis client and a websocket library. Before you commit, check that the API you need has a strongly typed wrapper, since the documentation admits coverage is incomplete, and read the v2 to v3 change notes, because the context parameter change and the token refresh fix will touch every call site you port.

Frequently asked questions

How do I install PowerWeChat in a Go project?

It is a standard Go module, so you add it with go get -u github.com/ArtisanCloud/PowerWeChat/v3. The import path carries the /v3 major version suffix, so the v2 import path has to be replaced rather than upgraded in place.

Which WeChat products does PowerWeChat cover?

The framework covers mini programs, WeCom, WeChat Pay and official accounts, with the API documentation split into those areas. The open platform is also documented, with pages for concepts, application scenarios, server side work and authorised party delegation.

What does PowerWeChat handle for me?

The project states its goal is that users only need to care about using the API, not the AES encryption and decryption, signing, verification, or the encrypting and decrypting of callback notifications that WeChat development normally requires.

What changed when moving from v2 to v3?

The documented changes are that interface methods gained a context parameter and that an automatic token refresh problem in v2 was solved. The context change is a source breaking change, so every call site has to be updated.

Does PowerWeChat need Redis?

The go.mod file includes the github.com/redis/go-redis/v9 client as a direct dependency, which is consistent with the framework keeping access tokens and cached state in Redis rather than in process memory. There is also a sibling project, PowerSocialite, which supplies the social login flows.

Official sources

  1. ArtisanCloud/PowerWeChat on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/artisancloud-powerwechat.svg)](https://hysenlabs.com/projects/artisancloud-powerwechat)

Was this useful?