← ClaudeAtlas

scraperapi-java-sdklisted

Best-practices reference for the ScraperAPI Java SDK (com.scraperapi:sdk Maven artifact). Consult whenever the user is writing, debugging, or reviewing Java code that calls ScraperAPI. Use when user asks: "scrape a website with Java and ScraperAPI", "ScraperAPI Java example", "how do I add ScraperAPI to my Maven project", "Java ScraperAPI render", "ScraperAPI Java fluent API", "ScraperAPI Java premium proxy", "ScraperAPI Java error handling", "ScraperAPI Java retry". Covers Maven/Gradle setup, the fluent builder API, all request parameters, the escalation ladder, async jobs, structured data calls, error handling, and credit costs.
scraperapi/scraperapi-skills · ★ 9 · AI & Automation · score 78
Install: claude install-skill scraperapi/scraperapi-skills
# ScraperAPI — Java SDK Best Practices **Requires:** Java 8+, Maven or Gradle, `SCRAPERAPI_API_KEY` environment variable. ## Setup ### Maven ```xml <dependency> <groupId>com.scraperapi</groupId> <artifactId>sdk</artifactId> <version>1.2</version> </dependency> ``` ### Gradle ```groovy implementation 'com.scraperapi:sdk:1.2' ``` ### Client instantiation ```java import com.scraperapi.ScraperApiClient; ScraperApiClient client = new ScraperApiClient(System.getenv("SCRAPERAPI_API_KEY")); ``` Never hardcode the API key. Read it from the environment every time. ## Basic Usage The Java SDK uses a **fluent builder** pattern. Chain parameter methods onto the result of `.get()`, then call `.result()` to block and retrieve the HTML. ```java // Simple GET — returns HTML as a String String html = client.get("https://example.com/").result(); // With parameters — chain before .result() String html = client.get("https://example.com/") .render(true) .result(); // Multiple parameters String html = client.get("https://example.com/") .render(true) .countryCode("us") .result(); ``` ## Decision Guide | Situation | Approach | |-----------|---------| | Single URL, synchronous | `.get(url).<params>.result()` | | Page loads content via JavaScript | Chain `.render(true)` | | Site blocks datacenter proxies | Chain `.premium(true)` | | Toughest anti-bot protection | Chain `.ultraPremium(true)` | | Multi-step / paginated flow on same domain | Chain `.sessionNumber