uri template parser

Parse and evaluate URI templates to generate URLs with specific parameter values.

Sample Upload

URI templates provide a structured method to define how to build a web address for your application programming interface.

RFC 6570 URI Template defines URI schema, which can then be extended to actual URIs schema by replacing variables and extracting variables from a given URI in the opposite way.

This whole process makes matching the URIs on the server side to determine what code to execute.
It is very important for server-side developers to reach an agreement on how to develop the web address

How to use RFC 6570 URI Template?

The RFC 6570 URI template is very useful for expressing the variables in web addresses, such as a query variable or a path variable. 
This can be achieved by adding curly braces on variables.

Here is an example:

http://www.example.com/{?data1,data2}

In this URL, there are two variables:

  1. data1 
  2. data2

So, all you have to do is just to enter the URI template in the “URI Template” box and paste the parameters or variables in JSON format in the “Parameters” input on this tool.

Click on the “Run” button and you can test expansion variables immediately.
Variables Expansion

The variables are handy for expressing UUID’s or ID’s that are usually a part of the URL.

This common schema can be seen in many HTTP APIs. 

A query variable may be defined with curly braces like any other variables, but they have a special syntax in the URI Template.

They are indicated by substituting a question mark sign after the first curly brace. 
After placing this sign, you can add query variables separated by commas without spaces.

Here is a syntax for defining parameters:

/user/{id}/{?data1,data2}

Unsupported things for RFC 6570

Following are some parts that are not supported in RFC 6570 URI Template:

  • Path segment expansion
  • Label expansion
  • Path style parameter expansion

Variables that are written within the curly braces must have unreserved characters’ (percentage encoding). 
It means that characters such as periods, greater than a sign or less than signs must be percentage coded for the URL template to work properly.

However, when you have an unreserved character like a less than, you only need to encode the sign to make it valid. 

Every character in a variable does not have to be encoded.

For example, if you want to add a query variable like object.function, you have to replace the period sign with %2e.

The resulting example will look like the following syntax:

http://example.com/{?object%2efunction}