Giter Site home page Giter Site logo

open-jike / jike-sdk Goto Github PK

View Code? Open in Web Editor NEW
57.0 1.0 9.0 1 MB

Ⓙ Jike SDK for Node.js / Deno / browser

Home Page: https://jike-sdk.sxzz.moe

License: GNU Affero General Public License v3.0

JavaScript 0.23% TypeScript 99.77%
jike api nodejs deno sdk typescript

jike-sdk's Introduction

jike-sdk Ⓙ Jike SDK

Unit Test GitHub node-lts npm type definitions GitHub Repo stars GitHub forks Jike (followers)

本项目仅供学习交流使用,在使用过程中对你或他人造成的任何损失我们概不负责。

Caution

本项目不再积极维护。

Features

  • 🌈 可能是东半球最全的第三方 SDK
  • ⭐️ 同时支持 Node.js / 浏览器 / Deno / Bun
  • 🦾 自带 TypeScript 类型声明
API 列表

Installation

Node.js

Node.js >= v18.12.0

npm i jike-sdk

ESM 导入

如果使用 ESM 方式导入,需要把 package.jsontype 设置为 module,或将后缀名改为 .mjs

// index.mjs

// 使用此版本需 node >= 18 或 自行 ployfill fetch。
import { setApiConfig } from 'jike-sdk'

setApiConfig({
  // ...
})

CJS 导入

const { setApiConfig } = require('jike-sdk')
setApiConfig({
  // ...
})

Bun

Bun >= 0.5.8

bun i jike-sdk
// index.ts
import { setApiConfig } from 'jike-sdk'
setApiConfig({
  // ...
})

Deno

import { setApiConfig } from 'https://cdn.skypack.dev/jike-sdk/index?dts'

浏览器

import { setApiConfig } from 'jike-sdk'

或使用 CDN 的方式加载(与 Deno 一致)

<script type="module">
  import { setApiConfig } from 'https://cdn.skypack.dev/jike-sdk/index'
</script>

由于 CORS 策略的原因,第三方网站无法直接请求外部服务器。但可以使用浏览器扩展的能力请求。

Usage

API Reference

import { ApiClient, api, setAccessToken, setApiConfig } from 'jike-sdk'

// 自行在 GitHub 搜索「jike endpoint」探索配置
const apiConfig = {
  endpointId: 'jike',
  endpointUrl: '<jike-endpoint-url>', // 请自行替换
  bundleId: '<bundle-id>', // 请自行替换
  buildNo: '<build-no>', // 请自行替换
  userAgent: '<jike-sdk-user-agent>', // 请自行替换
  accessToken: '<access-token>', // 请自行替换
}
setApiConfig(apiConfig)

setAccessToken('update-access-token')
api.userRelation.getFollowingList('82D23B32-CF36-4C59-AD6F-D05E3552CBF3', {
  limit: 100,
})

// 或使用 ApiClient
const client = ApiClient(apiConfig)
client.users.profile()

Contributing PRs Welcome

see CONTRIBUTING.md

Sponsors

License

AGPL-3.0 License © 2021-PRESENT 三咲智子

jike-sdk's People

Contributors

leizhenpeng avatar magren0321 avatar renovate[bot] avatar sxzz avatar yes1am avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jike-sdk's Issues

接口跑不通。。。

// package.json
{
  "name": "web3test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "jike-sdk": "^0.7.0"
  },
  "type": "module"
}
// index.mjs
import { api, setAccessToken, ApiClient } from 'jike-sdk/node'

setAccessToken('这里是我的 TOKEN') //TOKEN 取的是在 Cookie 里的 x-jike-access-token 或者 x-jike-refresh-token
api.userRelation.getFollowingList('82D23B32-CF36-4C59-AD6F-D05E3552CBF3', {
  limit: 100,
})

执行:

node index.mjs

返回报错:

.../web3test/node_modules/jike-sdk/dist/node.mjs:97
}, setAccessToken = (token2) => apiConfig.accessToken = token2, getAccessToken = () => apiConfig.accessToken, _request, request = new Proxy(() => {                                                       ssToken, _request, request = new Proxy(() => {   
                                                      ^

TypeError: Cannot set property 'accessToken' of undefined
    at setAccessToken (.../web3test/node_modules/jike-sdk/dist/node.mjs:97:55)
    at .../web3test/index.mjs:7:1
    at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
    at async Loader.import (internal/modules/esm/loader.js:178:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
    at async handleMainPromise (internal/modules/run_main.js:59:12)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/unit-test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • eventemitter3 ^5.0.1
  • ky ^1.2.3
  • @faker-js/faker ^8.4.1
  • @sxzz/eslint-config ^3.9.0
  • @sxzz/prettier-config ^2.0.1
  • @types/md5 ^2.3.5
  • @types/node ^20.12.6
  • @vitest/ui ^2.0.3
  • bumpp ^9.4.0
  • esbuild ^0.20.2
  • eslint ^9.0.0
  • md5 ^2.3.0
  • rollup ^4.14.1
  • serve ^14.2.1
  • sharp ^0.33.3
  • tsup ^8.0.2
  • tsx ^4.7.2
  • typedoc ^0.25.13
  • typescript ^5.4.4
  • vitest ^2.0.3
  • pnpm 9.0.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.