Spring Boot: download YouTube, TikTok and Instagram videos
Spring Boot 3.2's RestClient lets you define a CrawlFetch client bean once and inject it anywhere.
How it fits together
A configuration class builds a RestClient with the base URL and bearer header; a controller exposes a resolve endpoint to your frontend.
Spring Boot example
@Configurationclass CrawlFetchConfig {@BeanRestClient crawlFetch(@Value("${CRAWLFETCH_KEY}") String key) {return RestClient.builder().baseUrl("https://api.crawlfetch.com").defaultHeader(HttpHeaders.AUTHORIZATION, "Bearer " + key).build();}}@RestControllerclass ResolveController {private final RestClient crawlFetch;ResolveController(RestClient crawlFetch) { this.crawlFetch = crawlFetch; }@GetMapping("/resolve")Map<?, ?> resolve(@RequestParam String url) {return crawlFetch.get().uri(b -> b.path("/v1/resolve").queryParam("url", url).build()).retrieve().body(Map.class);}}
Notes for Spring Boot
- Map
RestClientResponseExceptionto your error responses with@ControllerAdvice. - Add Spring Retry's
@Retryablefor 500s.
FAQ
Can I use WebClient?
Yes, for reactive stacks. The request is the same.
Related
Last updated 2026-10-25