Add an API

Published on

Add an API

To add a reference page for a Chrome API, create a folder and index.md file inside site/en/docs/extensions/reference/. The folder name doesn't directly relate to the API itself—control which API is rendered via frontmatter like this:

---
api: browserAction
---


Something about this API. This text is completely optional. If you don't want to write anything,
then you should include a comment like <!-- This is intentionally empty -->.

The API name is assumed to be under "chrome.apiName". If you are documenting an API like "chrome.input.ime", then by convention, the folder name should be "input_ime" but the API in your frontmatter should still be api: input.ime.

The existence of this page will cause the API itself to be displayed in the top-level reference page. If it's a Chrome Apps-only API, it will appear at the very bottom of that page, rather than in Stable, Beta or Dev.

API Source

The API reference is generated via the published APIs in chrome-types on npm. It's possible for that dependency to get out-of-date; if you're trying to document a new API, take these steps:

  • Run npm install chrome-types to ensure that latest version is available.
  • Run npm run types to build our fast internal reprensetation of the TypeScript definition files (this normally happens on checkout, but since you've updated the types, it needs a re-run)

If you're just curious about what APIs are published (and not all are documented, matching the previous incanation of this site) then take a look inside node_modules/chrome-types/index.d.ts (or its peer file platform_app.d.ts for Chrome Apps-only APIs).

Updating APIs

Our TypeScript definition files are generated by running "npm deploy" from within the npm subfolder of that repo, which will check out the right parts of Chromium and automatically build the TypeScript definition files.

As of December 2020, this still needs to be done manually, and just deploys types from Chrome's HEAD revision. See its issue tracker for updates.

Updated on Improve article

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.