Skip to main content
The official Swift SDK for Spidra uses modern async/await concurrency throughout. All results come back as structured data ready to feed into your iOS, macOS, or server-side Swift applications.

Installation

Swift Package Manager

Add Spidra to your Package.swift dependencies:
Or add it directly via Xcode: File → Add Packages… and paste the repository URL.
Get your API key from app.spidra.io under Settings → API Keys. Never hardcode it in source files — use an environment variable instead.

Requirements

  • Swift 5.9+
  • iOS 15.0+ / macOS 12.0+ / tvOS 15.0+ / watchOS 8.0+
  • A Spidra API key (sign up free)

Getting started

From here you access everything through spidra.scrape, spidra.batch, spidra.crawl, spidra.logs, and spidra.usage.

Quick start


Scraping

All scrape jobs run asynchronously using Swift’s async/await. The run() method submits a job and polls until it finishes. Up to 3 URLs can be passed per request and they are processed in parallel.

Basic scrape

Parameters

Fire-and-forget approach

Use submit() and get() when you want to manage polling yourself.
Job statuses: waiting · active · completed · failed

Structured JSON output

Pass a schema to enforce an exact output shape. Missing fields come back as null rather than hallucinated values.

Geo-targeted scraping

Pass useProxy: true and a proxyCountry code to route through a residential IP in that country.
Supported codes include us, gb, de, fr, jp, au, ca, br, in, nl, and 40+ more. Use "global" or "eu" for regional routing.

Authenticated pages

Pass cookies as a string to scrape pages that require a login session.

Browser actions

Actions let you interact with the page before the scrape runs. They execute in order.
Available actions

forEach — loop over every element

forEach finds a set of elements and processes each individually. Best used when dealing with pagination, clicking into detail pages, or looping over long lists.
Modes:
  • inline — Read element content directly without navigating away.
  • navigate — Follow each element’s link to its destination page and capture content there.
  • click — Click each element, capture the content that appears (e.g., a modal), then move on.
You can also use pagination to navigate through multiple pages automatically:

Poll options

Override default polling intervals via PollOptions:
The same options work on batch.run() and crawl.run().

Batch scraping

Submit up to 50 URLs in a single request. All URLs are processed in parallel. Each URL is a plain string.
Item statuses: pending · running · completed · failed Batch statuses: pending · running · completed · failed · cancelled You can also list(), retry(), or cancel() batches using the same pattern as scrape.

Crawling

Given a starting URL, Spidra discovers pages automatically according to your instruction and extracts structured data from each one.
Parameters

Download crawled content

Fetch signed download URLs for HTML and Markdown for all crawled pages. Links expire after 1 hour.

Logs

Every API scrape job is logged automatically.

Usage statistics

Returns credit and request usage broken down by day or week.

Error handling

Every API error throws a SpidraError. Catch the specific case you care about.

.NET

Official .NET SDK — fully async, typed exceptions, JSON schema support. Requires .NET 8+.

Java

Official Java SDK — CompletableFuture-based, builder pattern, no extra HTTP dependencies.