mangadex-api:适用于Node.js的Mangadex API包装器

  • h3_846836
    了解作者
  • 171KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 03:20
    上传日期
Mangadex-api 这是网站api包装器。 额外资源 是公共端点。 支持缓存(在内存中)和所有不需要授权的公共MD-API。 () 使用mangadex-heroku进行API调用的 。 安装 npm i mangadex-api # or yarn add mangadex-api 例子 const { Mangadex } = require ( 'mangadex-api' ) Mangadex . manga . getManga ( 22723 ) . then ( ( manga ) => { console . log ( `Manga ${ manga . title } has ${ manga . follows } followers` ) Mangadex . manga . getMangaChapters ( 22723 ) . then (
mangadex-api-master.zip
  • mangadex-api-master
  • jest
  • get-test-client.ts
    856B
  • jest.setup.ts
    23B
  • schema
  • tag.ts
    468B
  • partial-base.ts
    129B
  • chapter.ts
    2KB
  • mangadex.ts
    3KB
  • group.ts
    1.1KB
  • user.ts
    2.9KB
  • manga.ts
    2.2KB
  • .github
  • workflows
  • codecov.yml
    822B
  • deploy-docs.yml
    671B
  • tests.yml
    1.2KB
  • linting.yml
    373B
  • docs-favicon.ico
    118.2KB
  • src
  • Mangadex.ts
    6.6KB
  • index.ts
    126B
  • Agent.ts
    12.8KB
  • lib
  • options.ts
    107B
  • normalize.ts
    907B
  • links.ts
    913B
  • sleep.ts
    114B
  • error.ts
    277B
  • deepmerge.ts
    900B
  • multipart.ts
    346B
  • get-search-headers.ts
    1.1KB
  • get-query.ts
    1.2KB
  • api
  • tag.ts
    1.4KB
  • base.ts
    716B
  • index.ts
    119B
  • chapter.ts
    1.6KB
  • group.ts
    1.9KB
  • user.ts
    7.4KB
  • manga.ts
    2.7KB
  • Scraper.ts
    12.8KB
  • Composer.ts
    982B
  • .vscode
  • launch.json
    496B
  • settings.json
    266B
  • typedoc.json
    261B
  • types
  • mangadex.d.ts
    9.3KB
  • domhandler.d.ts
    2KB
  • index.d.ts
    109B
  • agent.d.ts
    1.3KB
  • cheerio.d.ts
    8.3KB
  • language.d.ts
    365B
  • tsconfig.json
    357B
  • LICENSE
    1KB
  • __tests__
  • agent.test.ts
    1KB
  • manga.test.ts
    1.9KB
  • tag.test.ts
    1.2KB
  • group.test.ts
    1.3KB
  • mangadex.test.ts
    3KB
  • chapter.test.ts
    1.3KB
  • user.test.ts
    2.8KB
  • langcodes.json
    777B
  • .env.sample
    53B
  • .gitignore
    80B
  • readme.md
    5.6KB
  • package-lock.json
    368.8KB
  • package.json
    3.3KB
内容介绍
# Mangadex-api [![NPM Version](https://img.shields.io/npm/v/mangadex-api.svg?style=flat-square)](https://www.npmjs.com/package/mangadex-api) [![npm downloads](https://img.shields.io/npm/dm/mangadex-api.svg?style=flat-square)](http://npm-stat.com/charts.html?package=mangadex-api) [![License](https://img.shields.io/npm/l/mangadex-api?style=flat-square)](https://github.com/ejnshtein/mangadex-api) [![codecov](https://codecov.io/gh/ejnshtein/mangadex-api/branch/master/graph/badge.svg)](https://codecov.io/gh/ejnshtein/mangadex-api) This is [Mangadex](https://mangadex.org) website api wrapper. ## Additional resources - [mangadex-heroku](https://github.com/ejnshtein/mangadex-heroku) is a [GraphQL](https://graphql.org/) public endpoint. Supports caching (in memory) and all public MD-API's that doesn't require authorization. ([playground](http://mangadex.herokuapp.com/graphql)) - [Example webapp](https://codesandbox.io/s/condescending-kirch-u71ji?file=/src/index.js) that uses mangadex-heroku for API calls. ## Installation ```bash npm i mangadex-api # or yarn add mangadex-api ``` ## Example ```js const { Mangadex } = require('mangadex-api') Mangadex.manga.getManga(22723).then((manga) => { console.log(`Manga ${manga.title} has ${manga.follows} followers`) Mangadex.manga.getMangaChapters(22723).then(({ chapters, groups }) => { console.log(`Manga ${manga.title} has ${chapters.length} chapters`) console.log(`Manga ${manga.title} has ${groups.length} scanlated groups`) }) }) Mangadex.chapter.getChapter(8857).then((chapter) => { console.log( `Chapter title is "${chapter.title}" and it is ${chapter.chapter} chapter from ${chapter.volume} volume.` ) }) // currently requires authorization Mangadex.search('senko').then((response) => { console.log(`Found ${response.titles.length} titles.`) }) // Search with NSFW results Mangadex.search({ title: 'gotoubun', with_hentai: true }).then(result => { console.log(`Found ${result.titles.filter(title => title.is_hentai).length} hentai manga (☞ ͡ ͡° ͜ ʖ ͡ ͡°)☞`) }) Mangadex.getHome().then((home) => { if (home.accouncement) { console.log(`New accouncement!\n${home.accouncement.text}`) } console.log( `Todays top manga by follows is: ${home.top_manga.follows[0].title}` ) console.log( `Todays top chapter is from manga: ${home.top_chapters.day[0].title}` ) console.log( `Latest chapter is from manga: ${home.latest_updates.all[0].title}` ) }) Mangadex.group.getGroup(12).then((group) => { console.log( `Group ${group.name} has ${group.stats.follows} followers and ${group.stats.total_chapters} total chapters uploaded!` ) }) ``` ## Authorization example ```js const { Mangadex } = require('mangadex-api') const client = new Mangadex() await client.agent.login('username', 'password', false) const result = await client.search('To Be Winner') console.log(result) // { titles: [{ title: 'To Be Winner', ... }] } ``` ## Cached session example ```js // first you must save your session somewhere await client.agent.login('username', 'password', false) await client.agent.saveSession('/path/to/session')) // now we can use it await client.agent.loginWithSession('/path/to/session') const me = await client.getMe()) console.log(me) ``` ## Migration to version 4 Main focuses in V4 were [Typescript](https://www.typescriptlang.org/) and [Mangadex](https://mangadex.org/) [API V2](https://mangadex.org/thread/351011). So V1 support was dropped completely. If you still, for some reason, want to use API V1 then use `agent.callApi(endpoint, { baseUrl: 'https://mangadex.org/api' })` code snippet to request data from API V1. So there're new api groups: - chapter/{id|hash} - follows - group/{id} - group/{id}/chapters - manga/{id} - manga/{id}/chapters - manga/{id}/covers - relations - tag - tag/{id} - user/{id} - user/{id}/chapters - user/{id}/followed-manga - user/{id}/followed-updates - user/{id}/manga/{mangaId} - user/{id}/ratings - user/{id}/settings - user/{id}/marker Each of them is available on `Mangadex` instance via these properties: ```js const client = new Mangadex() // don't forget to login await client.agent.login(username, password) // and here we go // chapter/{id|hash} client.chapter.getChapter(chapterId) // follows client.getFollows() // group/{id} client.group.getGroup(groupId) // group/{id}/chapters client.group.getGroupChapters(groupId) // manga/{id} client.manga.getManga(mangaId) // manga/{id}/chapters client.manga.getMangaChapters(mangaId) // manga/{id}/covers client.manga.getMangaCovers(mangaId) // relations client.getRelations() // tag client.tag.getTags() // tag/{id} client.tag.getTag(tagId) // user/{id} client.user.getUser(userId) // user/{id}/chapters client.user.getUserChapters(userId) // user/{id}/followed-updates client.user.getUserFollowedUpdates(userId) // user/{id}/manga/{mangaId} client.user.getUserManga(userId, mangaId) // user/{id}/ratings client.user.getUserRatings(userId) // user/{id}/settings client.user.getUserSettings(userId) // user/{id}/followed-manga client.user.getUserFollowedManga(userId) // user/{id}/marker client.user.setUserChapterRead(userId, chapters, read) ``` ## Migration to version 3 LRU cache was removed from package, so you'll have to implement caching by yourself. [Mangadex constructor](#Mangadex) now accepts only 2 options. [getManga](#getManga) and [getChapter](#getChapter) lost **normalize** argument, now it's on **by default**. ## API API section is available on the [website](https://ejnshtein.github.io/mangadex-api/). --- ## Contact [My telegram](https://t.me/ejnshtein) and a [group](https://t.me/nyaasi_chat) where you can ask your questions or suggest something.
评论
    相关推荐
    • cache-helpers:缓存Node.JS的帮助器功能
      cache-helpers是一个Node.JS模块,其中包含几个通用的缓存功能。 编写它是为了提取中的许多常用模式。 cacheHelpers.once :采用一个(可能很昂贵)函数,该函数接受单个回调,并使用可选的error参数和data参数调用...
    • LRU-Cache:通过Node.js实现LRU缓存
      Node.js中的LRU缓存实现 用法 const lru = require ( 'LRU-Cache' ) ; 。放 capacity -列表容量,不允许0,默认值:1000 maxAge节点将在maxAge ms内自行销毁 const cache = new lru ( { capacity : 100 } ) ; cache...
    • Node.js的源代码和解析缓存-Node.js开发
      Node.jsnode-voo源缓存为执行的javascript文件创建v8缓存数据。 对一起使用的javascript文件进行分组。 (这些组称为“ Voo”。)将缓存文件存储到系统中。temp Director node-voo Node.js的源缓存为执行的...
    • Node.js-基于Redis的Node.jsLRU缓存
      基于Redis的Node.js LRU缓存
    • node-cache:Node.js缓存系统
      该软件包为Node.js提供了一个缓存系统。 可以为缓存中的项目指定最长使用期限,之后它们会自动失效。 每5分钟清理一次缓存。 也可以从缓存中删除最近最少使用的项目。 去做 如果可能,请监视内存使用情况。 当使用...
    • nodejs-buffer:Node.js缓存模块Buffer
      Node.js继承Javascript的语言特性,同时又扩展了Javascript语言,为二进制的数据处理提供了Buffer类,让Node.js可以像其他程序语言一样,能处理各种类型的数据了。 网上有很多讲Buffer的文章,大都讲的是原理,怎么...
    • Redis支持的Node.js LRU缓存-Node.js开发
      redis lru缓存Redis支持的最近最少使用(LRU)缓存,允许多个Node.JS进程共享数据。 受node-lru-cache启发的API。 var redis = require('redis')。createClient(port,host,opts); var lru redis lru缓存由...
    • Node.js-Node.js的源代码和解析缓存
      Node.js的源代码和解析缓存
    • cache-stream:缓存Node.js流2 API的流
      实现Node.js v0.10 +的Stream2接口的简单流模块 安装: $ npm i cache-stream var cacheStream = require ( 'cache-stream' ) , cache = cacheStream ( ) ; fs . createReadStream ( path . join ( __dirname , ...
    • abuse-cfg:滥用 node.js 模块缓存
      滥用 node.js 模块缓存! 读取配置文件 不要在家尝试做这个。 例如用法阅读测试或来源。 动机 每次有人执行global.app = app来读取某种配置时,仙女就会死! 执照 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE ...