Popular posts - adding and removing tags using the Admin API

I’m building a solution that will use Fathom Analytics to create the widget of the most popular post automatically. The idea is to remove the #most-popular tag from the posts that already have it and then add that tag to a new group of posts fetched from the Fathom.
Now, getting the slugs of the popular posts from Fathom and the list of Ghost slugs with the #most-popular tag was easy, but I’m stuck with removing/adding a tag from/to the post using the Admin APi.
Has anyone had any experience with that?


You’ll need to retrieve each post that you need to update, including the existing tags, then remove the #most-popular tag from the tags array and update the post with the updated list of tags. If you can say more about where you’re stuck, I can try to nudge you along.

1 Like

Thank you very much @Cathy_Sarisky for your time and effort, I’ll try that :slight_smile: