Skip to content

feature request: get oldest archived url #7

@sekedus

Description

@sekedus

Please add the "oldest" option to isArchived to get the oldest archives in Wayback Machine.

From: https://news.ycombinator.com/item?id=30085477

The trick is to set the timestamp to be /really/ old and it will show the first snapshot it has.


Example:

// https://archive.org/wayback/available?url=http://github.com&timestamp=19700101000000

const timestamp = new Date('January 1, 1970, UTC').toISOString().replace(/[-:T]/g, '').split('.')[0];
fetch(`https://archive.org/wayback/available?timestamp=${timestamp}&url=http://github.com`)
  .then(response => response.json())
  .then(data => {
    console.log("Wayback Machine response:", data);
    if (data.archived_snapshots && data.archived_snapshots.closest) {
      console.log("Closest snapshot URL:", data.archived_snapshots.closest.url);
    } else {
      console.log("No snapshot available for that timestamp.");
    }
  })
  .catch(error => {
    console.error("Error fetching Wayback data:", error);
  });

Result:

{
  "url": "http://github.com",
  "archived_snapshots": {
    "closest": {
      "status": "200",
      "available": true,
      "url": "http://web.archive.org/web/20080514210148/http://github.com/",
      "timestamp": "20080514210148"
    }
  },
  "timestamp": "19700101000000"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions