<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[FlashData Engineering]]></title><description><![CDATA[FlashData Engineering]]></description><link>https://flashdata.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Dec 2026 20:13:36 GMT</lastBuildDate><atom:link href="https://flashdata.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Fetching YouTube Transcripts and Video Metadata in Laravel (Plus Remote MCP for AI Agents)]]></title><description><![CDATA[A practical Laravel HTTP client and Artisan command guide to pulling timestamped YouTube transcripts, handling fallback metadata, and connecting AI coding…]]></description><link>https://flashdata.hashnode.dev/fetching-youtube-transcripts-and-video-metadata-in-laravel-plus-remote-mcp-for-ai-agents</link><guid isPermaLink="true">https://flashdata.hashnode.dev/fetching-youtube-transcripts-and-video-metadata-in-laravel-plus-remote-mcp-for-ai-agents</guid><category><![CDATA[Laravel]]></category><category><![CDATA[api]]></category><category><![CDATA[PHP]]></category><category><![CDATA[youtube]]></category><category><![CDATA[mcp]]></category><dc:creator><![CDATA[FlashData]]></dc:creator><pubDate>Fri, 04 Dec 2026 05:43:24 GMT</pubDate><content:encoded><![CDATA[<p>Building AI research assistants, video indexing jobs, or searchable knowledge bases inside a Laravel app usually starts with one simple requirement: given a YouTube video URL or 11-character ID, pull its timestamped transcript and structured metadata reliably.</p>
<p>In practice, teams run into three recurring headaches:</p>
<ol>
<li>Unofficial scraping libraries break whenever YouTube tweaks page markup or session endpoints.</li>
<li>Self-hosted workers require proxy rotation and constant maintenance just to keep caption fetches working.</li>
<li>Videos without captions cause unhandled HTTP exceptions instead of falling back cleanly to structured video metadata and chapters.</li>
</ol>
<p>In this tutorial, we'll build a clean Laravel service and Artisan command using <strong><a href="https://flashdata.dev">FlashData</a></strong>—a managed real-time data API and hosted Remote MCP server for Google Search, YouTube Data, and cloud YouTube Downloads—so your Laravel app gets clean structured JSON or LLM-ready Markdown without proxy maintenance or fragile HTML parsers.</p>
<blockquote>
<p><strong>Start with a free trial (no credit card required):</strong> Every developer and team can sign up and verify their email at <a href="https://flashdata.dev">flashdata.dev</a> to generate an API key and test all endpoints right away.</p>
</blockquote>
<hr />
<h2>Step 1: Configure Your FlashData API Key in Laravel</h2>
<p>Add your key to <code>.env</code>:</p>
<pre><code class="language-env">FLASHDATA_API_KEY=your_api_key_here
</code></pre>
<p>Register it in <code>config/services.php</code>:</p>
<pre><code class="language-php">'flashdata' =&gt; [
    'key' =&gt; env('FLASHDATA_API_KEY'),
    'endpoint' =&gt; env('FLASHDATA_REALTIME_ENDPOINT', 'https://data.flashdata.dev/v1/queries/realtime'),
],
</code></pre>
<p>All realtime sources share the same endpoint (<code>POST https://data.flashdata.dev/v1/queries/realtime</code>) and authenticate with the <code>X-API-Key</code> header, documented in the <a href="https://flashdata.dev/docs/openapi.json">OpenAPI 3.1.0 specification</a>.</p>
<hr />
<h2>Step 2: Build a Resilient Laravel Service (With Metadata Fallback)</h2>
<p>Two contract details from the <a href="https://flashdata.dev/docs/sources/youtube_transcript">YouTube Transcript API docs</a> make production error handling much cleaner:</p>
<ul>
<li><code>youtube_transcript</code> accepts <code>video_id</code> (an 11-character YouTube ID, not the full URL) at the top level, plus optional <code>params.language</code> (a single language code or an array of up to 10 selectors) and <code>params.auto</code> (<code>true</code> by default).</li>
<li>When requesting a language array, <code>results[0]</code> contains <code>tracks</code> and <code>errors</code>. When requesting a single language, <code>results[0]</code> is the track object itself. Reading <code>$first['tracks'] ?? [$first]</code> handles both shapes cleanly.</li>
<li>If a video has no matching captions, the API returns a non-2xx response (and refunds reserved credits on failed requests). Instead of throwing immediately, we check <code>$response-&gt;successful()</code> and fall back to <code>youtube_metadata</code> (<a href="https://flashdata.dev/docs/sources/youtube_metadata">docs</a>).</li>
</ul>
<p>Create <code>app/Services/FlashDataYouTubeService.php</code>:</p>
<pre><code class="language-php">&lt;?php

namespace App\Services;

use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use InvalidArgumentException;

class FlashDataYouTubeService
{
    protected function client(bool $markdown = false): PendingRequest
    {
        $headers = [
            'X-API-Key' =&gt; config('services.flashdata.key'),
            'Accept' =&gt; 'application/json',
        ];

        if ($markdown) {
            $headers['X-Respond-With'] = 'markdown';
        }

        return Http::withHeaders($headers)-&gt;timeout(60);
    }

    public function extractVideoId(string $input): string
    {
        $trimmed = trim($input);

        if (preg_match('/^[A-Za-z0-9_-]{11}$/', $trimmed) === 1) {
            return $trimmed;
        }

        if (preg_match('/(?:v=|youtu\.be\/|embed\/|shorts\/)([A-Za-z0-9_-]{11})/', $trimmed, $matches) === 1) {
            return $matches[1];
        }

        throw new InvalidArgumentException("Invalid YouTube video ID or URL: {$input}");
    }

    /**
     * Fetch timestamped transcript tracks, falling back to video metadata when captions are unavailable.
     */
    public function fetchTranscriptOrMetadata(string $videoInput, array $languages = ['en']): array
    {
        $videoId = $this-&gt;extractVideoId($videoInput);
        $endpoint = config('services.flashdata.endpoint');

        $transcriptResponse = $this-&gt;client()-&gt;post($endpoint, [
            'source' =&gt; 'youtube_transcript',
            'video_id' =&gt; $videoId,
            'params' =&gt; [
                'language' =&gt; $languages,
                'auto' =&gt; true,
            ],
        ]);

        if ($transcriptResponse-&gt;successful()) {
            $payload = $transcriptResponse-&gt;json();
            $first = $payload['results'][0] ?? null;

            if (is_array($first)) {
                $tracks = $first['tracks'] ?? [$first];
                $errors = $first['errors'] ?? [];

                if (!empty($tracks)) {
                    return [
                        'mode' =&gt; 'transcript',
                        'video_id' =&gt; $videoId,
                        'tracks' =&gt; $tracks,
                        'errors' =&gt; $errors,
                    ];
                }
            }
        }

        // Fallback: fetch structured video metadata (title, description, chapters)
        $metadataResponse = $this-&gt;client()-&gt;post($endpoint, [
            'source' =&gt; 'youtube_metadata',
            'video_id' =&gt; $videoId,
            'params' =&gt; [
                'include_chapters' =&gt; true,
                'include_formats' =&gt; false,
            ],
        ]);

        $metadataResponse-&gt;throw();

        return [
            'mode' =&gt; 'metadata_fallback',
            'video_id' =&gt; $videoId,
            'metadata' =&gt; $metadataResponse-&gt;json('results.0', []),
        ];
    }
}
</code></pre>
<h3>Bonus: Requesting LLM-Ready Markdown Directly</h3>
<p>If you are feeding transcripts straight into a summarization prompt or RAG chunker, pass <code>X-Respond-With: markdown</code> on the same <code>POST /v1/queries/realtime</code> request (using <code>$this-&gt;client(markdown: true)</code> above). With <code>Accept: application/json</code>, FlashData replaces the <code>results</code> array with a top-level <code>content</code> field containing clean Markdown (read <code>$response-&gt;json('content')</code>, or send <code>Accept: text/plain</code> for plain-text output) so you do not have to write extra formatting glue code.</p>
<hr />
<h2>Step 3: Wire Up a Laravel Artisan Command</h2>
<p>Create <code>app/Console/Commands/FetchYouTubeTranscript.php</code>:</p>
<pre><code class="language-php">&lt;?php

namespace App\Console\Commands;

use App\Services\FlashDataYouTubeService;
use Illuminate\Console\Command;

class FetchYouTubeTranscript extends Command
{
    protected $signature = 'youtube:transcript
        {video : YouTube video URL or 11-character video ID}
        {--lang=en : Comma-separated language selectors (e.g. en,ja)}';

    protected $description = 'Fetch timestamped YouTube transcripts (with metadata fallback) via FlashData';

    public function handle(FlashDataYouTubeService $youtube): int
    {
        $languages = array_values(array_unique(array_filter(array_map(
            'trim',
            explode(',', (string) $this-&gt;option('lang'))
        ))));

        $result = $youtube-&gt;fetchTranscriptOrMetadata(
            (string) $this-&gt;argument('video'),
            $languages ?: ['en']
        );

        if ($result['mode'] === 'transcript') {
            $primary = $result['tracks'][0];
            $segments = $primary['segments'] ?? [];

            $this-&gt;info(sprintf(
                'Fetched track [%s] (%s) with %d segments.',
                $primary['languageCode'] ?? 'unknown',
                $primary['captionSource'] ?? 'unknown',
                count($segments)
            ));

            foreach (array_slice($segments, 0, 5) as $segment) {
                $this-&gt;line(sprintf(
                    '[%.1fs] %s',
                    (float) ($segment['start'] ?? 0),
                    $segment['text'] ?? ''
                ));
            }

            return self::SUCCESS;
        }

        $this-&gt;warn('No matching captions found; returned structured metadata instead.');
        $this-&gt;line(json_encode($result['metadata'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));

        return self::SUCCESS;
    }
}
</code></pre>
<p>Run it from your terminal:</p>
<pre><code class="language-bash">php artisan youtube:transcript dQw4w9WgXcQ --lang=en
</code></pre>
<p>For high-volume ingestion inside Laravel queues, you can switch to the async endpoint (<code>POST https://data.flashdata.dev/v1/queries</code>) or batch endpoint (<code>POST https://data.flashdata.dev/v1/queries/batch</code>), optionally passing <code>callback_url</code> outside <code>params</code> on each query object (at the top level of <code>POST /v1/queries</code>, or on each entry inside <code>queries[]</code> for <code>POST /v1/queries/batch</code>) for completion notifications (<a href="https://flashdata.dev/docs/reference/webhooks">Completion Webhooks docs</a>).</p>
<hr />
<h2>Step 4: Reuse the Same Key in AI Coding Agents via Hosted Remote MCP</h2>
<p>While your Laravel backend calls the REST API, you can also connect <strong>Claude Code</strong>, <strong>Cursor</strong>, <strong>VS Code</strong>, or any Streamable HTTP MCP client to FlashData's zero-install hosted Remote MCP server (<code>https://data.flashdata.dev/mcp</code>, exposing 22 tools across Google Search, YouTube Data, and YouTube Downloads):</p>
<pre><code class="language-json">{
  "mcpServers": {
    "flashdata": {
      "url": "https://data.flashdata.dev/mcp",
      "headers": {
        "X-API-Key": "YOUR_FLASHDATA_API_KEY"
      }
    }
  }
}
</code></pre>
<p>Prefer running a local stdio MCP server? Run it directly via npm with <code>npx -y @flashdata-dev/mcp</code> (see the <a href="https://flashdata.dev/docs/mcp">MCP setup guide</a>). Beyond direct REST and MCP, FlashData also has live integrations with <strong>Dify Marketplace</strong>, <strong>General Input</strong>, <strong>Official MCP Registry</strong>, <strong>Apify Store</strong>, <strong>Windmill</strong>, and <strong>n8n</strong>.</p>
<hr />
<h2>Try It Free</h2>
<p>Every developer and team can start with a <strong>free trial (no credit card required)</strong> after email verification at <a href="https://flashdata.dev">flashdata.dev</a>—one API key covers Google Search (6 verticals), YouTube Data (8 endpoints), and YouTube Download (direct cloud storage delivery).</p>
<ul>
<li><strong>Website &amp; Free Trial</strong>: <a href="https://flashdata.dev">https://flashdata.dev</a></li>
<li><strong>YouTube Transcript API Reference</strong>: <a href="https://flashdata.dev/docs/sources/youtube_transcript">https://flashdata.dev/docs/sources/youtube_transcript</a></li>
<li><strong>YouTube Metadata API Reference</strong>: <a href="https://flashdata.dev/docs/sources/youtube_metadata">https://flashdata.dev/docs/sources/youtube_metadata</a></li>
<li><strong>Hosted Remote MCP Docs</strong>: <a href="https://flashdata.dev/docs/mcp">https://flashdata.dev/docs/mcp</a></li>
<li><strong>OpenAPI 3.1.0 Spec</strong>: <a href="https://flashdata.dev/docs/openapi.json">https://flashdata.dev/docs/openapi.json</a></li>
<li><strong>X (Twitter)</strong>: <a href="https://x.com/Flashdatadev">@Flashdatadev</a> | <strong>YouTube</strong>: <a href="https://www.youtube.com/@flashdatadev">@flashdatadev</a></li>
<li><strong>Support</strong>: <code>support@flashdata.dev</code></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Connecting AI Coding Agents to Google Search, YouTube Transcripts, and Cloud Video Downloads via Remote MCP]]></title><description><![CDATA[Connect AI coding agents to real-time Google Search, YouTube transcripts, and S3/GCS/R2 video delivery via one API key and remote MCP server.]]></description><link>https://flashdata.hashnode.dev/connecting-ai-coding-agents-to-google-search-youtube-transcripts-and-cloud-video-downloads-via-remote-mcp</link><guid isPermaLink="true">https://flashdata.hashnode.dev/connecting-ai-coding-agents-to-google-search-youtube-transcripts-and-cloud-video-downloads-via-remote-mcp</guid><category><![CDATA[mcp]]></category><category><![CDATA[api]]></category><category><![CDATA[AI]]></category><category><![CDATA[Python]]></category><category><![CDATA[RAG ]]></category><dc:creator><![CDATA[FlashData]]></dc:creator><pubDate>Mon, 23 Nov 2026 04:55:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6af1c8b67cab95bf2165ab48/3a842b24-6f6e-4440-a88c-553837b8e122.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you build AI coding agents, Deep Research workflows, or RAG pipelines, external data ingestion usually fractures across three different stacks: a Google SERP scraper with rotating proxies, an unofficial script for YouTube transcripts that breaks whenever markup changes, and self-hosted media workers for video downloads.</p>
<p><strong><a href="https://flashdata.dev">FlashData</a></strong> unifies <strong>Google Search</strong>, <strong>YouTube Data &amp; Transcripts</strong>, and <strong>cloud YouTube Downloads</strong> behind one API key, one shared credit balance, and a zero-install remote Streamable HTTP MCP server (<code>https://data.flashdata.dev/mcp</code>)—backed by fully managed data infrastructure with zero proxy pools or fragile HTML parsers to maintain.</p>
<blockquote>
<p><strong>Free Trial (No Credit Card Required):</strong> Every developer and team can sign up and verify their email at <a href="https://flashdata.dev">flashdata.dev</a> to start testing all three product lines right away with shared trial credits.</p>
</blockquote>
<hr />
<h2>Architecture Overview: 3 Product Lines, 15 Capabilities, 22 MCP Tools</h2>
<p>Instead of wiring separate credentials and SDKs for each source, FlashData exposes <strong>15 core data capabilities</strong> across three product lines (plus batch polling and balance inspection tools in MCP for <strong>22 tools total</strong>):</p>
<h3>1. Google Search API (6 Verticals)</h3>
<p>Retrieve clean, structured JSON with country, language, and geo-location parameters:</p>
<ul>
<li><strong>Web Search</strong>, <strong>News</strong>, <strong>Images</strong>, <strong>Shopping</strong>, <strong>Videos</strong>, and <strong>Places</strong></li>
<li>Built for real-time AI agent web grounding, competitive/SEO monitoring, and structured market research.</li>
</ul>
<h3>2. YouTube Data API (8 Structured Endpoints)</h3>
<p>Query public video intelligence and transcript feeds without maintaining custom scrapers:</p>
<ul>
<li><strong>Video Search</strong> &amp; <strong>Extended Search</strong></li>
<li><strong>Video Metadata</strong> &amp; <strong>Channel Details</strong></li>
<li><strong>Timestamped Transcripts</strong> &amp; <strong>Uploader Captions</strong> (ready for direct RAG chunking and LLM summarization)</li>
<li><strong>Creative Commons License Metadata</strong> &amp; <strong>Autocomplete Suggestions</strong></li>
</ul>
<h3>3. YouTube Download API (Direct Cloud Storage Delivery)</h3>
<p>Run high-concurrency asynchronous and batch downloads of video, audio, or time-range clips delivered directly to your own <strong>Amazon S3</strong>, <strong>Google Cloud Storage</strong>, <strong>Azure Blob Storage</strong>, or <strong>Cloudflare R2</strong> bucket—built for multimodal AI dataset curation and media pipelines.</p>
<hr />
<h2>Connect Your AI Coding Agent in 60 Seconds (Remote MCP)</h2>
<p>First, create an account and verify your email at <a href="https://flashdata.dev">flashdata.dev</a> to claim your <strong>free trial (no credit card required)</strong> and generate an API key.</p>
<h3>Option A: Claude Code (Zero-Install Remote HTTP MCP)</h3>
<pre><code class="language-bash">claude mcp add --transport http --scope user flashdata 'https://data.flashdata.dev/mcp' \
  --header 'X-API-Key: YOUR_FLASHDATA_API_KEY'
</code></pre>
<h3>Option B: Cursor (<code>~/.cursor/mcp.json</code>)</h3>
<pre><code class="language-json">{
  "mcpServers": {
    "flashdata": {
      "url": "https://data.flashdata.dev/mcp",
      "headers": {
        "X-API-Key": "YOUR_FLASHDATA_API_KEY"
      }
    }
  }
}
</code></pre>
<h3>Option C: Local Stdio MCP (<code>npx</code>)</h3>
<p>Prefer running locally over stdio (for Claude Desktop or custom MCP hosts)? Launch the official stdio MCP server directly with <code>npx -y @flashdata-dev/mcp</code> (see the full <a href="https://flashdata.dev/docs/mcp">MCP documentation</a> and <a href="https://flashdata.dev/docs/guides/agent-skill">Agent Skills guide</a>).</p>
<hr />
<h2>Production Backend Example: Google Search &amp; YouTube Transcripts in Python</h2>
<p>Every data workflow also runs over a single real-time REST endpoint (<code>POST https://data.flashdata.dev/v1/queries/realtime</code>) with an <code>X-API-Key</code> header, documented via OpenAPI 3.1.0 (<a href="https://flashdata.dev/docs/openapi.json">https://flashdata.dev/docs/openapi.json</a>):</p>
<pre><code class="language-python">import os
import requests

API_KEY = os.environ["FLASHDATA_API_KEY"]
ENDPOINT = "https://data.flashdata.dev/v1/queries/realtime"
HEADERS = {
    "X-API-Key": API_KEY,
    "Content-Type": "application/json",
    "Accept": "application/json",
}

def query_flashdata(payload: dict) -&gt; requests.Response:
    return requests.post(ENDPOINT, headers=HEADERS, json=payload, timeout=60)

# 1. Real-time Google Search (structured JSON)
serp_resp = query_flashdata({
    "source": "google_search",
    "query": "Model Context Protocol Python SDK",
    "params": {"hl": "en", "gl": "us", "num": 5},
})
serp_resp.raise_for_status()
serp = serp_resp.json()
print("Top organic results:", len((serp.get("results") or [{}])[0].get("organic", [])))

# 2. YouTube Timestamped Transcript (uses top-level video_id)
tr_resp = query_flashdata({
    "source": "youtube_transcript",
    "video_id": "dQw4w9WgXcQ",
    "params": {"language": ["en"], "auto": True},
})
if tr_resp.ok:
    first = (tr_resp.json().get("results") or [{}])[0]
    tracks = first.get("tracks", [first])
    print("Transcript tracks:", len(tracks))
else:
    # Fallback cleanly to structured video metadata if captions are unavailable
    meta_resp = query_flashdata({
        "source": "youtube_metadata",
        "video_id": "dQw4w9WgXcQ",
    })
    meta_resp.raise_for_status()
    print("Fallback metadata keys:", list((meta_resp.json().get("results") or [{}])[0].keys()))
</code></pre>
<p>Official documentation, SDK references, CLI guides, and live ecosystem connectors (<strong>Dify Marketplace</strong>, <strong>General Input</strong>, <strong>Official MCP Registry</strong>, <strong>Apify Store</strong>, <strong>Windmill</strong>, and <strong>n8n</strong>) are available through <a href="https://flashdata.dev/docs">flashdata.dev/docs</a>.</p>
<hr />
<h2>Start Testing for Free</h2>
<p>Every developer and team can start with a <strong>free trial (no credit card required)</strong> after email verification—your trial credits work across Google Search, YouTube Data, and YouTube Download from the same API key.</p>
<ul>
<li><strong>Free Trial &amp; Dashboard</strong>: <a href="https://flashdata.dev">https://flashdata.dev</a></li>
<li><strong>API Reference &amp; Guides</strong>: <a href="https://flashdata.dev/docs">https://flashdata.dev/docs</a></li>
<li><strong>Remote MCP Guide (22 Tools)</strong>: <a href="https://flashdata.dev/docs/mcp">https://flashdata.dev/docs/mcp</a></li>
<li><strong>Remote MCP Endpoint</strong>: <code>https://data.flashdata.dev/mcp</code></li>
<li><strong>X (Twitter)</strong>: <a href="https://x.com/Flashdatadev">@Flashdatadev</a></li>
<li><strong>YouTube</strong>: <a href="https://www.youtube.com/@flashdatadev">@flashdatadev</a></li>
<li><strong>Support</strong>: <code>support@flashdata.dev</code></li>
</ul>
]]></content:encoded></item></channel></rss>