Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

V2ex API 的 Swift 封装,支持 iOS/macOS (A V2ex API wrapper for iOS/macOS, built with Swift)

License

NotificationsYou must be signed in to change notification settings

isaced/V2exAPI

Repository files navigation

SwiftCocoaPodsCarthageiOSmacOS

中文|English

一个V2ex API 的 Swift 封装,支持 iOS/macOS,支持 SPM 引入和 async/await 方式调用。

特性

  • SPM(Swift Package Manager) 支持
  • Swift async/await 异步 API
  • V2ex API V1 支持度 100%
  • V2ex API V2 支持度 100%
  • Zero dependency 零三方依赖

API 支持范围

V1

接口路径进度
最热主题/api/topics/hot.json
最新主题/api/topics/latest.json
节点列表/api/nodes/list.json
节点信息/api/nodes/show.json
用户主页/api/members/show.json
回复列表/api/replies/show.json

V2

接口路径进度
获取最新的提醒notifications
删除指定的提醒notifications/:notification_id
获取自己的 Profilemember
查看当前使用的令牌token
获取指定节点nodes/:node_name
获取指定节点下的主题nodes/:node_name/topics
获取指定主题topics/:topic_id
获取指定主题下的回复topics/:topic_id/replies

安装

Swift Package Manager

通过Swift Package Manager 安装 V2exAPI 到你的项目,在Package.swift 中添加:

.package(name:"V2exAPI", url:"git@github.com:isaced/V2exAPI.git",.upToNextMinor(from:"1.0.0")),

在 Xcode 中:

CocoaPods

pod'V2exAPI','~> 1.0'

使用

import V2exAPI// 初始化 V2eXAPI 对象letv2ex=V2exAPI(accessToken:"XXXXX-XXXX-XXXX-XXXX-XXXXXXXXX")// 获取节点列表letnodes=tryawait v2ex.nodesList()// 获取最新主题letlatest=tryawait v2ex.latestTopics()// 获取指定节点下的主题列表lettopics=tryawait v2ex.topics(nodeName:"swift", page:1)// 获取指定主题下的回复letreplies=tryawait v2ex.replies(topicId:870607, page:1)

API 参考

API Rate Limit

默认情况下,每个 IP 每小时可以发起的 API 请求数被限制在 120 次。你可以在 API 返回结果的 HTTP 头部找到 Rate Limit 信息:

X-Rate-Limit-Limit: 120X-Rate-Limit-Reset: 1409479200X-Rate-Limit-Remaining: 116

对于能够被 CDN 缓存的 API 请求,只有第一次请求时,才会消耗 Rate Limit 配额。

Personal Access Token 申请参考:https://v2ex.com/help/personal-access-token

使用示例

  • V2exOS - 一个用 SwiftUI 编写的 V2ex macOS 客户端

screenshotscreenshot

License

V2exAPI 在 MIT 许可下发布的,有关详细信息,请参阅LICENSE

About

V2ex API 的 Swift 封装,支持 iOS/macOS (A V2ex API wrapper for iOS/macOS, built with Swift)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp