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

@taoya7/apk-parse

v1.0.1

Published

A TypeScript library for parsing Android APK files

Readme

@taoya7/apk-parse

npm version

一个用于解析 Android APK 文件的 TypeScript 库。

功能特性

  • 解析 APK 基本信息(包名、版本、应用名称等)
  • 提取应用图标并转换为 base64 格式
  • 获取权限列表
  • 支持文件路径和 Buffer 两种输入方式
  • 支持资源混淆的 APK 文件
  • 完整的 TypeScript 类型支持

安装

npm install @taoya7/apk-parse

快速开始

基本用法

import { parseApk } from '@taoya7/apk-parse'

// 从文件路径解析
const info = await parseApk('/path/to/app.apk')

console.log(info.packageName)      // com.example.app
console.log(info.versionName)      // 1.0.0
console.log(info.applicationLabel) // 我的应用
console.log(info.icon)             // data:image/png;base64,...

从 Buffer 解析

import { parseApk } from '@taoya7/apk-parse'
import * as fs from 'fs/promises'

const buffer = await fs.readFile('/path/to/app.apk')
const info = await parseApk(buffer)

高级用法

import { createApkParser } from '@taoya7/apk-parse'

const { info, parser } = await createApkParser('/path/to/app.apk')

// 获取 APK 中的文件列表
const files = await parser.getFileList()

// 读取 APK 中的文件
const fileContent = await parser.readFile('assets/config.json')

// 单独获取图标
const iconBuffer = await parser.getIcon()
const iconBase64 = await parser.getIconBase64()

返回数据结构

interface ApkInfo {
  packageName: string      // 包名 (例如: com.example.app)
  versionCode: number      // 版本号 (整数)
  versionName: string      // 版本名称 (例如: "1.0.0")
  applicationLabel: string // 应用名称
  minSdkVersion: number    // 最低 SDK 版本
  targetSdkVersion: number // 目标 SDK 版本
  compileSdkVersion?: number // 编译 SDK 版本 (可选)
  permissions: string[]    // 权限列表
  icon?: string            // 应用图标 base64 (data URI 格式)
}

示例输出

Package Name:     com.github.metacubex.clash.meta
Version Code:     211016
Version Name:     2.11.16.Meta
Application:      Clash Meta for Android
Min SDK:          21
Target SDK:       35
Compile SDK:      35
Permissions:      9
Icon:             data:image/png;base64,iVBORw0KGgo...

在 HTML 中使用图标

<img :src="info.icon" alt="App Icon" />

API 参考

parseApk(input, options?)

快速解析 APK 文件。

  • input: 文件路径 (string) 或 Buffer
  • options: 可选配置
  • 返回: Promise<ApkInfo>

createApkParser(input, options?)

创建解析器实例,可进行更多操作。

  • input: 文件路径 (string) 或 Buffer
  • options: 可选配置
  • 返回: Promise<{ info: ApkInfo, parser: ApkParser }>

ApkParser 类方法

  • parseFromFile(filePath): 从文件解析
  • parseFromBuffer(buffer): 从 Buffer 解析
  • getIcon(): 获取图标 Buffer
  • getIconBase64(): 获取图标 base64 字符串
  • getFileList(): 获取文件列表
  • readFile(path): 读取指定文件

开发

# 安装依赖
npm install

# 运行测试
npm run test

# 构建
npm run build

技术实现

  • 使用 jszip 解压 APK 文件
  • 实现了 Android 二进制 XML (AXML) 解析器
  • 实现了 resources.arsc 资源表解析器
  • 支持递归解析资源引用

License

MIT