# Get authorized user information

Debugging Tools

Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide

Interface English name: snsUserInfo

If the web page authorization scope is snsapi_userinfo, then the developer can pull user information through access_token and openid.

Note: The frequency limit for this interface is 50,000 / min

# 1. How to call

# HTTPS calls

GET https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=LANG

# Cloud Calls

  • This interface does not support cloud calls

# Third party invocation

  • Third Party Platform calls are not supported by this interface.

# 2. Request parameters

# Query parametersQuery String parameters

Parameter NametypeRequired to fill inExampleIntroductions
access_tokenstringyes-Interface invoke credentials, using access_token
openidstringyes-The unique identifier of the user
langstringnozh_CNBack to country language version, zh_CN simplified, zh_TW traditional, en English

# Request BodyRequest Payload

nothing

# 3. Return Parameters

# Response Payload

Parameter NametypeIntroductions
openidstringThe unique identifier of the user
nicknamestringUser nickname
sexnumberUser's gender, a value of 1 is male, avalue of 2 is female, and a value 0 is unknown
headimgurlstringUser avatar. The last value represents the square avatar size (there are values 0, 46, 64, 96, 132, and 0 represents a 640 * 640 square avatar). This item is empty when the user does not have a avatar.If the user changes the avatar, the original avatar URL will become invalid.
unionidstringThis field appears only after the user has bound Official Account to WeChat open platform account.
provincestringProvinces in which the user's profile was filled
citystringCities populated by the average user's profile
countrystringCountries, such as China for CN
privilegearrayUser privilege information, json array, such as WeChat

# 4. Note

There are no special considerations for this interface

# 5. Code examples

Example Requests

https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN

Return an example

{   
  "openid": "OPENID",
  "nickname": NICKNAME,
  "sex": 1,
  "province":"PROVINCE",
  "city":"CITY",
  "country":"COUNTRY",
  "headimgurl":"https://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46",
  "privilege":[ "PRIVILEGE1" "PRIVILEGE2"     ],
  "unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
}

# 6. Error code

The following is a list of error codes for this interface, other error codes can refer to General error codes

Error codeError DescriptionSolutions
40003invalid openidInvalid OpenID. Please confirm if the OpenID is following Official Account, or if it is another OpenID from the Official Account message template.

# 7. Scope of application

How this interface can be invoked under different account types:
Service Account Mobile App Website App
Certification only
  • Authentication only: means that only authenticated accounts are allowed to be invoked by the enterprise entity, and accounts that are not authenticated or do not support authentication cannot be invoked.
  • ✔: The account can call this interface
  • Other account types that are not expressly stated may not be called on this interface without special instructions;