NodeJS(TypeScript) SDK For V2EX(https://www.v2ex.com)
npm i --save @chyroc/v2ex-api
get token from https://www.v2ex.com/settings/tokens
import V2EX from "@chyroc/v2ex-api";
const token = process.env.V2EX_TOKEN || ''
const client = new V2EX({token, timeout: 10000})
const getNotifications = async (client: V2EX) => {
const {notifications, total} = await client.getNotifications({page: 1})
console.log('notifications:', notifications)
console.log('total:', total)
}
const deleteNotification = async (client: V2EX) => {
await client.deleteNotification({notificationID: 1})
}
const getProfile = async (client: V2EX) => {
const profile = await client.getProfile()
console.log('profile', profile)
}
const getToken = async (client: V2EX) => {
const token = await client.getToken()
console.log('token', token)
}
const createToken = async (client: V2EX) => {
const token = await client.createToken({
scope: TokenScope.everything,
expiration: TokenExpiration.D30,
})
console.log('token', token)
}
const getNode = async (client: V2EX) => {
const node = await client.getNode({nodeName: 'python'})
console.log('node', node)
}
const getTopicByNode = async (client: V2EX) => {
const topics = await client.getTopicByNode({nodeName: 'python', page: 2})
console.log('topics', topics)
}
const getTopic = async (client: V2EX) => {
const topic = await client.getTopic({topicID: 1})
console.log('topic', topic)
}
const getTopicReply = async (client: V2EX) => {
const topicReply = await client.getTopicReply({topicID: 1, page: 2})
console.log('topicReply', topicReply)
}
const getPlanes = async (client: V2EX) => {
const plane = await client.getPlanes()
console.log('plane', plane)
}