Using the AMP URL API
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="https://amp-by-example-api.appspot.com/iframe/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>
If the explanations on this page don't cover all of your questions feel free to reach out to other AMP users to discuss your exact use case.Go to Stack Overflow An unexplained feature?
The AMP project strongly encourages your participation and contributions! We hope you'll become an ongoing participant in our open source community but we also welcome one-off contributions for the issues you're particularly passionate about.Edit sample on GitHub
Written by @sebastianbenz