npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ratapi

v1.0.0

Published

RatAPI是一个Node.js模块,用于调用各种常用API

Downloads

63

Readme

RatAPI

一个快速调用API的npm包,基于Axios实现HTTP请求,方便Node.js项目调用各种常用API。

安装

使用pnpm安装:

pnpm add ratapi

使用npm安装:

npm install ratapi

使用示例

初始化

const ratapi = require('ratapi');

调用DeepSeek V3.2 API

async function example() {
  try {
    const result = await ratapi.deepSeek('你好,世界!', {
      system: '你是一个智能助手',
      type: 'text'
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

example();

调用快手可图绘画API

async function example() {
  try {
    const result = await ratapi.ksDraw('一只可爱的小猫', {
      size: '512x512',
      guidance: 7.5,
      batch: 1
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

example();

调用必应新闻资讯API

async function example() {
  try {
    const result = await ratapi.bingNews({
      page: 5,
      type: 'json'
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

example();

调用聚合语音生成API

async function example() {
  try {
    const result = await ratapi.voiceGenerate('欢迎使用RatAPI', {
      voice: '标准女声',
      format: 'mp3',
      download: false
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

example();

通用GET请求

async function example() {
  try {
    const result = await ratapi.get('example.php', {
      param1: 'value1',
      param2: 'value2'
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

example();

通用POST请求

async function example() {
  try {
    const result = await ratapi.post('example.php', {
      param1: 'value1',
      param2: 'value2'
    });
    console.log(result);
  } catch (error) {
    console.error(error);
  }
}

example();

API文档

deepSeek(question, options)

调用DeepSeek V3.2 API

  • question (string): 提问内容
  • options (object): 可选参数
    • system (string): 模型提示词
    • type (string): 支持text和json两种返回方式,不填写默认text,填true为纯文本输出
  • 返回值: Promise - API响应内容

ksDraw(msg, options)

调用快手可图绘画API

  • msg (string): 绘画内容
  • options (object): 可选参数
    • size (string): 图像大小,支持256x256, 512x512, 768x768, 1024x1024, 1536x1536。默认1024x1024大小
    • guidance (number): 【1-10任选,默认7.5】控制生成的图像与给定提示之间的匹配程度
    • batch (number): 输出的图像数量,最大支持4张,默认为1张
  • 返回值: Promise - API响应内容

bingNews(options)

调用必应新闻资讯API

  • options (object): 可选参数
    • page (string): 获取的新闻数量,支持1-100个或者auto获取全部,不填写默认返回前10个
    • type (string): 返回的数据格式,支持json和text,不填写默认返回json格式
  • 返回值: Promise - API响应内容

voiceGenerate(msg, options)

调用聚合语音生成API

  • msg (string): 生成内容
  • options (object): 可选参数
    • voice (string): 语音生成的音色,不填写任何参数会输出支持的所有语音列表,默认使用标准女声
    • format (string): 语音转化格式,支持mp3和wav,不填写默认返回mp3
    • download (boolean): 语音返回格式,支持true(直接返回下载音频)和false(直接返回json数据),不填写默认为false
  • 返回值: Promise - API响应内容

get(endpoint, params)

通用GET请求方法

  • endpoint (string): API端点
  • params (object): 请求参数
  • 返回值: Promise - API响应内容

post(endpoint, data)

通用POST请求方法

  • endpoint (string): API端点
  • data (object): 请求数据
  • 返回值: Promise - API响应内容

测试

运行测试:

pnpm test

npm test

注意事项

  1. 本包基于yunzhiapi.cn提供的API接口,使用前请确保您了解并遵守相关API的使用条款
  2. 部分API可能需要申请API密钥,请根据实际情况进行配置
  3. 如有任何问题,请提交issue或联系作者

许可证

MIT