gongdata 0.1.0
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/LICENSE +21 -0
- package/README.md +236 -0
- package/dist/index.cjs +663 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +509 -0
- package/dist/index.d.ts +509 -0
- package/dist/index.js +650 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SangheeSon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# gongdata
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for Korea Public Data Portal (data.go.kr) APIs
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install gongdata
|
|
9
|
+
# or
|
|
10
|
+
pnpm add gongdata
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { createClient } from 'gongdata';
|
|
17
|
+
|
|
18
|
+
const client = createClient({
|
|
19
|
+
serviceKey: process.env.DATA_GO_KR_SERVICE_KEY,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Get 2026 qualification exam schedules
|
|
23
|
+
const result = await client.qualification.getSchedules({ year: 2026 });
|
|
24
|
+
|
|
25
|
+
// Normalized data (SDK guaranteed interface)
|
|
26
|
+
console.log(result.data[0].writtenExam.registrationStart); // '2026-01-24'
|
|
27
|
+
|
|
28
|
+
// Raw data (original API response)
|
|
29
|
+
console.log(result.rawData[0].docRegStartDt); // '20260124'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
| Feature | Description |
|
|
35
|
+
|---------|-------------|
|
|
36
|
+
| Type Safety | Full TypeScript types for all API responses |
|
|
37
|
+
| Dual Data Access | `data` (normalized) + `rawData` (original) |
|
|
38
|
+
| Auto Pagination | `getAllSchedules()` fetches all pages automatically |
|
|
39
|
+
| Error Handling | Unified `GongdataError` for all API error codes |
|
|
40
|
+
| Retry Logic | Automatic retry on network failures |
|
|
41
|
+
|
|
42
|
+
## API Reference
|
|
43
|
+
|
|
44
|
+
### createClient(config)
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const client = createClient({
|
|
48
|
+
serviceKey: string, // Required: data.go.kr service key
|
|
49
|
+
timeout?: number, // Optional: timeout in ms (default: 10000)
|
|
50
|
+
retry?: {
|
|
51
|
+
maxRetries: number, // Optional: max retries (default: 3)
|
|
52
|
+
delay: number, // Optional: retry delay in ms (default: 1000)
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### client.qualification
|
|
58
|
+
|
|
59
|
+
Qualification exam schedule service
|
|
60
|
+
|
|
61
|
+
#### getSchedules(params, options?)
|
|
62
|
+
|
|
63
|
+
Get exam schedules (single page)
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const result = await client.qualification.getSchedules(
|
|
67
|
+
{
|
|
68
|
+
year: 2026, // Required: exam year
|
|
69
|
+
category: QualificationCategory.NATIONAL_TECHNICAL, // Optional
|
|
70
|
+
jmCode: JmCode.INFORMATION_PROCESSING_ENGINEER, // Optional
|
|
71
|
+
},
|
|
72
|
+
{ pageNo: 1, numOfRows: 10 } // Optional: pagination
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Returns: ScheduleResponse
|
|
76
|
+
result.data; // ExamSchedule[] - normalized data
|
|
77
|
+
result.rawData; // RawExamSchedule[] - original data
|
|
78
|
+
result.pagination; // { pageNo, numOfRows, totalCount }
|
|
79
|
+
result.hasNextPage();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### getAllSchedules(params)
|
|
83
|
+
|
|
84
|
+
Get all exam schedules (auto pagination)
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
const result = await client.qualification.getAllSchedules({ year: 2026 });
|
|
88
|
+
|
|
89
|
+
// Returns: AllSchedulesResponse
|
|
90
|
+
result.data; // ExamSchedule[] - all data
|
|
91
|
+
result.count(); // total count
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### getSubjects()
|
|
95
|
+
|
|
96
|
+
Get all qualification subject codes
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const result = await client.qualification.getSubjects();
|
|
100
|
+
|
|
101
|
+
// Returns: SubjectResponse
|
|
102
|
+
result.data; // Subject[]
|
|
103
|
+
result.findByCode('1320'); // find by code
|
|
104
|
+
result.findByName('정보처리기사'); // find by name
|
|
105
|
+
result.filterByCategory('T'); // filter by category
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Type Definitions
|
|
109
|
+
|
|
110
|
+
### ExamSchedule (Normalized)
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
interface ExamSchedule {
|
|
114
|
+
year: number; // exam year
|
|
115
|
+
round: number; // round number
|
|
116
|
+
category: {
|
|
117
|
+
code: string; // 'T' | 'C' | 'W' | 'S'
|
|
118
|
+
name: string; // category name in Korean
|
|
119
|
+
};
|
|
120
|
+
description: string; // schedule description
|
|
121
|
+
writtenExam: ExamPeriod; // written exam period
|
|
122
|
+
practicalExam: ExamPeriod; // practical exam period
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface ExamPeriod {
|
|
126
|
+
registrationStart: string; // 'YYYY-MM-DD'
|
|
127
|
+
registrationEnd: string;
|
|
128
|
+
examStart: string;
|
|
129
|
+
examEnd: string;
|
|
130
|
+
resultDate: string;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Subject (Normalized)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
interface Subject {
|
|
138
|
+
code: string; // '1320'
|
|
139
|
+
name: string; // '정보처리기사'
|
|
140
|
+
category: { code: string; name: string };
|
|
141
|
+
series: { code: string; name: string };
|
|
142
|
+
majorJobField: { code: string; name: string };
|
|
143
|
+
minorJobField: { code: string; name: string };
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Constants
|
|
148
|
+
|
|
149
|
+
### QualificationCategory
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import { QualificationCategory } from 'gongdata';
|
|
153
|
+
|
|
154
|
+
QualificationCategory.NATIONAL_TECHNICAL; // 'T' - National Technical
|
|
155
|
+
QualificationCategory.COURSE_EVALUATION; // 'C' - Course Evaluation
|
|
156
|
+
QualificationCategory.WORK_LEARNING; // 'W' - Work-Learning Dual
|
|
157
|
+
QualificationCategory.NATIONAL_PROFESSIONAL; // 'S' - National Professional
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### JmCode (Subject Codes)
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import { JmCode } from 'gongdata';
|
|
164
|
+
|
|
165
|
+
// IT
|
|
166
|
+
JmCode.INFORMATION_PROCESSING_ENGINEER; // '1320'
|
|
167
|
+
JmCode.INFORMATION_PROCESSING_INDUSTRIAL_ENGINEER; // '2290'
|
|
168
|
+
|
|
169
|
+
// Electrical
|
|
170
|
+
JmCode.ELECTRICAL_ENGINEER; // '1150'
|
|
171
|
+
JmCode.ELECTRICAL_TECHNICIAN; // '7780'
|
|
172
|
+
|
|
173
|
+
// Culinary
|
|
174
|
+
JmCode.KOREAN_CUISINE_TECHNICIAN; // '7910'
|
|
175
|
+
JmCode.WESTERN_CUISINE_TECHNICIAN; // '7911'
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Error Handling
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import { GongdataError, ResultCode } from 'gongdata';
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
const result = await client.qualification.getSchedules({ year: 2026 });
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (GongdataError.isGongdataError(error)) {
|
|
187
|
+
console.log(error.code); // '30'
|
|
188
|
+
console.log(error.message); // 'Unregistered service key'
|
|
189
|
+
|
|
190
|
+
if (error.code === ResultCode.UNREGISTERED_SERVICE_KEY) {
|
|
191
|
+
// Handle invalid service key
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### ResultCode
|
|
198
|
+
|
|
199
|
+
| Code | Constant | Description |
|
|
200
|
+
|------|----------|-------------|
|
|
201
|
+
| 00 | SUCCESS | Success |
|
|
202
|
+
| 1 | APPLICATION_ERROR | Application error |
|
|
203
|
+
| 22 | REQUEST_LIMIT_EXCEEDED | Request limit exceeded |
|
|
204
|
+
| 30 | UNREGISTERED_SERVICE_KEY | Unregistered service key |
|
|
205
|
+
| 31 | EXPIRED_SERVICE_KEY | Expired service key |
|
|
206
|
+
|
|
207
|
+
## Environment Setup
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# .env
|
|
211
|
+
DATA_GO_KR_SERVICE_KEY=your_service_key_here
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import 'dotenv/config';
|
|
216
|
+
|
|
217
|
+
const client = createClient({
|
|
218
|
+
serviceKey: process.env.DATA_GO_KR_SERVICE_KEY!,
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Getting a Service Key
|
|
223
|
+
|
|
224
|
+
1. Sign up at [data.go.kr](https://www.data.go.kr)
|
|
225
|
+
2. Apply for [Qualification Exam Schedule API](https://www.data.go.kr/data/15074408/openapi.do)
|
|
226
|
+
3. Copy the **Decoding Key** from My Page
|
|
227
|
+
|
|
228
|
+
## License
|
|
229
|
+
|
|
230
|
+
MIT
|
|
231
|
+
|
|
232
|
+
## Contributing
|
|
233
|
+
|
|
234
|
+
Issues and PRs are welcome.
|
|
235
|
+
|
|
236
|
+
- [GitHub Issues](https://github.com/Higangssh/gongdata/issues)
|