Introducing tiktok-mf2.tanna.dev, for converting TikTok video metadata to Microformats2

Featured image for sharing metadata for article

I'm a big fan of producing Pipe services where possible, and as I wanted to start producing better metadata for my interactions with TikToks i.e. posts tagged TikTok on my site.

I first thought about this as a thing that was possible, when Jan-Lukas Else wrote about building a JSON Feed for TikTok. It wasn't until last week, when I started producing more context for interactions on my site.

This was fortunately straightforward using the tiktok-scraper package, and wrapping it in a small adapter to translate between the metadata and a Microformats2 object.

An example of using this can be seen below, using the hosted version at tiktok-mf2.tanna.dev:

// curl 'https://tiktok-mf2.tanna.dev/video?url=https%3A%2F%2Fwww.tiktok.com%2F%40thereiruinedit%2Fvideo%2F7078499218352131371%3F_t%3D8R5zFHrp38o%26_r%3D1' -H 'Accept: application/mf2+json'
{
  "items": [
    {
      "properties": {
        "author": [
          {
            "properties": {
              "name": [
                "There I Ruined It"
              ],
              "nickname": [
                "thereiruinedit"
              ],
              "photo": [
                "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/21d23c0cf6f82dda4acd18a03b647d48~c5_1080x1080.jpeg?x-expires=1648929600&x-signature=4vxnY11wGzCb0iQKnrbtOwjR2%2FI%3D"
              ]
            },
            "type": [
              "h-card"
            ]
          }
        ],
        "featured": [
          "https://p16-sign.tiktokcdn-us.com/obj/tos-useast5-p-0068-tx/2fa48f1c4890479d861ef7cec68e7c56_1648091533?x-expires=1648864800&x-signature=sk87vHJ6hL8a2WZzUWWfMiAmrP4%3D"
        ],
        "published": [
          "2022-03-24T03:12:10.000Z"
        ],
        "summary": [
          "Shugga chugga #michaeljackson"
        ],
        "url": [
          "https://www.tiktok.com/@thereiruinedit/video/7078499218352131371?_t=8R5zFHrp38o&_r=1"
        ]
      },
      "type": [
        "h-entry"
      ]
    }
  ]
}

The source code for the library and the service can be found on GitLab.

Unfortunately, due to the static media URLs requiring time-limited signatures, the embedding of these cites isn't ideal longer-term.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#tiktok #tiktok-mf2 #indieweb #microformats2.

Also on: IndieWebCamp logo IndieWeb.xyz logo

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.