1. Tutorials
  2. How to scrape Reddit video post transcript

How to scrape Reddit video post transcript

Get Reddit video post transcript as JSON with one request. Captions cost 1 credit.

Get an API key; the examples use api.socialscrape.dev.

Before you start

Step 1: Send the request

GET /v1/reddit/post/transcript. Pick your language; each one reads the key from SOCIALSCRAPE_API_KEY.

1curl -G "https://api.socialscrape.dev/v1/reddit/post/transcript" \2  -H "x-api-key: $SOCIALSCRAPE_API_KEY" \3  --data-urlencode 'url=https://www.reddit.com/r/interestingasfuck/comments/1xl30t2/a_bird_watches_a_man_fish_he_offers_it_his_catch/'

Step 2: Read the response

The result is in data. Here is what the object gives you, from a recorded sample.

1print(body["data"]["text"])
SampleFields printed above
1{2  "text": "He's heavy, oh wow. I was not expecting that. Okay. Hey, kudos on you, dude. Oh yeah."3}

A field the platform does not give comes back as null. The full field list is on the endpoint page.

Step 3: Handle errors

Check ok, then branch on error.code and error.retryable, never on the message.

1body = res.json()2if not body["ok"]:3    err = body["error"]4    if err["retryable"]:5        ...  # wait a moment and send the same request again6    else:7        raise RuntimeError(f'{err["code"]}: {err["message"]}')
CodeHTTPRetryMeaning
invalid_params400noA parameter is missing, unknown or has the wrong type.
unsupported_url400noThe URL is not one this endpoint accepts (wrong platform or form).
not_found404noThe platform says this profile, post or item does not exist.
transcript_unavailable404noNo captions exist and AI transcription is not possible for this media.

Other errors, such as unauthorized or rate_limited, are on the errors page.

With the SDK

The Python and TypeScript clients wrap all of this: typed errors, retries. Install them with pip install socialscrape-sdk or npm install socialscrape.

1from socialscrape import SocialScrape23client = SocialScrape()  # reads SOCIALSCRAPE_API_KEY45res = client.reddit.post_transcript(url="https://www.reddit.com/r/interestingasfuck/comments/1xl30t2/a_bird_watches_a_man_fish_he_offers_it_his_catch/")6print(res.data)7print(res.credits_charged, res.credits_remaining)

What it costs

1 credit for captions; AI transcription 1 up to 2 minutes, then 5 per started minute of the whole video. A failed request costs nothing. Add max_age_days to reuse a cached result for 0 credits. Results are kept 30 days.

Next

Questions

Which language should I use?

Any. It is plain HTTP and JSON, so every language with an HTTP client works. The tabs show the same request nine ways.