{"id":30283213,"url":"https://github.com/scrapegraphai/scrapegraphai-php","last_synced_at":"2025-08-16T17:33:52.365Z","repository":{"id":309839912,"uuid":"1036617392","full_name":"ScrapeGraphAI/scrapegraphai-php","owner":"ScrapeGraphAI","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-14T03:18:17.000Z","size":110,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-14T05:29:34.152Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ScrapeGraphAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-12T10:38:56.000Z","updated_at":"2025-08-12T12:25:58.000Z","dependencies_parsed_at":"2025-08-14T05:29:38.135Z","dependency_job_id":"69603b4b-6d89-461b-9bfa-6004dde671aa","html_url":"https://github.com/ScrapeGraphAI/scrapegraphai-php","commit_stats":null,"previous_names":["scrapegraphai/scrapegraphai-php"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ScrapeGraphAI/scrapegraphai-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScrapeGraphAI%2Fscrapegraphai-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScrapeGraphAI%2Fscrapegraphai-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScrapeGraphAI%2Fscrapegraphai-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScrapeGraphAI%2Fscrapegraphai-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ScrapeGraphAI","download_url":"https://codeload.github.com/ScrapeGraphAI/scrapegraphai-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ScrapeGraphAI%2Fscrapegraphai-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270746900,"owners_count":24638445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-16T17:33:51.518Z","updated_at":"2025-08-16T17:33:52.338Z","avatar_url":"https://github.com/ScrapeGraphAI.png","language":"PHP","readme":"# Scrapegraphai PHP API library\n\n\u003e [!NOTE]\n\u003e The Scrapegraphai PHP API Library is currently in **beta** and we're excited for you to experiment with it!\n\u003e\n\u003e This library has not yet been exhaustively tested in production environments and may be missing some features you'd expect in a stable release. As we continue development, there may be breaking changes that require updates to your code.\n\u003e\n\u003e **We'd love your feedback!** Please share any suggestions, bug reports, feature requests, or general thoughts by [filing an issue](https://www.github.com/stainless-sdks/scrapegraphai-php/issues/new).\n\nThe Scrapegraphai PHP library provides convenient access to the Scrapegraphai REST API from any PHP 8.1.0+ application.\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## Documentation\n\nThe REST API documentation can be found on [scrapegraphai.com](https://scrapegraphai.com).\n\n## Installation\n\nTo use this package, install via Composer by adding the following to your application's `composer.json`:\n\n```json\n{\n  \"repositories\": [\n    {\n      \"type\": \"vcs\",\n      \"url\": \"git@github.com:stainless-sdks/scrapegraphai-php.git\"\n    }\n  ],\n  \"require\": {\n    \"org-placeholder/scrapegraphai\": \"dev-main\"\n  }\n}\n```\n\n## Usage\n\n```php\n\u003c?php\n\nuse Scrapegraphai\\Client;\nuse Scrapegraphai\\Smartscraper\\SmartscraperCreateParams;\n\n$client = new Client(\n  apiKey: getenv(\"SCRAPEGRAPHAI_API_KEY\") ?: \"My API Key\",\n  environment: \"environment_1\",\n);\n\n$params = SmartscraperCreateParams::from(\n  userPrompt: \"Extract the product name, price, and description\"\n);\n$completedSmartscraper = $client-\u003esmartscraper-\u003ecreate($params);\n\nvar_dump($completedSmartscraper-\u003erequest_id);\n```\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `Scrapegraphai\\Errors\\APIError` will be thrown:\n\n```php\n\u003c?php\n\nuse Scrapegraphai\\Errors\\APIConnectionError;\nuse Scrapegraphai\\Smartscraper\\SmartscraperCreateParams;\n\ntry {\n    $params = SmartscraperCreateParams::from(\n      userPrompt: \"Extract the product name, price, and description\"\n    );\n    $Smartscraper = $client-\u003esmartscraper-\u003ecreate($params);\n} catch (APIConnectionError $e) {\n    echo \"The server could not be reached\", PHP_EOL;\n    var_dump($e-\u003egetPrevious());\n} catch (RateLimitError $_) {\n    echo \"A 429 status code was received; we should back off a bit.\", PHP_EOL;\n} catch (APIStatusError $e) {\n    echo \"Another non-200-range status code was received\", PHP_EOL;\n    var_dump($e-\u003estatus);\n}\n```\n\nError codes are as follows:\n\n| Cause            | Error Type                 |\n| ---------------- | -------------------------- |\n| HTTP 400         | `BadRequestError`          |\n| HTTP 401         | `AuthenticationError`      |\n| HTTP 403         | `PermissionDeniedError`    |\n| HTTP 404         | `NotFoundError`            |\n| HTTP 409         | `ConflictError`            |\n| HTTP 422         | `UnprocessableEntityError` |\n| HTTP 429         | `RateLimitError`           |\n| HTTP \u003e= 500      | `InternalServerError`      |\n| Other HTTP error | `APIStatusError`           |\n| Timeout          | `APITimeoutError`          |\n| Network error    | `APIConnectionError`       |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, \u003e=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```php\n\u003c?php\n\nuse Scrapegraphai\\Client;\nuse Scrapegraphai\\RequestOptions;\nuse Scrapegraphai\\Smartscraper\\SmartscraperCreateParams;\n\n// Configure the default for all requests:\n$client = new Client(maxRetries: 0);\n$params = SmartscraperCreateParams::from(\n  userPrompt: \"Extract the product name, price, and description\"\n);\n\n// Or, configure per-request:\n$result = $client\n  -\u003esmartscraper\n  -\u003ecreate($params, new RequestOptions(maxRetries: 5));\n```\n\n## Advanced concepts\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```php\n\u003c?php\n\nuse Scrapegraphai\\RequestOptions;\nuse Scrapegraphai\\Smartscraper\\SmartscraperCreateParams;\n\n$params = SmartscraperCreateParams::from(\n  userPrompt: \"Extract the product name, price, and description\"\n);\n$completedSmartscraper = $client\n  -\u003esmartscraper\n  -\u003ecreate(\n  $params,\n  new RequestOptions(\n    extraQueryParams: [\"my_query_parameter\" =\u003e \"value\"],\n    extraBodyParams: [\"my_body_parameter\" =\u003e \"value\"],\n    extraHeaders: [\"my-header\" =\u003e \"value\"],\n  ),\n);\n\nvar_dump($completedSmartscraper[\"my_undocumented_property\"]);\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```php\n\u003c?php\n\n$response = $client-\u003erequest(\n  method: \"post\",\n  path: '/undocumented/endpoint',\n  query: ['dog' =\u003e 'woof'],\n  headers: ['useful-header' =\u003e 'interesting-value'],\n  body: ['hello' =\u003e 'world']\n);\n```\n\n## Examples\n\nThe `examples/` directory contains comprehensive examples demonstrating various use cases:\n\n### Basic Examples\n- **[SmartScraper](examples/basic/basic-smartscraper.php)** - Extract data from web pages using natural language prompts\n- **[Markdownify](examples/basic/basic-markdownify.php)** - Convert web pages to clean Markdown format\n- **[SearchScraper](examples/basic/basic-searchscraper.php)** - Search and scrape data from multiple websites\n- **[Crawl](examples/basic/basic-crawl.php)** - Systematically crawl entire websites\n- **[Generate Schema](examples/basic/basic-schema.php)** - Generate JSON schemas from natural language\n- **[Credits](examples/basic/basic-credits.php)** - Check your API credit balance\n- **[Validate](examples/basic/basic-validate.php)** - Validate your API key\n\n### Advanced Examples\n- **[Advanced SmartScraper](examples/advanced/advanced-smartscraper.php)** - Complex schemas, JavaScript rendering, pagination\n- **[Error Handling](examples/advanced/advanced-error-handling.php)** - Comprehensive error handling strategies\n\n### Real-World Use Cases\n- **[E-commerce Scraper](examples/use-cases/ecommerce-scraper.php)** - Product monitoring, price comparison, review analysis\n- **[News Aggregator](examples/use-cases/news-aggregator.php)** - Multi-source news monitoring, sentiment analysis\n- **[Job Listings](examples/use-cases/job-listings.php)** - Job search aggregation, salary benchmarking, skills analysis\n\n### Quick Start Example\n\n```php\n\u003c?php\nrequire_once 'vendor/autoload.php';\n\nuse Scrapegraphai\\Client;\nuse Scrapegraphai\\Smartscraper\\SmartscraperCreateParams;\n\n// Initialize client\n$client = new Client(\n    apiKey: getenv('SCRAPEGRAPHAI_API_KEY')\n);\n\n// Extract product information\n$params = SmartscraperCreateParams::from(\n    userPrompt: \"Extract the product name, price, and rating\",\n    websiteURL: \"https://example-store.com/product\"\n);\n\n$result = $client-\u003esmartscraper-\u003ecreate($params);\necho json_encode($result-\u003edata, JSON_PRETTY_PRINT);\n```\n\nFor more examples and detailed documentation, see the [examples directory](examples/).\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) PHPDoc type definitions to be non-breaking changes.\n\n## Requirements\n\nPHP 8.1.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/stainless-sdks/scrapegraphai-php/tree/main/CONTRIBUTING.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrapegraphai%2Fscrapegraphai-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscrapegraphai%2Fscrapegraphai-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscrapegraphai%2Fscrapegraphai-php/lists"}