YouTube playlist videos
Beta GET /v1/youtube/playlist
GET /v1/youtube/playlist
The playlist's videos; parent is the playlist itself.
- Cost: 1 credit
- Status: Beta. Built and tested against recorded responses; the shape may still gain fields.
- Cache: Results are kept up to 30 days; send
max_age_daysto reuse them for free. - Timeout: A request still running after about 25 seconds answers
202with a job to poll (Batch and jobs).
Parameters#
| Name | Type | Required | Description |
|---|---|---|---|
url | URL | one of | Playlist URL (list=...). Accepted hosts: youtube.com, youtu.be. |
id | string | one of | Playlist id (PL..., UU..., OL...). Also accepted as playlist_id, playlistId. |
Send at least one of url, id. If you send several, the first listed is used and the rest are ignored.
Every request also accepts:
cursor: the cursor from the previous page (Pagination).trim:truefor a smaller response withoutnullfields andextra.raw:trueto also get the platform's original object asraw.max_age_days: accept a cached result up to this many days old, for 0 credits (Caching).
Example request#
Set your key in the environment first (see Authentication).
curl
curl -G "https://api.socialscrape.io/v1/youtube/playlist" \
-H "x-api-key: $SOCIALSCRAPE_API_KEY" \
--data-urlencode "id=PL2aBZuCeDwlTxZeGRlKrWpLiX_W7jpt6p"Python
import os
import requests
params = {
"id": "PL2aBZuCeDwlTxZeGRlKrWpLiX_W7jpt6p",
}
res = requests.get(
"https://api.socialscrape.io/v1/youtube/playlist",
headers={"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]},
params=params,
)
body = res.json()
if body["ok"]:
print(body["data"])
else:
print(body["error"]["code"], body["error"]["message"])TypeScript
const url = new URL("https://api.socialscrape.io/v1/youtube/playlist");
url.search = new URLSearchParams({
"id": "PL2aBZuCeDwlTxZeGRlKrWpLiX_W7jpt6p"
}).toString();
const res = await fetch(url, {
headers: { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! },
});
const body = await res.json();
if (body.ok) {
console.log(body.data);
} else {
console.error(body.error.code, body.error.message);
}n8n
{
"nodes": [
{
"name": "SocialScrape YouTube playlist videos",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
0,
0
],
"parameters": {
"method": "GET",
"url": "https://api.socialscrape.io/v1/youtube/playlist",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "id",
"value": "PL2aBZuCeDwlTxZeGRlKrWpLiX_W7jpt6p"
}
]
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "x-api-key",
"value": "={{ $env.SOCIALSCRAPE_API_KEY }}"
}
]
}
}
}
],
"connections": {}
}Example response#
This is a sample from a recorded response, lists and long text are shortened. Status 200.
{
"ok": true,
"credits_charged": 1,
"credits_remaining": 4999,
"cached": false,
"cached_at": null,
"request_id": "req_714ff6a10d51e7b72da00727",
"data": {
"object": "list",
"items": [
{
"object": "post",
"platform": "youtube",
"id": "JNCw3fUtwbs",
"url": "https://www.youtube.com/watch?v=JNCw3fUtwbs",
"type": "video",
"author": {
"id": null,
"handle": null,
"name": "NASA",
"url": null,
"avatar_url": null,
"verified": null
},
"title": "Thanks for All the Gravity Assists",
"text": null,
"published_at": "2022-10-30T00:00:00Z",
"duration_seconds": 392.0,
"language": null,
"hashtags": null,
"mentions": null,
"stats": {
"views": 33000,
"likes": null,
"comments": null,
"shares": null,
"saves": null,
"dislikes": null
},
"media": {
"thumbnail_url": "https://i.ytimg.com/vi/JNCw3fUtwbs/mqdefault.jpg",
"video_url": null,
"audio_url": null,
"image_urls": null,
"width": null,
"height": null
},
"song": null,
"location": null,
"is_pinned": null,
"is_sponsored": null,
"extra": {
"published_at_approximate": true
}
},
{
"object": "post",
"platform": "youtube",
"id": "coFE7-E6LRg",
"url": "https://www.youtube.com/watch?v=coFE7-E6LRg",
"type": "video",
"author": {
"id": null,
"handle": null,
"name": "NASA",
"url": null,
"avatar_url": null,
"verified": null
},
"title": "Gravity Assist: Listening to the Universe",
"text": null,
"published_at": "2021-10-30T00:00:00Z",
"duration_seconds": 228.0,
"language": null,
"hashtags": null,
"mentions": null,
"stats": {
"views": 82000,
"likes": null,
"comments": null,
"shares": null,
"saves": null,
"dislikes": null
},
"media": {
"thumbnail_url": "https://i.ytimg.com/vi/coFE7-E6LRg/mqdefault.jpg",
"video_url": null,
"audio_url": null,
"image_urls": null,
"width": null,
"height": null
},
"song": null,
"location": null,
"is_pinned": null,
"is_sponsored": null,
"extra": {
"published_at_approximate": true
}
}
],
"cursor": null,
"has_more": false,
"parent": {
"object": "collection",
"platform": "youtube",
"id": "PL2aBZuCeDwlTxZeGRlKrWpLiX_W7jpt6p",
"url": "https://www.youtube.com/playlist?list=PL2aBZuCeDwlTxZeGRlKrWpLiX_W7jpt6p",
"kind": "playlist",
"title": null,
"description": null,
"owner": null,
"item_count": null,
"cover_url": null,
"updated_at": null,
"extra": null
}
},
"cursor": null,
"has_more": false
}Response#
A list of Post objects in data.items, with data.cursor and data.has_more.
See Data models for every field. The envelope around data is described in Responses.
Errors#
Failures are free: credits_charged is 0. Branch on error.code, never on the message.
| Code | HTTP | Retry | Meaning |
|---|---|---|---|
invalid_params | 400 | no | A parameter is missing, unknown or has the wrong type. |
unsupported_url | 400 | no | The URL is not one this endpoint accepts (wrong platform or form). |
not_found | 404 | no | The platform says this profile, post or item does not exist. |
Every request can also fail with the account and platform errors listed on the Errors page.
Related endpoints#
- YouTube channel details (
GET /v1/youtube/channel) - YouTube channel videos (
GET /v1/youtube/channel/videos) - Search inside a YouTube channel (
GET /v1/youtube/channel/search) - YouTube channel playlists (
GET /v1/youtube/channel/playlists) - YouTube channel Shorts (
GET /v1/youtube/channel/shorts) - YouTube channel live streams (
GET /v1/youtube/channel/lives) - YouTube channel community posts (
GET /v1/youtube/channel/community-posts) - YouTube video or Short details (
GET /v1/youtube/video)