# uri-template

> Parse and expand URI templates as defined by http://tools.ietf.org/html/rfc6570

Latest version **2.0.0** (published 2021-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install uri-template
pnpm add uri-template
yarn add uri-template
bun add uri-template
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2021-10-24 |
| First published | 2011-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 62.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Stephen Sugden |
| Maintainers | andreineculau, grncdr |

## Links

- npm: https://www.npmjs.com/package/uri-template
- Repository: https://github.com/grncdr/uri-template
- Homepage: https://github.com/grncdr/uri-template#readme
- Issues: https://github.com/grncdr/uri-template/issues
- npm.io page: https://npm.io/package/uri-template

## Dependencies (1)

- [pct-encode](https://npm.io/package/pct-encode.md) ~1.0.0

## Recent versions

- 2.0.0 (latest) — 2021-10-24
- 1.0.3 — 2021-10-16
- 1.0.2 — 2021-10-16
- 1.0.1 — 2016-06-18
- 1.0.0 — 2015-01-15
- 0.4.1 — 2013-06-25
- 0.4.0 — 2013-06-24
- 0.3.3 — 2013-03-20
- 0.3.4 — 2013-03-20
- 0.3.2 — 2012-05-21
- 0.3.1 — 2012-04-10
- 0.2.1 — 2012-04-06
- 0.3.0 — 2012-04-06
- 0.2.0 — 2012-03-27
- 0.1.2 — 2012-01-10
- … 6 more at https://npm.io/package/uri-template/versions

## README

# URI Template

[![Node.js CI](https://github.com/grncdr/uri-template/actions/workflows/nodejs.yml/badge.svg)](https://github.com/grncdr/uri-template/actions/workflows/nodejs.yml)

This is a node.js implementation of the URI template draft standard
defined at http://tools.ietf.org/html/rfc6570

## Example

```javascript
var parser = require("uri-template");

var tpl = parser.parse("/{year}/{month}/{day}{?orderBy,direction}");

tpl.expand({ year: 2006, month: 6, day: 6 });
// /2006/6/6

tpl.expand({ year: 2006, month: 6, day: 6, orderBy: "size" });
// /2006/6/6?orderBy=size

tpl.expand({ year: 2006, month: 6, day: 6, orderBy: "time", direction: "asc" });
// /2006/6/6?orderBy=time&direction=asc

var queryTpl = parser.parse("/search{?q,otherParams*}");
queryTpl.expand({
  q: "Bigger office",
  otherParams: { prefer: "Sterling's office", accept: "Crane's office" },
});
// /search?q=Bigger%20office&prefer=Sterling%27s%20office&accept=Crane%27s%20office
```

For more thorough coverage of the syntax, see the [RFC](https://datatracker.ietf.org/doc/html/rfc6570).

##

---
_Source: https://npm.io/package/uri-template · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
