title: Eureka Getting List of Services
body: <p>How can I fetch the already registered service from eureka?</p>
  
  <p>The below code gives the details about a particular service. But I want the list of the registered services .</p>
  
  <p>Code: </p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.cloud.client.ServiceInstance;
  import org.springframework.cloud.client.discovery.DiscoveryClient;
  import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  import java.util.List;
  
  @EnableDiscoveryClient
  @SpringBootApplication
  public class EurekaClientApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(EurekaClientApplication.class, args);
      }
  }
  
  @RestController
  class ServiceInstanceRestController {
  
      @Autowired
      private DiscoveryClient discoveryClient;
  
      @RequestMapping("/service-instances/{applicationName}")
      public List&lt;ServiceInstance&gt; serviceInstancesByApplicationName(
              @PathVariable String applicationName) {
          return this.discoveryClient.getInstances(applicationName);
      }
  }
  </code></pre>