PHPackages                             codechap/zoho-analytics-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. codechap/zoho-analytics-api

ActiveLibrary[API Development](/categories/api)

codechap/zoho-analytics-api
===========================

A PSR-4 compliant library to interact with Zoho Analytics API

171PHP

Since Aug 19Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/codeChap/zoho-analytics-api)[ Packagist](https://packagist.org/packages/codechap/zoho-analytics-api)[ RSS](/packages/codechap-zoho-analytics-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Zoho Analytics API PHP Client
=============================

[](#zoho-analytics-api-php-client)

A comprehensive PHP client library for interacting with the Zoho Analytics API v2, featuring OAuth2 authentication, embed URL generation, data export, and comprehensive testing capabilities.

🚀 Features
----------

[](#-features)

- **OAuth2 Authentication** with automatic token refresh
- **Embed URL Generation** for dashboards and reports
- **Shared URL Creation** (login required)
- **Private URL Creation** (no login required)
- **Data Export** in multiple formats (CSV, JSON, XML, PDF, etc.)
- **Comprehensive Testing Suite** with interactive mode
- **Environment Variable Support** for secure credential management
- **Token Management** with automatic persistence

📋 Requirements
--------------

[](#-requirements)

- PHP 7.4 or higher
- Composer
- Zoho Analytics account
- Zoho OAuth application credentials

🛠️ Installation
---------------

[](#️-installation)

1. **Clone the repository:**

    ```
    git clone
    cd zoho-analytics-auth
    ```
2. **Install dependencies:**

    ```
    composer install
    ```
3. **Set up credentials:**

    ```
    cp .env.example .env
    # Edit .env with your actual credentials
    ```

🔧 Configuration
---------------

[](#-configuration)

### Option 1: Environment Variables (Recommended)

[](#option-1-environment-variables-recommended)

Copy `.env.example` to `.env` and fill in your credentials:

```
ZOHO_CLIENT_ID=your_client_id_here
ZOHO_CLIENT_SECRET=your_client_secret_here
ZOHO_ORG_ID=your_organization_id_here
```

### Option 2: External Files

[](#option-2-external-files)

Create these files in your parent directory:

- `../../ZOHO-CLIENT-ID.txt`
- `../../ZOHO-CLIENT-SECRET.txt`
- `../../ZOHO-ORG-ID.txt`

### Getting Zoho Credentials

[](#getting-zoho-credentials)

1. **OAuth Application:**

    - Visit [Zoho API Console](https://api-console.zoho.com/)
    - Create a new application
    - Note your Client ID and Client Secret
2. **Organization ID:**

    - Log into Zoho Analytics
    - Go to Settings → Organization
    - Find your Organization ID

🎯 Usage
-------

[](#-usage)

### Quick Start

[](#quick-start)

```
# Run OAuth authentication flow
php run.php

# Run comprehensive test suite
php test.php

# Interactive testing mode
php test.php interactive
```

### Programmatic Usage

[](#programmatic-usage)

```
require_once 'vendor/autoload.php';

use Codechap\ZohoAnalyticsApi\Auth;
use Codechap\ZohoAnalyticsApi\Client;

// Initialize authentication
$auth = new Auth();
$auth->set('clientId', 'your_client_id')
     ->set('clientSecret', 'your_client_secret')
     ->set('redirectUri', 'http://localhost:8080')
     ->set('accountsUrl', 'https://accounts.zoho.eu')
     ->set('scopes', [
         'ZohoAnalytics.data.all',
         'ZohoAnalytics.metadata.read',
         'ZohoAnalytics.embed.read',
         'ZohoAnalytics.embed.update'
     ]);

// Create API client
$client = new Client($auth, 'your_org_id');

// Example: Create embed URL
$config = [
    'includeTitle' => true,
    'includeToolBar' => true,
    'validityPeriod' => 3600
];

$result = $client->makeRequest('GET', "/restapi/v2/workspaces/{$workspaceId}/views/{$viewId}/publish/embed", [
    'query' => ['CONFIG' => json_encode($config)]
]);
```

🧪 Testing Features
------------------

[](#-testing-features)

### Available Tests

[](#available-tests)

1. **Workspace Listing** - List all accessible workspaces
2. **View Listing** - List views within a workspace
3. **Embed URLs** - Create time-limited embed URLs (no login required)
4. **Shared URLs** - Create shared URLs (login required)
5. **Private URLs** - Create private URLs (no login required)
6. **Data Export** - Export data in various formats
7. **Token Refresh** - Test automatic token renewal

### Interactive Mode

[](#interactive-mode)

```
php test.php interactive
```

Menu options:

- `[0]` List workspaces
- `[1]` List views in workspace
- `[2]` Create embed URL
- `[3]` Create shared URL
- `[4]` Create private URL (no login)
- `[5]` Test advanced embed options
- `[6]` Export data from view
- `[7]` Test token refresh
- `[8]` Run full test suite

### Full Test Suite

[](#full-test-suite)

```
php test.php
```

Runs all tests automatically and provides comprehensive output including:

- Authentication status
- Available workspaces and views
- Generated URLs for testing
- Export capabilities
- Error diagnostics

🔐 Security
----------

[](#-security)

### Credential Protection

[](#credential-protection)

- **Environment Variables**: Preferred method for credential storage
- **File Exclusion**: All credential files are gitignored
- **Token Security**: Tokens are stored locally and never committed
- **No Hardcoding**: No credentials are hardcoded in the codebase

### OAuth Scopes

[](#oauth-scopes)

The application uses minimal required scopes:

- `ZohoAnalytics.data.all` - Data access
- `ZohoAnalytics.metadata.read` - Workspace/view metadata
- `ZohoAnalytics.embed.read` - Embed URL creation
- `ZohoAnalytics.embed.update` - Private URL creation

📊 API Endpoints
---------------

[](#-api-endpoints)

### Supported Endpoints

[](#supported-endpoints)

EndpointPurposeLogin RequiredExpiry`/publish/embed`Embed URLsNoConfigurable (default: 1h)`/publish`Shared URLsYesPermanent`/publish/privatelink`Private URLsNoConfigurable`/data`Data ExportN/AN/A### URL Types Comparison

[](#url-types-comparison)

FeatureEmbed URLShared URLPrivate URL**Login Required**❌ No✅ Yes❌ No**Expiry Control**✅ Yes❌ No✅ Yes**Security**Time-basedLogin-basedKey-based**Use Case**EmbeddingSharingPublic access🚨 Troubleshooting
-----------------

[](#-troubleshooting)

### Permission Issues

[](#permission-issues)

If you get `SECURITY_NOT_PERMITTED` errors:

1. **User Permissions:**

    - Must have 'Workspace Admin' or 'Workspace Editor' role
    - Must have 'Embed' permissions enabled
2. **OAuth Scopes:**

    - Ensure all required scopes are granted
    - Re-authenticate if you added new scopes
3. **Organization Settings:**

    - Enable 'Embed Reports' in Organization permissions
    - Check domain restrictions

### Common Issues

[](#common-issues)

- **Invalid Credentials**: Check environment variables or credential files
- **Token Expired**: Run `php run.php` to re-authenticate
- **Missing Permissions**: Verify user role in Zoho Analytics workspace
- **Network Issues**: Check firewall settings for OAuth callbacks

📁 Project Structure
-------------------

[](#-project-structure)

```
zoho-analytics-auth/
├── src/
│   ├── Auth.php          # OAuth2 authentication handler
│   └── Client.php        # API client with request handling
├── test.php              # Comprehensive testing suite
├── run.php               # OAuth authentication flow
├── export.php            # Data export examples
├── .env.example          # Environment configuration template
├── .gitignore            # Security exclusions
└── README.md             # This file

```

🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

📄 License
---------

[](#-license)

This project is open source. Please check the license file for details.

🔗 Related Links
---------------

[](#-related-links)

- [Zoho Analytics API Documentation](https://www.zoho.com/analytics/api/v2/)
- [Zoho API Console](https://api-console.zoho.com/)
- [OAuth 2.0 Specification](https://oauth.net/2/)

⚠️ Important Notes
------------------

[](#️-important-notes)

- **Never commit credentials** to version control
- **Use HTTPS** for all API requests
- **Store tokens securely** and never share them
- **Test in development** before production use
- **Monitor API usage** to stay within limits

For support or questions, please open an issue in the repository.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance41

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb9295442ae3080252d831794578a67b53968136834c0ebb1878d4f495a1f79a?d=identicon)[CodeChap](/maintainers/CodeChap)

---

Top Contributors

[![codeChap](https://avatars.githubusercontent.com/u/451621?v=4)](https://github.com/codeChap "codeChap (11 commits)")

### Embed Badge

![Health badge](/badges/codechap-zoho-analytics-api/health.svg)

```
[![Health](https://phpackages.com/badges/codechap-zoho-analytics-api/health.svg)](https://phpackages.com/packages/codechap-zoho-analytics-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
