Skip to content

Instantly share code, notes, and snippets.

@ilsubyeega
Last active January 28, 2022 03:21
Show Gist options
  • Save ilsubyeega/fca07f8c5a3234c5722ee8d488fe46f3 to your computer and use it in GitHub Desktop.
Save ilsubyeega/fca07f8c5a3234c5722ee8d488fe46f3 to your computer and use it in GitHub Desktop.
datakr-client-prototype
import { Client } from '@datakr/client'
import AxiosDriver from '@datakr/axios-driver'
import { RequestData, MetroData } from '@datakr/data'
const serviceKey = "access_service_key";
const client = new Client();
client.driver = new AxiosDriver();
const result = await client.query(serviceKey, RequestData.from("서울교통공사_서울 도시철도 열차운행시각표", {
pageNo: 1,
numOfRows: 100,
stationCode: MetroData.Station.from("운서").code,
week: "DAY",
trainDirection: "UP"
}));
// 혹은 코드 기반
const result = await client.query(serviceKey, RequestData.from(15098251, {
pageNo: 1,
numOfRows: 100,
stationCode: MetroData.Station.from("운서").code,
week: "DAY",
trainDirection: "UP"
}));
// result.status.code; result.body;
@danieluhm2004
Copy link

danieluhm2004 commented Jan 23, 2022

import { DataKoreaClient } from '@datakr/client';
import { AxiosDriver } from '@datakr/driver-axios';

const client = new DataKoreaClient({
  serviceKey: '',
  driver: new AxiosDriver({ /** Axios Config */ })
});


client.setDriver(new AxiosDriver())
client.setServiceKey('');

const resource = new client.getAssets('서울교통공사_서울 도시철도 열차운행시각표');
const result1 = new client.getAssets(15098251).then((asset) => asset.get({ /** something */}))

const result2 = await resource.get({
  pageNo: 1,
  numOfRows: 100,
  stationCode: '운서',
  week: 'DAY',
  trainDirection: 'UP',
});

이런 느낌은 어떠십니까!

@ilsubyeega
Copy link
Author

ilsubyeega commented Jan 23, 2022

@danieluhm2004 이게 좀 눈물나는게
data.go.kr가 API 하나당 토큰 하나이고, typescript completion 기대하고 싶은 코드들이라 ㅇ.ㅇ;
이걸 어떻게 감을 잡아야 될지 몰루
image

@ilsubyeega
Copy link
Author

@Alex4386 리뷰점

@Alex4386
Copy link

🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment