Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get last update date for an Algolia index
import dateutil.parser
from datetime import datetime, timezone
import os
from algoliasearch.search_client import SearchClient
from dotenv import load_dotenv, find_dotenv
INDEX_NAME = "address-geo"
client = SearchClient.create(os.getenv("APP_ID"), os.getenv("API_KEY"))
indices = client.list_indices()
updated_at = [
index["updatedAt"] for index in indices["items"] if index["name"] == INDEX_NAME
updated_date = dateutil.parser.isoparse(updated_at)
print(f'Index {INDEX_NAME} last update: {updated_date.strftime("%Y-%m-%d %H:%M:%S")}')
now =
print(f'Current date and time: {now.strftime("%Y-%m-%d %H:%M:%S")}')
print(f"Last update was {now - updated_date} ago")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment