I downloaded and published my Instagram archive

With the death of the Instagram API and it coinciding with my move towards the indieweb, I decided to download my Instagram archive and host them on my own site.

It was actually Timehop that notified me about the Instagram API dying. I would not be able to see my photos in their app.

I had set my Instagram to private a couple of years ago and haven't really posted much either. My last photo was from 2022. So I'm not really invested in Instagram, per se.

Of course this now changed with my new-found passion of the indieweb.
And so, I set out to create to a script that could read your Instagram archive and converts your posts to Kindy posts. (My internal content management system, thingamabob)

Resulting in my own instagram-esque Photos page.

Programmer troubles

For quick and dirty code, or for your initial Go struct, I like to use this tool called JSON-to-Go. Which gave me the following monstrosity.

// removed some tabs for readability
type AutoGenerated struct {
Media []struct {
    URI               string `json:"uri"`
    CreationTimestamp int    `json:"creation_timestamp"`
    MediaMetadata     struct {
        PhotoMetadata struct {
            ExifData []struct {
            Latitude         float64 `json:"latitude,omitempty"`
            Longitude        float64 `json:"longitude,omitempty"`
            SceneCaptureType string  `json:"scene_capture_type,omitempty"`
            Software         string  `json:"software,omitempty"`
            DeviceID         string  `json:"device_id,omitempty"`
            DateTimeOriginal string  `json:"date_time_original,omitempty"`
            SourceType       string  `json:"source_type,omitempty"`
            } `json:"exif_data"`
        } `json:"photo_metadata"`
        VideoMetadata struct {
            ExifData []struct {
                Latitude  float64 `json:"latitude,omitempty"`
                Longitude float64 `json:"longitude,omitempty"`
            } `json:"exif_data"`
        } `json:"video_metadata"`
        CameraMetadata struct {
            HasCameraMetadata bool `json:"has_camera_metadata"`
        } `json:"camera_metadata"`
    } `json:"media_metadata"`
    Title           string `json:"title"`
    CrossPostSource struct {
        SourceApp string `json:"source_app"`
    } `json:"cross_post_source"`
    BackupURI string `json:"backup_uri"`
} `json:"media"`
}

It's not great. Specifically the exif_data, which not only lives in either a photo_metadata or video_metadata, it's also an array.
A Go struct can deal with multiple types in the same struct (see Lat/Long vs the other metadata), but in the actual Instagram Facebook Meta JSON these are separate array entries.

If you thought that was bad, the worst part is the type of encoding. I wonder if this comes from Hack/PHP. But my emojis are 4 separate bytes, instead of being a multibyte.
And yes, I did spend 2 hours trying to get it fixed, but gave up.
Truth be told, I only have 150 posts and there's not a lot of emojis, I could, and should, have done it by hand...

I fought the CSS and it won

Spend another hour getting the grid to play nicely on /photos as well as having to deal with incomplete data.
Not every entry has a summary or even a title. So I use their slug/permalink, but those are long strings without spaces so it would mess up the layout.
Then there were tags, some have none, some from my earlier years have a πŸ’©-ton because I tried to get publicity on Instagram. Regardless, I'm showing 2 and a count of how many, the rest has to be shown on the real page.

Screenshot of /photos, showing a grid of 3 by 2 photos. Photos are of different height and metadata above them has different amount of lines
It's not pretty, but it's honest work. πŸ§‘β€πŸŒΎ

But for now there's at least something, and while not pixel-perfect, for a personal site I think it's actually quite fitting.

I didn't remember it, but apparently I also had 2 videos. So I had to scramble to get that to work as well, and so it does. (Hardcoded to ".mp4", but we'll cross that bridge when we need to)

I have not linked (u-syndication) them back to their Instagram page because I could not find the instagram shortcode or how to decode it from whatever JSON I had.

Not to mention that my Instagram is still set to private.. so probably should open it up since it's all here in public.. πŸ€”