Using Go

How to Scrape TikTok Song Details with Go

Get details about a specific song by clip ID using Go. This comprehensive guide will walk you through the entire process, from setup to implementation.

Overview

What You'll Learn

  • Setting up your Go environment
  • Installing the required HTTP client
  • Authenticating with SociaVault API
  • Making requests to TikTok
  • Handling responses and errors

What You'll Get

  • Access to music details data
  • JSON formatted responses
  • Real-time data access
  • Scalable solution
  • Error handling patterns

Prerequisites

1. API Key

First, you'll need a SociaVault API key to authenticate your requests.

2. Development Environment

Make sure you have the following installed:

  • Go installed
  • A code editor (VS Code, Sublime, etc.)
  • Command line interface access

Implementation

Step 1: Install HTTP Client

We'll use net/http to make HTTP requests.

bash
// Standard library

Step 2: API Implementation

Now let's make a request to the TikTok API using Go. Replace YOUR_API_KEY with your actual API key.

go
package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
)

func main() {
	url := "https://api.sociavault.com/tiktok/music/details?clipId=7439295283975702544"
	req, _ := http.NewRequest("GET", url, nil)
	req.Header.Add("x-api-key", "YOUR_API_KEY")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)
	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(string(body))
}

Testing Your Code

API Parameters

ParameterTypeRequiredDescription
clipIdstringYesExample: 7439295283975702544

Expected Response

You should receive a structured JSON response containing the music details data.

json
{
  "music_info": {
    "album": "Different",
    "allow_offline_music_to_detail_page": false,
    "artists": [
      {
        "avatar": {
          "uri": "tos-maliva-avt-0068/e7d4971260ccf9834d92fe6a3c63e848",
          "url_list": [
            "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e7d4971260ccf9834d92fe6a3c63e848~c5_168x168.webp?lk3s=544a444f&nonce=23330&refresh_token=9e7d26286320fa35b998105f0dcbc158&x-expires=1741053600&x-signature=5oUamOIDpQFqlJS8XBBgEaNiNK0%3D&shp=544a444f&shcp=-"
          ]
        },
        "enter_type": 2,
        "follow_status": 0,
        "follower_status": 0,
        "handle": "micahtylertok",
        "is_block": false,
        "is_blocked": false,
        "is_private_account": false,
        "is_verified": false,
        "is_visible": false,
        "nick_name": "Micah Tyler",
        "sec_uid": "MS4wLjABAAAAEdwuYUJfZcFMddE2j_F7VdBPJ-mFgfmhvS_OEZc_CwP9mgiFLDBlqsJOgEaAaHR5",
        "status": 1,
        "uid": "7086245766293226538"
      }
    ],
    "audition_duration": 60,
    "author": "Micah Tyler",
    "author_deleted": false,
    "avatar_medium": {
      "height": 720,
      "uri": "tos-maliva-avt-0068/e7d4971260ccf9834d92fe6a3c63e848",
      "url_list": [
        "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e7d4971260ccf9834d92fe6a3c63e848~c5_720x720.webp?lk3s=544a444f&nonce=64063&refresh_token=84290303432aef362a12963995398c8c&x-expires=1741053600&x-signature=VWm%2FJPJZmHRb23mnxnbZIoyMEfY%3D&shp=544a444f&shcp=-"
      ],
      "width": 720
    },
    "avatar_thumb": {
      "height": 720,
      "uri": "tos-maliva-avt-0068/e7d4971260ccf9834d92fe6a3c63e848",
      "url_list": [
        "https://p16-sign-va.tiktokcdn.com/tos-maliva-avt-0068/e7d4971260ccf9834d92fe6a3c63e848~c5_100x100.webp?lk3s=544a444f&nonce=19785&refresh_token=546fc5e384f6934ebcb6a569ae37a54d&x-expires=1741053600&x-signature=q5%2FBVdNQxITSyrSbvd69kij1sRE%3D&shp=544a444f&shcp=-"
      ],
      "width": 720
    },
    "binded_challenge_id": 0,
    "can_be_stitched": true,
    "can_not_reuse": false,
    "collect_stat": 0,
    "commercial_right_type": 3,
    "cover_large": {
      "height": 720,
      "uri": "tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb",
      "url_list": [
        "https://p16-sg.tiktokcdn.com/aweme/720x720/tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb.jpeg"
      ],
      "width": 720
    },
    "cover_medium": {
      "height": 720,
      "uri": "tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb",
      "url_list": [
        "https://p16-sg.tiktokcdn.com/aweme/200x200/tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb.jpeg"
      ],
      "width": 720
    },
    "cover_thumb": {
      "height": 720,
      "uri": "tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb",
      "url_list": [
        "https://p16-sg.tiktokcdn.com/aweme/100x100/tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb.jpeg"
      ],
      "width": 720
    },
    "create_time": 1563960621,
    "dmv_auto_show": false,
    "duration": 60,
    "duration_high_precision": {
      "audition_duration_precision": 60,
      "duration_precision": 60,
      "shoot_duration_precision": 60,
      "video_duration_precision": 60
    },
    "extra": "{\"aed_music_dur\":35.15,\"amplitude_peak\":0.90573657,\"apple_song_id\":1294619219,\"beats\":{\"audio_effect_onset\":\"https://sf16-ies-music-sg.tiktokcdn.com/obj/tos-alisg-v-2774/oUAUk8ZzzEAU6HBiB7fAhDsjbAN8yAAEhqQTWg\",\"beats_tracker\":\"https://sf77-ies-music-sg.tiktokcdn.com/obj/tos-alisg-v-2774/oAF3bCnBfkAAUeZDlsqGFACtgETHBYaEAAH5DZ\",\"energy_trace\":\"https://sf77-ies-music-sg.tiktokcdn.com/obj/tos-alisg-v-2774/ow8bhfzzsWgaaEAjQHhEKiABkApQUJA5gyNpRA\",\"merged_beats\":\"https://sf16-ies-music-sg.tiktokcdn.com/obj/tos-alisg-v-2774/oUIygAzuEAAhAAHCNWBQEYAfF8HjMRdiUFZshk\"},\"can_read\":true,\"can_reuse\":true,\"erase_type\":0,\"erase_uid\":0,\"from_user_id\":7353023837547873313,\"full_song_beat_info\":{\"bpm\":81},\"full_song_beats\":{\"audio_effect_onset\":\"tos-alisg-v-2774/oEF39BYibIPQZrDAG3AwdhCAEgJo3EWEABPiR\",\"beats_tracker\":\"tos-alisg-v-2774/ogAgAf9gDADnFAitguEi0fIMdBNI2Qtg6AZxRC\",\"energy_trace\":\"tos-alisg-v-2774/o8G0ODdiECCg20AtwAREmDRADEBZgAFgn3BeZf\",\"merged_beats\":\"tos-alisg-v-2774/osZ3PAAxGEI3lBTwCEiGEiBAEWRQrYwQdl7UA\"},\"has_edited\":0,\"is_batch_take_down_music\":false,\"is_ugc_mapping\":false,\"is_used\":0,\"loudness_lufs\":-11.893368,\"music_vid\":\"v10ad6g50000ctcrhlvog65o48qsdm1g\",\"owner_id\":0,\"resource_status\":0,\"review_unshelve_reason\":0,\"reviewed\":0,\"schedule_search_time\":0}",
    "full_song": {
      "full_song_duration": 195,
      "full_song_duration_precision": 195.12,
      "full_song_id": "6739983931317159937",
      "full_song_play_url": {
        "uri": "tos-alisg-ve-2774/ok4uNQDaztAMCS5ZA6iiwxBnWrBsBXAMIVfyoN",
        "url_list": [
          "https://sf77-ies-music-sg.tiktokcdn.com/obj/tos-alisg-ve-2774/ok4uNQDaztAMCS5ZA6iiwxBnWrBsBXAMIVfyoN"
        ]
      },
      "full_song_shoot_duration": 60,
      "full_song_shoot_duration_precision": 60
    },
    "has_commerce_right": false,
    "id": 6717159721276541000,
    "id_str": "6717159721276540930",
    "is_audio_url_with_cookie": false,
    "is_author_artist": true,
    "is_commerce_music": true,
    "is_matched_metadata": false,
    "is_original": false,
    "is_original_sound": false,
    "is_pgc": true,
    "is_shooting_allow": true,
    "log_extra": "{\"meta_song_matched_type\":\"pgc\",\"ttm_matched_type\":\"\",\"ttm_track_id\":\"\",\"matched_meta_song_id\":\"\",\"vid\":\"\",\"owner_id\":\"\"}",
    "matched_song": {
      "author": "Micah Tyler",
      "chorus_info": {
        "duration_ms": 85824,
        "start_ms": 91968
      },
      "cover_medium": {
        "height": 720,
        "uri": "tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb",
        "url_list": [
          "https://p16-sg.tiktokcdn.com/aweme/200x200/tos-alisg-v-2774/okeuMAAZnBBv88JZBjFEgjDOtWCZQ4AEEwfoQb.jpeg"
        ],
        "width": 720
      },
      "full_duration": 195120,
      "h5_url": "",
      "id": "6717159725093390337",
      "title": "Different (Acoustic)"
    },
    "mid": "6717159721276540930",
    "music_release_info": {
      "group_release_date": 1507852800,
      "is_new_release_song": false
    },
    "mute_share": false,
    "offline_desc": "",
    "owner_handle": "",
    "owner_nickname": "",
    "play_url": {
      "height": 720,
      "uri": "https://sf77-ies-music-sg.tiktokcdn.com/obj/tos-alisg-ve-2774/oIBIZNfxOX2Nzi1WRH4ABroDirMAuIjwsGVov9",
      "url_list": [
        "https://sf77-ies-music-sg.tiktokcdn.com/obj/tos-alisg-ve-2774/oIBIZNfxOX2Nzi1WRH4ABroDirMAuIjwsGVov9"
      ],
      "width": 720
    },
    "prevent_download": false,
    "preview_end_time": 0,
    "preview_start_time": 0,
    "recommend_status": 100,
    "share_info": {
      "bool_persist": 0,
      "share_desc": "Check out this song! Different (Acoustic) #TikTok",
      "share_desc_info": "Users all over the world are having fun making their own versions of the song Different (Acoustic) on TikTok! Tap here >>",
      "share_quote": "",
      "share_signature_desc": "",
      "share_signature_url": "",
      "share_title": "Amazing! I just found a bunch of funny videos! #TikTok > Different (Acoustic)",
      "share_title_myself": "",
      "share_title_other": "",
      "share_url": "https://www.tiktok.com/music/Different-Acoustic-6717159721276540930?_r=1&sharer_language=en&source=h5_m&u_code=edc4e03mb6jec3&_d=edc4blalch8k7a&share_music_id=6717159721276540930"
    },
    "shoot_duration": 60,
    "source_platform": 10033,
    "status": 1,
    "strong_beat_url": {
      "height": 720,
      "uri": "https://sf16-ies-music-sg.tiktokcdn.com/obj/tos-alisg-v-2774/c8b6aea87f2f430e93a4c5e75515cbce",
      "url_list": [
        "https://sf16-ies-music-sg.tiktokcdn.com/obj/tos-alisg-v-2774/c8b6aea87f2f430e93a4c5e75515cbce"
      ],
      "width": 720
    },
    "suggest_words": {
      "suggest_words": [
        {
          "scene": "search_hint",
          "words": [
            {
              "word": "Different (Acoustic)",
              "word_id": "2444359994125246213"
            }
          ]
        }
      ]
    },
    "title": "Different (Acoustic)",
    "user_count": 358,
    "vid_volume_info": "{\"Peak\":0.90157,\"Loudness\":-11.9}",
    "video_duration": 60
  },
  "status_code": 0,
  "status_msg": ""
}

Best Practices

Error Handling

Implement comprehensive error handling and retry logic for failed requests. Log errors properly for debugging.

Caching

Cache responses when possible to reduce API calls and improve performance. Consider data freshness requirements.

Security

Never expose your API key in client-side code. Use environment variables and secure key management practices.

Troubleshooting

401

Unauthorized

Check your API key is correct and properly formatted in the x-api-key header.

402

Payment Required

You ran out of credits and need to buy more.

404

Not Found

The resource (user, video, etc.) might not exist or be private.

429

Too Many Requests

You have exceeded your rate limit. Slow down your requests.

Frequently Asked Questions

How much does it cost to scrape TikTok?

SociaVault offers 50 free API calls to get started. After that, pricing starts at $10 for 5k requests with volume discounts available.

Is it legal to scrape TikTok data?

Scraping publicly available data is generally considered legal. We only collect public data that is accessible without logging in.

How fast can I scrape TikTok?

Our API handles the rate limiting for you. You can make requests as fast as your plan allows.

What data format does the API return?

All API responses are returned in JSON format, making it easy to integrate with any programming language or application.

Related Tutorials

Ready to Start Scraping?

Get started with 50 free API calls. No credit card required. Stop worrying about proxies and captchas.