Skip to content

Commit 50fdf6b

Browse files
authored
Merge pull request #30 from Kucoin/release/2025.03.21
Release/2025.03.21
2 parents b9ab863 + fe8ab20 commit 50fdf6b

File tree

1,246 files changed

+39499
-28324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,246 files changed

+39499
-28324
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
API documentation [Changelog](https://www.kucoin.com/docs-new/change-log)
4+
5+
Current synchronized API documentation version [20250313](https://www.kucoin.com/docs-new/change-log#20250313)
6+
7+
## 2025-03-21(1.2.0)
8+
- Update the latest APIs, documentation, etc
9+
- Remove range validation in Python
10+
- Update API KEY verification version to 3
11+
- Fix the bug related to resubscribing
12+
- The Node.js SDK has been changed to the official unified version
13+
- Fix issues with automated test execution.
14+
315
## 2025-03-04(Python 1.1.1)
416
- Update __init__.py to enhance the import experience
517
- Reduce unnecessary log output

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.m2,sharing=locked mvn -U clean package -Dsk
2222
# build tools
2323
FROM openapitools/openapi-generator-cli:v7.7.0
2424

25-
RUN apt-get update && apt-get install python3 python3-pip python3.8-venv nodejs npm -y
25+
RUN apt-get update && apt-get install python3 python3-pip python3.8-venv nodejs jq npm -y
2626
RUN pip install yapf
2727
ENV GOLANG_VERSION=1.22.2
2828
RUN curl -OL https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz && \

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,11 @@ SUBDIRS := $(shell find ./sdk -mindepth 1 -maxdepth 1 -type d)
8888
test: $(SUBDIRS)
8989
$(SUBDIRS):
9090
@echo "Running tests in $@"
91-
@docker run --rm -v ./$@:/app -w /app $(IMAGE_NAME):$(IMAGE_TAG) \
91+
@docker run --rm \
92+
-v venv-test-cache:/app/.venv-test \
93+
-v go-mod-cache:/go/pkg/mod \
94+
-v go-build-cache:/root/.cache/go-build \
95+
-v ./$@:/app -w /app $(IMAGE_NAME):$(IMAGE_TAG) \
9296
bash run_test.sh
9397
@echo "Completed tests in $@"
9498

@@ -97,7 +101,7 @@ generate: setup-logs
97101
$(call generate-postman)
98102
$(call generate-code,golang,/pkg/generate)
99103
$(call generate-code,python,/kucoin_universal_sdk/generate)
100-
$(call generate-code,node,/src/generate,v0.1.1-alpha)
104+
$(call generate-code,node,/src/generate)
101105

102106
.PHONY: gen-postman
103107
gen-postman: preprocessor

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# KuCoin Universal SDK
22

33
![License Badge](https://img.shields.io/badge/license-MIT-green)
4-
![Language](https://img.shields.io/badge/language-Python|Go-blue)
4+
![Language](https://img.shields.io/badge/language-Python|Go|Node.js-blue)
55

66
The **KuCoin Universal SDK** is the official SDK provided by KuCoin, offering a unified and seamless interface for accessing KuCoin's trading platform. Built using code generation technology, it ensures consistency and rapid updates across multiple programming languages, simplifying integration with consistent APIs.
77

@@ -32,9 +32,9 @@ The **KuCoin Universal SDK** is the official SDK provided by KuCoin, offering a
3232

3333
## 🛠️ Installation
3434

35-
### Latest Version: `1.1.0`(Global API version)
35+
### Latest Version: `1.2.0`(Global API version)
3636

37-
### Python Installation(`1.1.1`)
37+
### Python Installation
3838

3939
```bash
4040
pip install kucoin-universal-sdk
@@ -47,8 +47,7 @@ go get github.com/Kucoin/kucoin-universal-sdk/sdk/golang
4747
go mod tidy
4848
```
4949

50-
### Node.js Installation (`0.1.1-alpha`)
51-
Note: This SDK is currently in the Alpha phase. We are actively iterating and improving its features, stability, and documentation. Feedback and contributions are highly encouraged to help us refine the SDK.
50+
### Node.js Installation
5251
```bash
5352
npm install kucoin-universal-sdk
5453
```
@@ -64,12 +63,12 @@ Here's a quick example to get you started with the SDK in **Python**.
6463
import logging
6564
import os
6665

67-
from kucoin_universal_sdk.api.client import DefaultClient
68-
from kucoin_universal_sdk.generate.spot.market.model_get_part_order_book_req import GetPartOrderBookReqBuilder
69-
from kucoin_universal_sdk.model.client_option import ClientOptionBuilder
70-
from kucoin_universal_sdk.model.constants import GLOBAL_API_ENDPOINT, GLOBAL_FUTURES_API_ENDPOINT, \
66+
from kucoin_universal_sdk.api import DefaultClient
67+
from kucoin_universal_sdk.generate.spot.market import GetPartOrderBookReqBuilder
68+
from kucoin_universal_sdk.model import ClientOptionBuilder
69+
from kucoin_universal_sdk.model import GLOBAL_API_ENDPOINT, GLOBAL_FUTURES_API_ENDPOINT, \
7170
GLOBAL_BROKER_API_ENDPOINT
72-
from kucoin_universal_sdk.model.transport_option import TransportOptionBuilder
71+
from kucoin_universal_sdk.model import TransportOptionBuilder
7372

7473

7574
def example():

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.1.0
1+
v1.2.0

generator/plugin/src/main/java/com/kucoin/universal/sdk/plugin/generator/PythonSdkGenerator.java

Lines changed: 18 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,13 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
452452

453453
case API:
454454
case TEST: {
455-
allModels.forEach(m-> {
456-
String importName = (String)m.get("importPath");
455+
allModels.forEach(m -> {
456+
String importName = (String) m.get("importPath");
457457
String fileName = m.getModel().getClassFilename();
458458
// from .model_get_part_order_book_req import GetPartOrderBookReqBuilder
459459
exports.add(String.format("from .%s import %s", fileName, importName));
460460
if (m.getModel().getVendorExtensions().containsKey("x-request-model")) {
461-
exports.add(String.format("from .%s import %s", fileName, importName+"Builder"));
461+
exports.add(String.format("from .%s import %s", fileName, importName + "Builder"));
462462
}
463463
});
464464
exports.add(String.format("from .%s import %sAPI", toApiFilename(meta.getSubService()), formatService(meta.getSubService())));
@@ -477,8 +477,8 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<Mo
477477
}
478478
case WS:
479479
case WS_TEST: {
480-
allModels.forEach(m-> {
481-
String importName = (String)m.get("importPath");
480+
allModels.forEach(m -> {
481+
String importName = (String) m.get("importPath");
482482
String fileName = m.getModel().getClassFilename();
483483
// from .model_get_part_order_book_req import GetPartOrderBookReqBuilder
484484
exports.add(String.format("from .%s import %s", fileName, importName));
@@ -775,8 +775,8 @@ public Map<String, Object> postProcessSupportingFileData(Map<String, Object> obj
775775
throw new RuntimeException("read csv fail", e);
776776
}
777777

778-
services.forEach(s-> {
779-
Map<String,String> specialKeywords = Map.of("copytrading", "CopyTrading", "viplending", "VIPLending");
778+
services.forEach(s -> {
779+
Map<String, String> specialKeywords = Map.of("copytrading", "CopyTrading", "viplending", "VIPLending");
780780
String service = formatService(specialKeywords.getOrDefault(s, s));
781781
serviceExports.add(String.format("from .%s_api import %sService", s, service));
782782
});
@@ -1178,100 +1178,23 @@ private PythonType mapType(IJsonSchemaValidationProperties cp) {
11781178
}
11791179

11801180
private PythonType numberType(IJsonSchemaValidationProperties cp) {
1181-
if (cp.getHasValidation()) {
1182-
PythonType floatt = new PythonType("float");
1183-
1184-
// e.g. confloat(ge=10, le=100, strict=True)
1185-
if (cp.getMaximum() != null) {
1186-
if (cp.getExclusiveMaximum()) {
1187-
floatt.constrain("lt", cp.getMaximum(), false);
1188-
} else {
1189-
floatt.constrain("le", cp.getMaximum(), false);
1190-
}
1191-
}
1192-
if (cp.getMinimum() != null) {
1193-
if (cp.getExclusiveMinimum()) {
1194-
floatt.constrain("gt", cp.getMinimum(), false);
1195-
} else {
1196-
floatt.constrain("ge", cp.getMinimum(), false);
1197-
}
1198-
}
1199-
if (cp.getMultipleOf() != null) {
1200-
floatt.constrain("multiple_of", cp.getMultipleOf());
1201-
}
1202-
1203-
return floatt;
1204-
} else {
1205-
return new PythonType("float");
1206-
}
1181+
return new PythonType("float");
12071182
}
12081183

12091184
private PythonType intType(IJsonSchemaValidationProperties cp) {
1210-
if (cp.getHasValidation()) {
1211-
PythonType pt = new PythonType("int");
1212-
// e.g. conint(ge=10, le=100, strict=True)
1213-
pt.constrain("strict", true);
1214-
if (cp.getMaximum() != null) {
1215-
if (cp.getExclusiveMaximum()) {
1216-
pt.constrain("lt", cp.getMaximum(), false);
1217-
} else {
1218-
pt.constrain("le", cp.getMaximum(), false);
1219-
}
1220-
}
1221-
if (cp.getMinimum() != null) {
1222-
if (cp.getExclusiveMinimum()) {
1223-
pt.constrain("gt", cp.getMinimum(), false);
1224-
} else {
1225-
pt.constrain("ge", cp.getMinimum(), false);
1226-
}
1227-
}
1228-
if (cp.getMultipleOf() != null) {
1229-
pt.constrain("multiple_of", cp.getMultipleOf());
1230-
}
1231-
return pt;
1232-
} else {
1233-
return new PythonType("int");
1234-
}
1185+
return new PythonType("int");
12351186
}
12361187

12371188
private PythonType binaryType(IJsonSchemaValidationProperties cp) {
1238-
if (cp.getHasValidation()) {
1239-
PythonType bytest = new PythonType("bytes");
1240-
PythonType strt = new PythonType("str");
1241-
1242-
// e.g. conbytes(min_length=2, max_length=10)
1243-
bytest.constrain("strict", true);
1244-
strt.constrain("strict", true);
1245-
if (cp.getMaxLength() != null) {
1246-
bytest.constrain("max_length", cp.getMaxLength());
1247-
strt.constrain("max_length", cp.getMaxLength());
1248-
}
1249-
if (cp.getMinLength() != null) {
1250-
bytest.constrain("min_length", cp.getMinLength());
1251-
strt.constrain("min_length", cp.getMinLength());
1252-
}
1253-
if (cp.getPattern() != null) {
1254-
moduleImports.add("pydantic", "field_validator");
1255-
// use validator instead as regex doesn't support flags, e.g. IGNORECASE
1256-
//fieldCustomization.add(Locale.ROOT, String.format(Locale.ROOT, "regex=r'%s'", cp.getPattern()));
1257-
}
1258-
1259-
moduleImports.add("typing", "Union");
1260-
PythonType pt = new PythonType("Union");
1261-
pt.addTypeParam(bytest);
1262-
pt.addTypeParam(strt);
1263-
return pt;
1264-
} else {
1265-
// same as above which has validation
1266-
moduleImports.add("pydantic", "StrictBytes");
1267-
moduleImports.add("pydantic", "StrictStr");
1268-
moduleImports.add("typing", "Union");
1269-
1270-
PythonType pt = new PythonType("Union");
1271-
pt.addTypeParam(new PythonType("StrictBytes"));
1272-
pt.addTypeParam(new PythonType("StrictStr"));
1273-
return pt;
1274-
}
1189+
// same as above which has validation
1190+
moduleImports.add("pydantic", "StrictBytes");
1191+
moduleImports.add("pydantic", "StrictStr");
1192+
moduleImports.add("typing", "Union");
1193+
1194+
PythonType pt = new PythonType("Union");
1195+
pt.addTypeParam(new PythonType("StrictBytes"));
1196+
pt.addTypeParam(new PythonType("StrictStr"));
1197+
return pt;
12751198
}
12761199

12771200
private PythonType boolType(IJsonSchemaValidationProperties cp) {
@@ -1281,29 +1204,6 @@ private PythonType boolType(IJsonSchemaValidationProperties cp) {
12811204
private PythonType decimalType(IJsonSchemaValidationProperties cp) {
12821205
PythonType pt = new PythonType("Decimal");
12831206
moduleImports.add("decimal", "Decimal");
1284-
1285-
if (cp.getHasValidation()) {
1286-
// e.g. condecimal(ge=10, le=100, strict=True)
1287-
pt.constrain("strict", true);
1288-
if (cp.getMaximum() != null) {
1289-
if (cp.getExclusiveMaximum()) {
1290-
pt.constrain("gt", cp.getMaximum(), false);
1291-
} else {
1292-
pt.constrain("ge", cp.getMaximum(), false);
1293-
}
1294-
}
1295-
if (cp.getMinimum() != null) {
1296-
if (cp.getExclusiveMinimum()) {
1297-
pt.constrain("lt", cp.getMinimum(), false);
1298-
} else {
1299-
pt.constrain("le", cp.getMinimum(), false);
1300-
}
1301-
}
1302-
if (cp.getMultipleOf() != null) {
1303-
pt.constrain("multiple_of", cp.getMultipleOf());
1304-
}
1305-
}
1306-
13071207
return pt;
13081208
}
13091209

generator/plugin/src/main/java/com/kucoin/universal/sdk/plugin/service/impl/OperationServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private void checkUpdateExtension(String path, PathItem.HttpMethod httpMethod, O
143143
{"API-CHANNEL", operation.getExtensions().getOrDefault("x-api-channel", "NULL").toString().toUpperCase()},
144144
{"API-PERMISSION", operation.getExtensions().getOrDefault("x-api-permission", "NULL").toString().toUpperCase()},
145145
{"API-RATE-LIMIT-POOL", operation.getExtensions().getOrDefault("x-api-rate-limit-pool", "NULL").toString().toUpperCase()},
146-
{"API-RATE-LIMIT", operation.getExtensions().getOrDefault("x-api-rate-limit", "NULL").toString().toUpperCase()},
146+
{"API-RATE-LIMIT-WEIGHT", operation.getExtensions().getOrDefault("x-api-rate-limit-weight", "NULL").toString().toUpperCase()},
147147
};
148148

149149
String[] extraComment = AsciiTable.getTable(AsciiTable.BASIC_ASCII_NO_DATA_SEPARATORS, new Column[]{

generator/postman/script_broker_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function auth(apiKey, method, url, data) {
4141
'KC-API-PASSPHRASE': sign(apiKey.passphrase || '', apiKey.secret),
4242
'Content-Type': 'application/json',
4343
'User-Agent': `Kucoin-Universal-Postman-SDK/{{SDK-VERSION}}`,
44-
'KC-API-KEY-VERSION': 2,
44+
'KC-API-KEY-VERSION': 3,
4545
'KC-API-PARTNER': apiKey.partner,
4646
'KC-BROKER-NAME': apiKey.brokerName,
4747
'KC-API-PARTNER-VERIFY': 'true',

generator/postman/script_template.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function auth(apiKey, method, url, data) {
3737
'KC-API-PASSPHRASE': sign(apiKey.passphrase || '', apiKey.secret),
3838
'Content-Type': 'application/json',
3939
'User-Agent': `Kucoin-Universal-Postman-SDK/{{SDK-VERSION}}`,
40-
'KC-API-KEY-VERSION': 2,
40+
'KC-API-KEY-VERSION': 3,
4141
};
4242
}
4343

sdk/golang/CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
API documentation [Changelog](https://www.kucoin.com/docs-new/change-log)
4+
5+
Current synchronized API documentation version [20250313](https://www.kucoin.com/docs-new/change-log#20250313)
6+
7+
## 2025-03-21(1.2.0)
8+
- Update the latest APIs, documentation, etc
9+
- Remove range validation in Python
10+
- Update API KEY verification version to 3
11+
- Fix the bug related to resubscribing
12+
- The Node.js SDK has been changed to the official unified version
13+
- Fix issues with automated test execution.
14+
15+
## 2025-03-04(Python 1.1.1)
16+
- Update __init__.py to enhance the import experience
17+
- Reduce unnecessary log output
18+
- Optimize WebSocket reconnection logic
19+
20+
## 2025-02-26(Nodejs 0.1.0-alpha)
21+
- Release Node.js implementation
22+
323
## 2025-01-16(1.1.0)
424
- Updated the API sequence to be consistent with the documentation.
525
- Updated the license.

0 commit comments

Comments
 (0)