Comparing master...feature/upload-image · serpapi/serpapi-php · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: serpapi/serpapi-php
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: serpapi/serpapi-php
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: feature/upload-image
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 7 files changed
  • 1 contributor

Commits on Oct 21, 2026

  1. Add Image API support with uploadImage()

    Uploads a JPG, PNG, or WebP image to POST /image as multipart/form-data
    and returns the decoded response, whose image_id can be passed to
    Google Lens and other engines that accept uploaded images. Mirrors
    upload_image in serpapi-ruby and serpapi-python:
    
    - accepts a file path or a stream; seekable streams are rewound first,
      as Ruby does, and uploaded from a temporary copy because cURL uploads
      by path and CURLStringFile needs PHP 8.1
    - sends the same parameters as any other request (api_key, source,
      default search parameters) as form fields, so the key stays out of
      the URL; per-call api_key and timeout work as for search()
    - sends only the file's base name; without one, cURL would send the
      full local path
    - errors raise SerpApiException with the same context as searches
    
    The persistent cURL handle now resets the method on every GET.
    Without CURLOPT_HTTPGET, a search after an upload went out as a
    multipart POST. Uploads also drop the Expect: 100-continue header:
    libcurl before 7.69 sends it with bodies over 1 KB, SerpApi does not
    answer it, and each upload stalled for a second.
    
    The live integration test uploads a 27 KB public domain thumbnail of
    the Mona Lisa from Wikimedia Commons and searches it with Google Lens.
    strzibny committed Oct 21, 2026
    Configuration menu
    Copy the full SHA
    16cfba2 View commit details
    Browse the repository at this point in the history
Loading