Search code examples
jsonapiparametersurlencodeurl-encoding

How to use the Wayback Machine API with URL query string?


I'm trying to get information with the wayback machine API.

The webpage I'm testing the API with is :

http://www.ifop.com/?option=com_publication&type=poll&id=3367

As you can see here, the webpage is already archived :

https://web.archive.org/web/*/http://www.ifop.com/?option=com_publication&type=poll&id=3367

So when I'm using the API :

http://archive.org/wayback/available?url=http://www.ifop.com/?option=com_publication&type=poll&id=3367

I should get my information but the API answer is empty as if the webpage wasn't archived...

{"archived_snapshots":{}}

I tried to replace & with & but it's still empty...

So my question is : how to use the Wayback Machine API with URL query string ?


Solution

  • Problem:
    The ampersands, even in &, are parsed as additional parameters to the API rather than as part of the url parameter.

    Solution:
    Use %26 to encode the ampersand. Similarly encode the rest of the URL.

    Your request becomes: http://archive.org/wayback/available?url=http%3A%2F%2Fwww.ifop.com%2F%3Foption%3Dcom_publication%26type%3Dpoll%26id%3D3367