The p2 API is not known for its intuitiveness and requires an Equinox container at runtime. If repository contents should be accessed programmatically this is a bit overkill. So why not hiding all this in a microservice and make the metadata available through a REST API?
This demo shows how to create a microservice from a headless Eclipse application, integrate JAX-RS and accessing p2 API for querying p2 metadata. It is also a blueprint to make other kind of (headless) Eclipse applications accessible via RESTful services.