Rest Assured – Query Parameter vs. Path Parameter

What is Query Parameter in Rest API?

We can use query parameters to control what data is returned in endpoint resources. It appears at the end of the URL after the question mark (?) and helps us to control the set of items and properties in responses, and the order of the items returned.

Consider the following GitHub API url:

This will list all repositories for an authenticated user but the response properties will be sorted by repository created and in descending order.

There are two query parameters defined in the API url:

– sort=created (sort repositories by created date)

– direction=desc (sort in descending order)

What is Path Parameters in Rest API?

Path parameters are variables in a URL path. They are used to point to a specific resource within a collection. We can define multiple PATH parameters and each of them is  represented by a curly brace {}.

Consider the following GitHub API url:

This will list all public repositories for the specified user with the value username.

:username is the Path parameter in the above url.

How to pass Query Paramter and Path Parameter using Rest Assured?

public class GithubAPITest {

    String apiToken = "your api token";
    String url = "";

    //To pass query parameters in the API URL
    public void verifyRepos(){
        String url_new = url + "/user/repos";

    //To pass path parameters in the API URL
    public void getRepoForSpecificUser(){

        String apiURL = url + "/users/{username}/repos";



Bijan Patel

Founder & Creator of QAScript | 12+ years of IT Experience | Full Stack Automation Engineer | Blogger | Trainer

You may also like...

1 Response

  1. Sunil Kirangi says:

    Hello Bijan,
    I am interested in enrolling for BDD framework course.
    Is it possible to take classes online.
    Sunil Kirangi

Leave a Reply

Your email address will not be published.