Official Java SDK for SHEIN Open Platform API integration. This SDK provides easy access to SHEIN's e-commerce APIs with built-in authentication, request signing, and data encryption/decryption capabilities.
- 🚀 Easy Integration - Simple setup with Spring Boot auto-configuration
- 🔐 Security First - Built-in request signing and data encryption
- 🛠️ Flexible - Support both Spring Boot and standalone Java applications
- 📝 Well Documented - Comprehensive JavaDoc and examples
- ⚡ High Performance - Connection pooling and timeout configuration
<dependency>
<groupId>io.github.sheinsight</groupId>
<artifactId>shein-open-sdk</artifactId>
<version>0.0.2</version>
</dependency>
implementation 'io.github.sheinsight:shein-open-sdk:0.0.2'
- Add configuration to
application.yml
:
shein:
open:
sdk:
# Choose the appropriate domain based on your business needs
# Available options: https://openapi.sheincorp.com or https://openapi.sheincorp.cn
domain: https://openapi.sheincorp.com
connectTimeoutMillis: 10000
requestTimeoutMillis: 10000
responseTimeoutMillis: 10000
- Inject and use the SDK:
@Service
public class SheinApiService {
@Autowired
private SheinOpenSDKClient sheinOpenSDKClient;
public String exchangeToken(String tempToken) throws OpenSdkException {
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.APPID)
.withAppid("YOUR_APP_ID")
.withAppSecret("YOUR_APP_SECRET");
return sheinOpenSDKClient.getToken(tempToken, authInfo);
}
public String getProducts() throws OpenSdkException {
RequestBuilder requestBuilder = new RequestBuilder();
requestBuilder.setUrl("/open-api/products");
requestBuilder.setMethod(HttpMethodEnum.GET);
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.OPEN_KEY_ID)
.withOpenKeyId("YOUR_OPEN_KEY_ID")
.withSecretKey("YOUR_SECRET_KEY");
requestBuilder.setAuthInfo(authInfo);
// API response is returned directly, no decryption needed
return sheinOpenSDKClient.get(requestBuilder);
}
}
public class SheinApiExample {
public static void main(String[] args) throws OpenSdkException {
// Initialize configuration
SheinAppConfig config = new SheinAppConfig();
// Choose the appropriate domain based on your business needs
// Available options: https://openapi.sheincorp.com or https://openapi.sheincorp.cn
config.setDomain("https://openapi.sheincorp.com");
// Create SDK client
SheinOpenSDKClient client = SheinOpenSDK.getInstance(config);
// Exchange temporary token
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.APPID)
.withAppid("YOUR_APP_ID")
.withAppSecret("YOUR_APP_SECRET");
String response = client.getToken("your-temp-token", authInfo);
System.out.println("Token response: " + response);
}
}
Method | Description |
---|---|
getToken(String tempToken, AuthInfo authInfo) |
Exchange temporary token for permanent access credentials |
get(RequestBuilder requestBuilder) |
Send GET requests to SHEIN Open Platform APIs |
post(RequestBuilder requestBuilder) |
Send POST requests to SHEIN Open Platform APIs |
decryptSecretKey(String encryptedData, String secretKey) |
Decrypt encrypted secret key from token exchange response |
decryptEventData(String encryptedData, String secretKey) |
Decrypt webhook event callback data |
decryptResponse(String encryptedResponse, String secretKey) |
Decrypt encrypted data when SHEIN calls your endpoints |
When calling SHEIN APIs (you → SHEIN):
- Use
get()
andpost()
methods directly - API responses are returned as plain text, no decryption needed
When SHEIN calls your endpoints (SHEIN → you):
- Use
decryptEventData()
for webhook event notifications - Use
decryptResponse()
for other encrypted callback data
When exchanging tokens:
- Use
decryptSecretKey()
to decrypt the secret key from token exchange response
RequestBuilder requestBuilder = new RequestBuilder();
requestBuilder.setUrl("/your/api/endpoint");
requestBuilder.setMethod(HttpMethodEnum.POST);
requestBuilder.setBody("{\"key\":\"value\"}");
// Add custom headers
Map<String, String> headers = new HashMap<>();
headers.put("Custom-Header", "value");
requestBuilder.setHeaders(headers);
// Add query parameters (for GET requests)
Map<String, String> queryParams = new HashMap<>();
queryParams.put("page", "1");
queryParams.put("size", "20");
requestBuilder.setQueryParams(queryParams);
// Set authentication info
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.OPEN_KEY_ID)
.withOpenKeyId("YOUR_OPEN_KEY_ID")
.withSecretKey("YOUR_SECRET_KEY");
requestBuilder.setAuthInfo(authInfo);
The SDK supports two domains. Choose the appropriate one based on your business needs:
Domain | URL |
---|---|
Domain 1 | https://openapi.sheincorp.com |
Domain 2 | https://openapi.sheincorp.cn |
Property | Description | Default |
---|---|---|
shein.open.sdk.domain |
SHEIN Open Platform API domain Options: https://openapi.sheincorp.com or https://openapi.sheincorp.cn |
Required |
shein.open.sdk.connectTimeoutMillis |
Connection timeout in milliseconds | 10000 |
shein.open.sdk.requestTimeoutMillis |
Request timeout in milliseconds | 10000 |
shein.open.sdk.responseTimeoutMillis |
Response timeout in milliseconds | 10000 |
shein.open.sdk.followRedirects |
Whether to follow HTTP redirects | true |
shein.open.sdk.maxConnections |
Maximum HTTP connections | 32 |
try {
String response = sheinOpenSDKClient.get(requestBuilder);
} catch (OpenSdkException e) {
// Handle SDK-specific exceptions
logger.error("SHEIN API call failed: {}", e.getMessage(), e);
}
- Java 8 or higher
- Spring Boot 2.7+ (for auto-configuration features)
SHEIN开放平台官方Java SDK,提供便捷的API集成,内置身份验证、请求签名和数据加密/解密功能。
- 🚀 简单集成 - Spring Boot自动配置,快速上手
- 🔐 安全优先 - 内置请求签名和数据加密
- 🛠️ 灵活使用 - 支持Spring Boot和独立Java应用
- 📝 文档完善 - 详细的JavaDoc和使用示例
- ⚡ 高性能 - 连接池和超时配置优化
<dependency>
<groupId>io.github.sheinsight</groupId>
<artifactId>shein-open-sdk</artifactId>
<version>0.0.2</version>
</dependency>
implementation 'io.github.sheinsight:shein-open-sdk:0.0.2'
- 在
application.yml
中添加配置:
shein:
open:
sdk:
# Choose the appropriate domain based on your business needs
# Available options: https://openapi.sheincorp.com or https://openapi.sheincorp.cn
domain: https://openapi.sheincorp.com
connectTimeoutMillis: 10000
requestTimeoutMillis: 10000
responseTimeoutMillis: 10000
- 注入并使用SDK:
@Service
public class SheinApiService {
@Autowired
private SheinOpenSDKClient sheinOpenSDKClient;
public String exchangeToken(String tempToken) throws OpenSdkException {
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.APPID)
.withAppid("您的应用ID")
.withAppSecret("您的应用密钥");
return sheinOpenSDKClient.getToken(tempToken, authInfo);
}
public String getProducts() throws OpenSdkException {
RequestBuilder requestBuilder = new RequestBuilder();
requestBuilder.setUrl("/open-api/products");
requestBuilder.setMethod(HttpMethodEnum.GET);
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.OPEN_KEY_ID)
.withOpenKeyId("您的开放密钥ID")
.withSecretKey("您的密钥");
requestBuilder.setAuthInfo(authInfo);
// API响应直接返回,无需解密
return sheinOpenSDKClient.get(requestBuilder);
}
}
public class SheinApiExample {
public static void main(String[] args) throws OpenSdkException {
// 初始化配置
SheinAppConfig config = new SheinAppConfig();
config.setDomain("https://openapi.sheincorp.com");
// 创建SDK客户端
SheinOpenSDKClient client = SheinOpenSDK.getInstance(config);
// 交换临时令牌
AuthInfo authInfo = AuthInfo.buildAuthInfo(SignModeEnum.APPID)
.withAppid("您的应用ID")
.withAppSecret("您的应用密钥");
String response = client.getToken("您的临时令牌", authInfo);
System.out.println("令牌响应: " + response);
}
}
方法 | 描述 |
---|---|
getToken(String tempToken, AuthInfo authInfo) |
交换临时令牌获取永久访问凭证 |
get(RequestBuilder requestBuilder) |
向SHEIN开放平台API发送GET请求 |
post(RequestBuilder requestBuilder) |
向SHEIN开放平台API发送POST请求 |
decryptSecretKey(String encryptedData, String secretKey) |
解密令牌交换响应中的加密密钥 |
decryptEventData(String encryptedData, String secretKey) |
解密webhook事件回调数据 |
decryptResponse(String encryptedResponse, String secretKey) |
解密SHEIN主动调用您的接口时的加密数据 |
当您调用SHEIN API时(您 → SHEIN):
- 直接使用
get()
和post()
方法 - API响应以明文返回,无需解密
当SHEIN调用您的接口时(SHEIN → 您):
- 使用
decryptEventData()
解密webhook事件通知数据 - 使用
decryptResponse()
解密其他加密回调数据
当交换令牌时:
- 使用
decryptSecretKey()
解密令牌交换响应中的密钥
SDK支持两个域名,请根据业务需求选择合适的域名:
域名 | URL |
---|---|
域名1 | https://openapi.sheincorp.com |
域名2 | https://openapi.sheincorp.cn |
配置项 | 描述 | 默认值 |
---|---|---|
shein.open.sdk.domain |
SHEIN开放平台API域名 可选项: https://openapi.sheincorp.com 或 https://openapi.sheincorp.cn |
必填 |
shein.open.sdk.connectTimeoutMillis |
连接超时时间(毫秒) | 10000 |
shein.open.sdk.requestTimeoutMillis |
请求超时时间(毫秒) | 10000 |
shein.open.sdk.responseTimeoutMillis |
响应超时时间(毫秒) | 10000 |
shein.open.sdk.followRedirects |
是否自动跟随HTTP重定向 | true |
shein.open.sdk.maxConnections |
最大HTTP连接数 | 32 |
try {
String response = sheinOpenSDKClient.get(requestBuilder);
} catch (OpenSdkException e) {
// 处理SDK特定异常
logger.error("SHEIN API调用失败: {}", e.getMessage(), e);
}
- Java 8或更高版本
- Spring Boot 2.7+(用于自动配置功能)
- Fork本仓库
- 创建特性分支 (
git checkout -b feature/amazing-feature
) - 提交更改 (
git commit -m 'Add some amazing feature'
) - 推送到分支 (
git push origin feature/amazing-feature
) - 创建Pull Request
本项目采用Apache License 2.0许可证 - 查看LICENSE文件了解详情。
如有问题和技术支持:
- 📧 在GitHub上创建issue
- 📖 查看文档
- 💬 加入我们的开发者社区
查看CHANGELOG.md了解最新更改详情。