AMP
  • websites

Using the AMP URL API

Introduction

The AMP URL API retrieves the matching AMP URLs for a given list of URLs. Apps can use this if they want to load the fast AMPs instead of the original URL, for example, when opening external links.

The URL API returns for a given URL with matchin AMP version three different URLs:

  • originalUrl: the unmodified original URL.
  • ampUrl: the URL of the AMP version.
  • cdnAmpUrl: the URL of the cached AMP version in the Google AMP Cache.

For performance and security reasons we recommend using the cached AMP version when displaying AMP content.

See how it works

Press execute to perform a live query against the AMP URL API. Change the input query and try different URLs.

<amp-iframe title="Performs a live query against the AMP URL API"
            width="auto" height="645"
            layout="fixed-height"
            sandbox="allow-scripts allow-same-origin allow-popups"
            allowfullscreen
            frameborder="0"
            src="/static/samples/files/amp-url-api.html">
            <amp-img src="/static/samples/img/amp-url-api-placeholder.png"
             layout="fixed-height"
             height="645"
             placeholder>
             </amp-img>
 </amp-iframe>
Bạn cần được giải thích thêm?

Nếu bạn vẫn còn thắc mắc sau khi đọc hướng dẫn trên trang này, hãy liên hệ với những người dùng AMP khác để thảo luận về trường hợp sử dụng cụ thể của bạn.

Truy cập Stack Overflow
Một tính năng chưa được giải thích?

Dự án AMP đặc biệt khuyến khích sự tham gia và đóng góp của bạn! Chúng tôi hi vọng bạn sẽ trở thành một người tham gia tích cực trong cộng đồng mã nguồn mở của chúng tôi, nhưng chúng tôi cũng chào mừng các đóng góp đơn lẻ về vấn đề mà bạn đặc biệt quan tâm.

Chỉnh sửa mẫu trên GitHub