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

node-apk-ts

v2.0.1

Published

A library to parse Android application manifest and signature

Readme

Node APK

A modern library to parse Android application's manifest and signature.

Requirements

  • Node.js 20 or later
  • ESM module system (no CommonJS support)

Installation

npm install node-apk

TypeScript is highly recommended — this library has full type support.

Usage

Import the Apk class and instantiate it with your APK's file path or Buffer:

import { Apk } from "node-apk";

const apk = new Apk("yourapplication.apk");
// Or with a Buffer:
// const apk = new Apk(buffer);

Manifest information

const manifest = await apk.getManifestInfo();

console.log(`package = ${manifest.package}`);
console.log(`versionCode = ${manifest.versionCode}`);
console.log(`versionName = ${manifest.versionName}`);

// For properties without existing accessors, use the raw binary XML
console.log(JSON.stringify(manifest.raw, null, 4));

Certificate information

const certs = await apk.getCertificateInfo();

for (const cert of certs) {
  console.log(`issuer = ${cert.issuer.get("CN")}`);
  console.log(`subject = ${cert.subject.get("CN")}`);
  console.log(`validUntil = ${cert.validUntil}`);
  console.log(cert.bytes.toString("base64"));
  
  // Access the certificate chain
  for (const chainCert of cert.chain) {
    console.log(`  chain: ${chainCert.subject.get("CN")}`);
  }
}

App label (helper)

// Get the app label, optionally preferring a specific locale
const label = await apk.getLabel();
const frenchLabel = await apk.getLabel({ locale: "fr" });
console.log(`label = ${label}`);

Launcher icon (helper)

// Get the launcher icon as a Buffer (PNG or WebP format)
const icon = await apk.getLauncherIcon();

// Prefer a specific density
const hdpiIcon = await apk.getLauncherIcon({ density: "hdpi" });

// Save to file
import { writeFile } from "node:fs/promises";
await writeFile("icon.png", icon);

Application resources (low-level)

For advanced use cases, access resources directly:

const [manifest, resources] = await Promise.all([
  apk.getManifestInfo(),
  apk.getResources(),
]);

// Resolve a resource ID to all its localized values
const labelId = manifest.applicationLabel;
if (typeof labelId === "number") {
  const all = resources.resolve(labelId);
  const frenchResource = all.find((res) => res.locale?.language === "fr");
  const label = (frenchResource ?? all[0])?.value;
  console.log(`label = ${label}`);
}

// Resolve and extract a specific resource
const iconId = manifest.applicationIcon;
const iconResource = resources.resolve(iconId)[0];
if (iconResource) {
  const iconBytes = await apk.extract(`res/${iconResource.value}.png`);
}

Extract arbitrary files

const fileContent = await apk.extract("assets/data.json");

API

Apk

The main class for parsing APK files.

Constructor

  • new Apk(input: string | Buffer) — Create an Apk instance from a file path or Buffer.

Methods

  • getManifestInfo(): Promise<Manifest> — Parse and return the AndroidManifest.xml.
  • getCertificateInfo(): Promise<Certificate[]> — Extract and return signing certificates.
  • getResources(): Promise<Resources> — Parse and return the resources.arsc.
  • extract(key: string): Promise<Buffer> — Extract a file from the APK by path.
  • getLabel(options?): Promise<string> — Get the resolved app label from resources. Options: { locale?: string } to prefer a specific locale.
  • getLauncherIcon(options?): Promise<Buffer> — Get the launcher icon as a Buffer (PNG or WebP). Options: { density?: "mdpi" | "hdpi" | "xhdpi" | "xxhdpi" | "xxxhdpi" } to prefer a specific density.

Manifest

Represents the parsed AndroidManifest.xml.

Properties

  • package: string — The package name.
  • versionCode: number — The version code.
  • versionName: string — The version name.
  • applicationLabel: string | number — The application label (string or resource ID).
  • applicationIcon: number — The application icon resource ID.
  • permissions: Iterable<string> — Required permissions.
  • receivers: Iterable<Receiver> — Broadcast receivers.
  • raw: XmlElement — The raw XML element tree.

Certificate

Represents a signing certificate.

Properties

  • serial: string — The certificate serial number.
  • validFrom: Date — Validity start date.
  • validUntil: Date — Validity end date.
  • issuer: Map<string, string> — Issuer attributes.
  • subject: Map<string, string> — Subject attributes.
  • bytes: Buffer — The raw certificate bytes (DER encoded).
  • parent?: Certificate — The parent certificate in the chain.
  • chain: Certificate[] — The full certificate chain.

Resources

Resource table parser.

Methods

  • resolve(id: number): Resource[] — Resolve a resource ID to its values.

Resource

A resolved resource value.

Properties

  • value: ResourceValue — The resource value (string, number, boolean, or null).
  • locale?: Locale — The locale if the resource is localized.

Migration from v1.x

Version 2.0 is a complete rewrite with breaking changes:

ESM Only

This package now requires ESM. CommonJS is not supported.

// package.json must have:
{
  "type": "module"
}

Named Exports Only

Default export has been removed. Use named exports:

// v1.x
import Apk from "node-apk";

// v2.x
import { Apk } from "node-apk";

Async/Await

All methods now return Promises. Use async/await:

// v1.x
apk.getManifestInfo().then((manifest) => { ... });

// v2.x
const manifest = await apk.getManifestInfo();

Removed close() Method

The close() method has been removed as it was a no-op.

// v1.x
apk.close();

// v2.x - no cleanup needed

License

This software is licensed under the MIT license.

Copyright © 2019-2024 All rights reserved. sRaH