How to do I/O file operation in my extension?

In my extension, I want to list all the files in a directory, and find ones with prefix name ‘jupyter’ (not in the original file system, it’s a main-area widget feature), how to do it with jupyterlab API?

You will want to hit the api/contents/ endpoint which will return JSON of the directory. It is not recursive but will tell you if each item is a file or a directory. It starts from your defined notebooks directory (such as /home/jovyan) and goes down.

api/contents/foo would then be the directory listing of //foo

could you please elaborate a bit more on the ‘api/contents’ API you’ve mentioned here? Is this a REST API or is it available in one of the libraries?