maplestory-openapi 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -0
- package/package.json +2 -1
- package/types/maplestory/api/mapleStoryApi.d.ts +6 -3
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# MapleStory OpenAPI JavaScript Library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/maplestory-openapi)
|
|
4
|
+
|
|
5
|
+
This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.
|
|
6
|
+
|
|
7
|
+
Packages written in other languages can be found [HERE](https://github.com/SpiralMoon/maplestory.openapi).
|
|
8
|
+
|
|
9
|
+
(한국어 문서는 [이쪽](https://github.com/SpiralMoon/maplestory.openapi/blob/master/js/README-ko.md)입니다.)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the latest version of the JavaScript/TypeScript library in your npm project:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install maplestory-openapi@1.0.1 # Replace with the latest version
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Supports
|
|
22
|
+
|
|
23
|
+
1. **CommonJS, ESM Support**: The library supports both CommonJS and ESM usage.
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
const {MapleStoryApi, MapleStoryApiError} = require('maplestory-openapi'); // CommonJS
|
|
27
|
+
```
|
|
28
|
+
```typescript
|
|
29
|
+
import {MapleStoryApi, MapleStoryApiError} from 'maplestory-openapi'; // ESM
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
2. **TypeScript Support**: TypeScript is fully supported. Type definitions are included.
|
|
33
|
+
|
|
34
|
+
### Sample Code
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const {MapleStoryApi, MapleStoryApiError} = require('maplestory-openapi');
|
|
38
|
+
|
|
39
|
+
const apiKey = '{Your API Key}';
|
|
40
|
+
const api = new MapleStoryApi(apiKey);
|
|
41
|
+
|
|
42
|
+
api.getCubeResult(1000, {
|
|
43
|
+
year: 2023,
|
|
44
|
+
month: 10,
|
|
45
|
+
day: 15
|
|
46
|
+
})
|
|
47
|
+
.then((dto) => {
|
|
48
|
+
const {count, cubeHistories, nextCursor} = dto;
|
|
49
|
+
|
|
50
|
+
console.log('You used ' + count + ' cubes.');
|
|
51
|
+
})
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
if (e instanceof MapleStoryApiError) {
|
|
54
|
+
// handle MapleStoryApiError
|
|
55
|
+
} else {
|
|
56
|
+
// handle other errors
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(e);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Exception Handling
|
|
64
|
+
|
|
65
|
+
Handle `MapleStoryApiError` to safely make calls, ensuring that specific Status defined in the [MapleStory OpenAPI Guide](https://developers.nexon.com/Maplestory/guides) are not encountered.
|
|
66
|
+
|
|
67
|
+
While `MapleStoryApi` is designed to prevent the occurrence of certain Status, exceptions may arise due to developer mistakes.
|
|
68
|
+
|
|
69
|
+
Therefore, it's recommended to use `MapleStoryApiError` for exception handling based on the Status list described in the table below.
|
|
70
|
+
|
|
71
|
+
| Status | Message |
|
|
72
|
+
|--------|---------------------------------------------------------|
|
|
73
|
+
| 400 | Request format error (incorrect parameter input) |
|
|
74
|
+
| 401 | Unauthorized service (unsupported service, service type) |
|
|
75
|
+
| 403 | Unauthorized AccessToken usage |
|
|
76
|
+
| 429 | AccessToken's request allowance (Rate Limit) exceeded |
|
|
77
|
+
| 500 | Internal server error |
|
|
78
|
+
| 504 | Internal server processing timeout |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplestory-openapi",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"maplestory",
|
|
6
6
|
"maplestory openapi",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"nexon",
|
|
10
10
|
"nexon developers"
|
|
11
11
|
],
|
|
12
|
+
"description": "This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.",
|
|
12
13
|
"homepage": "https://github.com/SpiralMoon/maplestory.openapi",
|
|
13
14
|
"bugs": {
|
|
14
15
|
"url": "https://github.com/SpiralMoon/maplestory.openapi/issues"
|
|
@@ -7,14 +7,16 @@ declare class MapleStoryApi {
|
|
|
7
7
|
constructor(apiKey: string);
|
|
8
8
|
/**
|
|
9
9
|
* 오늘 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
|
|
10
|
-
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수
|
|
10
|
+
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.<br>
|
|
11
|
+
* 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
|
|
11
12
|
*
|
|
12
13
|
* @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
|
|
13
14
|
*/
|
|
14
15
|
getCubeResult(count: number): Promise<CubeHistoryResponseDto>;
|
|
15
16
|
/**
|
|
16
17
|
* 지목한 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
|
|
17
|
-
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수
|
|
18
|
+
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.<br>
|
|
19
|
+
* 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
|
|
18
20
|
*
|
|
19
21
|
* @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
|
|
20
22
|
* @param dateOptions 조회할 연월일 날짜 정보
|
|
@@ -22,7 +24,8 @@ declare class MapleStoryApi {
|
|
|
22
24
|
getCubeResult(count: number, dateOptions: DateOptions): Promise<CubeHistoryResponseDto>;
|
|
23
25
|
/**
|
|
24
26
|
* 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
|
|
25
|
-
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수
|
|
27
|
+
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.<br>
|
|
28
|
+
* 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
|
|
26
29
|
*
|
|
27
30
|
* @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
|
|
28
31
|
* @param cursor
|