Download the PHP package webscraping-ai/webscraping-ai-php without Composer

On this page you can find all versions of the php package webscraping-ai/webscraping-ai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package webscraping-ai-php

WebScraping.AI PHP Client

Packagist Version CI

Official PHP client for the WebScraping.AI API.

The API gives you LLM-powered scraping tools with Chromium JavaScript rendering, rotating proxies, and built-in HTML parsing — full HTML, visible text, selected page areas, AI-extracted fields, and free-form question answering over any URL.

Requirements

If you don't already have these installed, the simplest pair is:

php-http/discovery (a transitive dependency) will pick them up automatically.

Installation

Quick start

Sign up to get an API key — a free trial, no credit card required. Your key lives in the dashboard.

All optional parameters (headers, timeout, js, js_timeout, wait_for, proxy, country, custom_proxy, device, error_on_404, error_on_redirect, js_script, …) are PHP named arguments. See the API docs for the full parameter reference.

Search engine results (SERP)

serp() returns parsed Google results for a query. It is query-shaped rather than URL-shaped, so none of the page-scraping parameters above apply — only q (required), engine ("google", the default), gl (country, default "us"), hl (language, default "en") and page (1–100, 10 results per page; the server rejects values above 100 with a 400). Priced per search (see pricing); failed searches are not charged.

The client validates before sending: an empty or whitespace-only q, or a page below 1, throws \InvalidArgumentException and no request (or charge) is made. The server also rejects a bad page with a 400 (not billed); checking client-side saves the round trip.

The decoded array has search_parameters, search_information, organic_results (position, title, link, domain, displayed_link, and optionally snippet / date), related_searches (optional) and pagination. Optional keys are omitted rather than set to null.

Structured data for supported sites

data() returns structured JSON for a public page on a supported site — pass the page's normal URL, e.g. a YouTube video/channel/playlist, TikTok video/profile, X (Twitter) post/profile, LinkedIn company/job/profile, Instagram post/reel/profile or Reddit post/subreddit/user. The site (provider) and page kind (type) are detected from the URL. Priced per site (see pricing), including results that parse empty or no longer exist; unsupported URLs and failed fetches are not charged.

More sites and page types are added on the server over time and work without upgrading this package, so the client does not check which sites are supported — only that url is non-blank (a blank url throws \InvalidArgumentException before any request). An unsupported URL or page type returns a 400 that is not charged (BadRequestException). Its message lists what is supported. For other sites use fields().

None of the page-scraping parameters (js, proxy, headers, timeout, …) apply. The options are:

The decoded array has request_parameters (url, provider, type), parse_status and data. provider and type are open sets — expect new values. parse_status is ok, parse_failed (fetched but not parsed; data may be null or partial) or not_found; all three are charged successes. The shape of data depends on provider and type.

Provider-specific parameters added server-side after this release can be sent through params, as-is (scalar values; null is dropped). api_key, url, country, transcript and transcript_language are rejected with \InvalidArgumentException — use the named arguments for those, even when you haven't set them:

Bring your own HTTP client

By default, the client builds its own transport. If Guzzle is installed it is used with a request deadline applied (see Timeouts); otherwise php-http/discovery resolves whatever PSR-18 client is installed. To pin a specific client, pass it explicitly:

Injecting your own client opts out of the default deadline — configure transport-level timeouts on the client you pass.

Timeouts

Two different timeouts are in play, and they're easy to confuse:

By default the client applies a transport deadline when it builds its own client and Guzzle is available: a total request timeout of Client::DEFAULT_TIMEOUT (60s) and a TCP connect timeout of Client::DEFAULT_CONNECT_TIMEOUT (10s). Override them via the constructor:

These constructor timeouts apply only to the auto-built default client. If you inject your own httpClient, or no concrete client (Guzzle) is available and discovery falls back to an unknown PSR-18 implementation, no deadline is imposed — in that case inject a client with timeouts configured to get one.

Errors

The client raises typed exceptions for every documented status code:

Status Exception
400 WebScrapingAI\Exception\BadRequestException
402 WebScrapingAI\Exception\PaymentRequiredException
403 WebScrapingAI\Exception\AuthenticationException
429 WebScrapingAI\Exception\RateLimitException
500 WebScrapingAI\Exception\ServerException
504 WebScrapingAI\Exception\GatewayTimeoutException

All inherit from WebScrapingAI\Exception\ApiException, which exposes $message, $status, $statusCode, $statusMessage, $body, and $responseBody. The latter three are populated when the API surfaces target-page errors as 500s.

Transport-level failures raise WebScrapingAI\Exception\ApiTimeoutException (the PSR-18 client timed out) or WebScrapingAI\Exception\ApiConnectionException (DNS / connection refused / TLS).

All SDK-originated exceptions implement the marker interface WebScrapingAI\Exception\WebScrapingAIException, so a single catch (WebScrapingAIException $e) block catches everything.

Response shapes

The client returns whatever the API returns — it does not normalise or unwrap. A couple of current quirks worth knowing:

These are upstream spec/server drifts; the official Ruby and Python clients return the same shapes.

Migration from 3.x

3.x was generated from the OpenAPI spec under the namespace OpenAPI\Client\ and used per-tag classes (AIApi, HTMLApi, etc.). 4.0 is a hand-authored rewrite with a single WebScrapingAI\Client entry point. There are no deprecation shims — pin to ^3.2 if you need the old surface.

Development

Links

License

MIT — see LICENSE.


All versions of webscraping-ai-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
php-http/discovery Version ^1.19
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webscraping-ai/webscraping-ai-php contains the following files

Loading the files please wait ...