<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "LinkPresentation",
  "identifier" : "/documentation/LinkPresentation/LPMetadataProvider",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Link Presentation"
    ],
    "preciseIdentifier" : "c:objc(cs)LPMetadataProvider"
  },
  "title" : "LPMetadataProvider"
}
-->

# LPMetadataProvider

An object that retrieves metadata for a URL.

```
class LPMetadataProvider
```

## Overview

Use [`LPMetadataProvider`](/documentation/LinkPresentation/LPMetadataProvider) to fetch metadata for a URL, including its title,
icon, and image or video links. All properties on the resulting
[`LPLinkMetadata`](/documentation/LinkPresentation/LPLinkMetadata) instance are optional.

> Note: To enable macOS clients to fetch metadata for remote URLs, add the
> <doc://com.apple.documentation/documentation/BundleResources/Entitlements/com.apple.security.network.client>
> entitlement.

## Fetch link metadata from a URL

For each metadata request, create an instance of [`LPMetadataProvider`](/documentation/LinkPresentation/LPMetadataProvider) and
call [`startFetchingMetadata(for:completionHandler:)`](/documentation/LinkPresentation/LPMetadataProvider/startFetchingMetadata(for:completionHandler:)-54z5i).

In the completion handler, check the error. If your user doesn’t have a
network connection, the fetch can fail. If the server doesn’t respond or is
too slow, the fetch can time out. Alternatively, the app may cancel the
request, or an unknown error may occur.

Otherwise, use the metadata however you want, for example, to populate the
title for a table view cell.

```swift
let metadataProvider = LPMetadataProvider()
let url = URL(string: "https://www.apple.com/ipad")!

metadataProvider.startFetchingMetadata(for: url) { metadata, error in
    if error != nil {
        // The fetch failed; handle the error.
        return
    }

    // Make use of fetched metadata.
}
```

For more information about handling errors, see
[`LPError`](/documentation/LinkPresentation/LPError).

## Topics

### Fetching metadata

[`startFetchingMetadata(for:completionHandler:)`](/documentation/LinkPresentation/LPMetadataProvider/startFetchingMetadata(for:completionHandler:)-54z5i)

Fetches metadata for the given URL.

[`cancel()`](/documentation/LinkPresentation/LPMetadataProvider/cancel())

Cancels a metadata request.

[`shouldFetchSubresources`](/documentation/LinkPresentation/LPMetadataProvider/shouldFetchSubresources)

A Boolean value indicating whether to download subresources specified by the
metadata.

[`timeout`](/documentation/LinkPresentation/LPMetadataProvider/timeout)

The time interval after which the request automatically fails if it hasn’t
already completed.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)