The browser history of Safari is stored in ~/Library/Safari/History.db which is a regular SQLite database. For example, it can be viewed using SQLite Browser or queried using Python.

The database contains a table named history_items. This lists all URL's, with their title, and id and the total number of time the website was visited. Another table is named history_visits. This lists all individual visits, with a timestamp, id and, possibly, information about the source which redirected the user to this website.

In the Chrome browser history, the transition type is also stored. This notes whether the user arrived at the website via a link, a reload or whether he typed in the address directly. Is such transition information also available in the Safari History.db?

The table history_visits also contains integer columns named origin, generation and attributes. However, it is unclear to me what these mean. Is there a documentation available for the Safari browser history database?

1 Answers

buboh On

Checked with my history, the origin column seems to show the origin of the database entry. In my case it was 0 for the MacBook running Safari (where I checked the contents of History.db and 1 for history entries from my iPad (history gets synced over iCloud). The generation column might have something to do with "generations of histories". I found the entries current_generation and last_synced_generation in the metadata table, which would suggest it having something to do with syncing the history to the cloud. This is only an educated guess though. As for attributes I'm still kind of stumped.