Discovery needs no key. Ratings and market analysis are Pro.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. See our Privacy Policy and
Terms.
openapi: 3.2.0
info:
title: WeChat Mini Program Server API (subset) Access Token API
description: 'Subset OpenAPI description for the WeChat (Weixin) Mini Programs server-side
API hosted at `api.weixin.qq.com`.'
version: 1.0.0
contact:
name: WeChat Developer Community
url: https://developers.weixin.qq.com/community/
license:
name: Proprietary
servers:
- url: https://api.weixin.qq.com
description: WeChat production API
tags:
- name: Access Token
description: Application-level access token management.
paths:
/cgi-bin/token:
get:
tags:
- Access Token
summary: auth.getAccessToken
description: 'Obtain the global application `access_token` for a Mini Program.
Returned tokens are valid for 7200 seconds and must be cached and
re-used across the application; concurrent calls will overwrite each
other.'
operationId: getAccessToken
parameters:
- in: query
name: grant_type
required: true
schema:
type: string
enum:
- client_credential
description: Must be set to `client_credential`.
- in: query
name: appid
required: true
schema:
type: string
description: Mini Program AppID from the WeChat Official Accounts Platform.
- in: query
name: secret
required: true
schema:
type: string
description: Mini Program AppSecret.
responses:
'200':
description: Access token response.
content:
application/json:
schema:
oneOf:
- type: object
properties:
access_token:
type: string
description: Global application access token.
expires_in:
type: integer
format: int32
description: Lifetime of the access token in seconds (typically 7200).
- $ref: '#/components/schemas/WeChatError'
examples:
success:
value:
access_token: ACCESS_TOKEN
expires_in: 7200
invalidAppId:
value:
errcode: 40013
errmsg: invalid appid
components:
schemas:
WeChatError:
type: object
description: Standard WeChat API error envelope.
properties:
errcode:
type: integer
description: Numeric WeChat error code; `0` indicates success.
errmsg:
type: string
description: Human-readable error message.
externalDocs:
description: WeChat Mini Program Server API
url: https://developers.weixin.qq.com/miniprogram/en/dev/api-backend/