How can I retrieve @date information from Google Docs API responses?

I’m trying to get the @date field from a Google Doc using their API. I’ve used the documents.get method with the right documentId, but the JSON response doesn’t show the @date anywhere. Here’s a snippet of what I’m getting back:

{
  "documentContent": {
    "paragraphs": [
      {
        "text": "Sample content",
        "style": {
          "type": "NORMAL",
          "alignment": "LEFT"
        }
      }
    ]
  }
}

Is there a special parameter or method to fetch the @date? I heard something about using Google Drive’s export feature to get a PDF or TXT version, which might include the date. Any tips on how to do this directly through the Docs API would be great. Thanks!

Having worked extensively with the Google Docs API, I can confirm that retrieving the @date field directly isn’t straightforward. In my experience, using the Google Drive API to fetch file metadata offers a reliable alternative. When you call files.get and request the modifiedTime field, you get a timestamp that typically aligns with the document’s date. This approach has worked well in my projects, provided that the proper OAuth scopes are in place. While exporting to PDF or TXT might capture additional details, using modifiedTime is less resource-intensive and usually satisfies most requirements.

hey laura, i’ve run into this too. the docs api is kinda limited for dates. u could try using the drive api instead - grab the file metadata with files.get and look at the ‘modifiedTime’ field. it’s usually pretty close to the @date. not perfect but worked ok for me in most cases. good luck!

I’ve faced a similar issue before, and unfortunately, the Google Docs API doesn’t directly expose the @date field in its standard response. However, there’s a workaround you can try. Instead of using documents.get, you can use the revisions.list method. This method returns metadata about document revisions, including timestamps. The most recent revision’s timestamp usually corresponds to the @date you’re looking for. Here’s a quick example:

GET https://docs.googleapis.com/v1/documents/{documentId}/revisions

This should return a list of revisions with their corresponding timestamps. Keep in mind that you might need additional scopes for this method. If you absolutely need the exact @date field, the Google Drive API route you mentioned might be your best bet, but it’s more complex to implement.