> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data.md).

# Fetching Data

Learn how to request data when extending the Backoffice.

{% hint style="info" %}
Coming from `$http` in Umbraco 13? The Umbraco HTTP Client replaces `$http`, and `tryExecute` replaces `umbRequestHelper.resourcePromise`. For more AngularJS equivalents, see the [Migrate Backoffice Extensions from AngularJS](/umbraco-cms/17.latest/get-started/upgrading-and-migrating/find-your-upgrade-path/migrate-backoffice-extensions-from-angularjs.md) article.
{% endhint %}

## Choose How to Fetch Data

Your extension can request data from Umbraco, from your own API controllers, and from third-party APIs. Choose the option that fits the API you call:

| Option                                                                                                                                          | Use it for                                                        | What you get                                                                                                                                                                                                                                                                                                        |
| ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Umbraco HTTP Client](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/http-client.md)                 | The Management API, and direct calls to your own API controllers. | Authentication, the login prompt when the session expires, error handling, and notifications.                                                                                                                                                                                                                       |
| [Custom Generated Client](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/custom-generated-client.md) | Your own API controllers.                                         | A typed function for each endpoint. Configured with `configureClient()`, the client handles authentication and the login prompt like the Umbraco HTTP Client. To show a notification from `tryExecute` when a request fails, also set `throwOnError`. The Umbraco Extension Template configures the client for you. |
| [Fetch API](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/fetch-api.md)                             | Third-party APIs.                                                 | A plain request. You handle authentication and errors yourself.                                                                                                                                                                                                                                                     |

Wrap requests to Umbraco and to your own API in [`tryExecute`](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/try-execute.md), which shows a notification when a request throws an error.

### [Umbraco HTTP Client](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/http-client.md)

The Umbraco HTTP Client, `umbHttpClient`, is the client the backoffice uses for its own requests. It adds the access token of the current user. When the session expires, it asks the user to log in again. The [Umbraco HTTP Client](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/http-client.md) article lists what it handles.

### [Custom Generated Client](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/custom-generated-client.md)

A generated client gives you a typed function for each endpoint of your API. The [`@hey-api/openapi-ts`](https://github.com/hey-api/openapi-ts) library generates it from the OpenAPI document of your API. Configure your client with `configureClient()`. Your client then handles authentication and the login prompt like the Umbraco HTTP Client. To show a notification from `tryExecute` when a request fails, also set `throwOnError`.

### [Fetch API](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/fetch-api.md)

Use the Fetch API for third-party APIs, and when you cannot use the Umbraco HTTP Client. The Umbraco HTTP Client treats a 401 response as an expired backoffice session, so it doesn't suit a third-party API. A request with the Fetch API doesn't get the token, the error handling, or the notifications of the backoffice.

## [Executing Requests](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data/try-execute.md)

The `tryExecute` function runs a request, and shows a notification when the request throws an error. It returns the data or the error, so you don't need a `try...catch` block.

## [Repositories](/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/repositories.md)

Repositories provide a structured way to manage data operations in the Backoffice. They abstract the data access layer, allowing for easier maintenance and scalability.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-cms/17.latest/extend-your-project/backoffice-extensions/foundation/fetching-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
