How to consume REST API in Android Studio using Volley?

How to consume REST API in Android Studio using Volley?

API is very useful while working on Web Application. The term API means the interface that consists of endpoints for a request. An API takes request from the client i.e. parameters or the input and processes them to produce desired outputs to give as response. We use APIs by invoking them from our client applications. In this article, I am going to show you how to call an API. We will be using volley library to achieve that. It can be implemented using different libraries also like HttpURLConnectionRetrofit etc. but I prefer to use Volley as it is easy to implement.

Add the INTERNET permission

To use Volley and send requests to API, you must add the android.permission.INTERNET permission to your app’s manifest. This allows your app to connect to the network.


To use volley library with your android application, add dependency to your build.gradle(app level).

dependencies {
    compile ''


final TextView textView = (TextView) findViewById(;
// ...

// Instantiate the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
String url ="";

// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
    public void onResponse(String response) {
        // Display the first 500 characters of the response string.
        textView.setText("Response is: "+ response.substring(0,500));
}, new Response.ErrorListener() {
    public void onErrorResponse(VolleyError error) {
        textView.setText("That didn't work!");

// Add the request to the RequestQueue.
Written by
Nazal TK
Join the discussion


Invalid username or token.