Since hosted services are registered as singleton, one good approach may be to create a separate singleton class to hold the shared data. So your background service (MyService) can inject this class and update its state. Then you can use anywhere in your API to read this data.