tims/zomato-php-sdk

PHP SDK for the Zomato Restaurant API (v2.1)

Maintainers

Package info

github.com/timslabs/zomato-php-sdk

pkg:composer/tims/zomato-php-sdk

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-07-26 04:28 UTC

This package is auto-updated.

Last update: 2026-07-26 04:42:07 UTC


README

PHP SDK for the Zomato Restaurant API (v2.1).

Covers the public endpoints documented by Zomato and mirrored in the community Postman collection.

Requirements

  • PHP 8.1+ (8.1, 8.2, 8.3, and 8.4)
  • ext-json
  • Guzzle 7

Installation

composer require tims/zomato-php-sdk

Authentication

Create an API key in the Zomato developer portal. Every request sends it as the user-key header.

use Tims\Zomato\ZomatoClient;

$zomato = new ZomatoClient(getenv('ZOMATO_USER_KEY'));

Do not commit API keys. Prefer environment variables.

Quick start

use Tims\Zomato\Enums\EntityType;
use Tims\Zomato\Enums\Sort;
use Tims\Zomato\ZomatoClient;

$zomato = new ZomatoClient($userKey);

$categories = $zomato->categories();
$cities = $zomato->cities(['q' => 'Mumbai', 'count' => 5]);

$results = $zomato->search([
    'entity_id' => 1,
    'entity_type' => EntityType::City,
    'q' => 'pizza',
    'cuisines' => [25, 55],
    'sort' => Sort::Rating,
    'count' => 20,
]);

Successful responses are decoded JSON arrays. Failed HTTP responses throw Tims\Zomato\ApiException.

Configuration

Constructor argument Default Purpose
$userKey required Zomato API key (user-key header)
$httpClient new Guzzle client Inject a custom Guzzle client (tests, middleware)
$guzzleOptions [] Extra Guzzle options when the default client is created
$baseUrl https://developers.zomato.com/api/v2.1 Override API base URL
$zomato = new ZomatoClient(
    userKey: $userKey,
    baseUrl: 'https://developers.zomato.com/api/v2.1',
);

Error handling

use Tims\Zomato\ApiException;
use Tims\Zomato\ZomatoClient;

try {
    $data = (new ZomatoClient($userKey))->restaurant(16506740);
} catch (ApiException $e) {
    $e->getStatusCode();      // HTTP status
    $e->getResponseBody();    // raw body
    $e->getResponseHeaders(); // response headers
    $e->getMessage();
}

API reference

Base URL: https://developers.zomato.com/api/v2.1

Common

Method HTTP Path Notes
categories() GET /categories No query params
cities(array $params = []) GET /cities q, lat, lon, city_ids, count
collections(array $params = []) GET /collections city_id, lat, lon, count
cuisines(array $params = []) GET /cuisines city_id, lat, lon
establishments(array $params = []) GET /establishments city_id, lat, lon

Locations

Method HTTP Path Notes
geocode(float $lat, float $lon) GET /geocode Required lat, lon
locations(string $query, array $params = []) GET /locations Required query; optional lat, lon, count
locationDetails(int|string $entityId, string|EntityType $entityType) GET /location_details Required entity_id, entity_type

Restaurants

Method HTTP Path Notes
restaurant(int|string $resId) GET /restaurant Required res_id
dailyMenu(int|string $resId) GET /dailymenu Required res_id
reviews(int|string $resId, array $params = []) GET /reviews Required res_id; optional start, count
search(array $params = []) GET /search See search parameters below

Search parameters

Param Type Description
entity_id int|string Location id
entity_type string|EntityType city, subzone, zone, landmark, metro, group
q string Keyword
start int Offset
count int Max results
lat / lon float Coordinates
radius float Radius in meters
cuisines string|array Cuisine ids
establishment_type int|string From /establishments
collection_id int|string From /collections
category string|array From /categories
sort string|Sort cost, rating, real_distance
order string|Order asc, desc

Arrays for cuisines / category are joined as comma-separated values.

Enums

use Tims\Zomato\Enums\EntityType;
use Tims\Zomato\Enums\Order;
use Tims\Zomato\Enums\Sort;

EntityType::City;
Sort::Rating;
Order::Desc;

Examples

export ZOMATO_USER_KEY=your_key
php examples/categories.php

Testing

composer install
composer test

Tests use Guzzle mock handlers; no live API key is required.

Laravel

A Laravel wrapper (laravel-zomato) will be published separately. It will read ZOMATO_USER_KEY / ZOMATO_BASE_URL from config and bind ZomatoClient in the container.

License

This package is open-sourced software licensed under the MIT license.

Copyright (c) 2026 TIMS.