PHPackages                             altravia/openapi - 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. altravia/openapi

ActiveLibrary[API Development](/categories/api)

altravia/openapi
================

OpenApi PHP Libraries (https://openapi.it)

1.1.0(4y ago)67.7k↓40%5[2 PRs](https://github.com/openapi/openapi-dotnet-sdk/pulls)PHPPHP &gt;=7.2.0CI passing

Since Sep 29Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/openapi/openapi-dotnet-sdk)[ Packagist](https://packagist.org/packages/altravia/openapi)[ RSS](/packages/altravia-openapi/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)DependenciesVersions (11)Used By (0)

[![Read this!](https://raw.githubusercontent.com/openapi/.github/main/assets/under-construction-a5.gif)](https://raw.githubusercontent.com/openapi/.github/main/assets/under-construction-a5.gif)

⚠️ Heads Up, Hackers
====================

[](#️-heads-up-hackers)

This codebase is entering **⚡ heavy refactoring ⚡**
…and switching its **main language**.

> Expect broken APIs, moving files, disappearing functions…
> …basically, chaos with a purpose.

**TL;DR:** Don’t rely on this as “stable”… yet.
Fork, explore, contribute, but **brace for impact**.

---

OpenAPI Library
===============

[](#openapi-library)

- 1. [Installation](#Installation)
- 2. [Usage](#Usage)

    - 2.1. [Instanza della classe](#Instanzadellaclasse)
    - 2.2. [Esempi](#Esempi)
- 3. [Modulo comuni](#Modulocomuni)

    - 3.1. [Esempi](#Esempi-1)
- 4. [Modulo imprese](#Moduloimprese)

    - 4.1. [Utilizzo](#Utilizzo)
    - 4.2. [Esempi](#Esempi-1)
- 5. [Modulo Marche Temporali](#ModuloMarcheTemporali)

    - 5.1. [Esempi](#Esempi-1)
- 6. [Modulo SMS](#ModuloSMS)

    - 6.1. [Inviare un SMS](#InviareunSMS)
- 7. [Modulo Visengine](#ModuloVisengine)

1. Installation
-------------------------------------------------------

[](#1-installation)

```
composer require altravia/openapi
```

2. Usage
-----------------------------------------

[](#2-usage)

### 2.1. Instanza della classe

[](#21-instanza-della-classe)

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

$openapi = new \OpenApi\OpenApi($scopes, $user, $apikey, $environment);
```

Dove `$scopes` è un array di stringhe o di oggetti in uno dei seguenti formati:

```
$scopes = [
    "GET:ws.ufficiopostale.com/comuni",
    [
        "domain"=>"ws.ufficiopostale.com",
        "method"=>"comuni",
        "mode"  =>"GET"
    ]
];
```

...e `$environment` è l'ambiente sceltro tra `'test'` (default) e `'production'`

OpenApi si occuperá di reperire automaticamente, o generare, un nuovo token quando necessario.

A questo punto, in base agli scopes indicati vengono creati i seguenti oggetti:

```
// Ogni oggetto verrá creato solo se disponibile nello scope.
$openapi->ufficiopostale;
$openapi->comuni;
$openapi->imprese;
$openapi->visengine;
$openapi->marcheTemporali;
$openapi->geocoding;
$openapi->SMS;
$openapi->firmaDigitale;
$openapi->pecMassiva;
```

che possono essere usati al seguente modo:

```
$this->openapi->ufficioposale->getCitiesByCap('00132');
```

### 2.2. Esempi

[](#22-esempi)

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

// Dichiaro gli scopes necessari
$scopes = [
    'GET:comuni.openapi.it/cap',
    'GET:imprese.altravia.com/advance',
];

$openapi = new OpenApi\OpenApi($scopes, 'my_username','my_api_key', 'test');

// Comuni: prendi informazioni sul cap 00132
$cap = $openapi->comuni->getCitiesByCap('00132');

// Imprese: prendi informazioni su una specifica impresa
$impresa = $openapi->imprese->getByPartitaIva('12485671007');

// Ufficio Postale: ottieni informaizoni sul tracking
$track = $this->openapi->ufficiopostale->track('123456789');
```

3. Modulo comuni
--------------------------------------------------------

[](#3-modulo-comuni)

Consente di prendere informazioni su comuni e provincie.

- `getCitiesByCap`
- `getComuneByCatasto`
- `getRegioni`
- `getProvince`
- `getComuni`

### 3.1. Esempi

[](#31-esempi)

```
$provincia = 'RM';
$comuni = $this->openapi->comuni->getComuni($provincia);

var_dump($comuni['comuni']);
/*

["nome_provincia"]=>
  string(4) "Roma"
  ["sigla_provincia"]=>
  string(2) "RM"
  ["regione"]=>
  string(5) "Lazio"
  ["comuni"]=>
  array(121) {
    [0]=>
    string(6) "Affile"
    ...
*/
```

4. Modulo imprese
----------------------------------------------------------

[](#4-modulo-imprese)

### 4.1. Utilizzo

[](#41-utilizzo)

Il modulo imprese espone i seguenti metodi:

- `getByPartitaIva`
- `getClosed`
- `getVatGroup`
- `getPec`
- `getBySearch`

Per `getBySearch` e `getByPartitaIva` è richiesto accesso allo scope `/advance`

### 4.2. Esempi

[](#42-esempi)

Utilizziamo `getBySearch` per cercare un'azienda il cui nome inizia con `Altrav` a Roma

```
$autocomplete = $this->openapi->imprese->getBySearch('Altrav*', 'RM');

/*
 [0]=>
  object(stdClass)#41 (10) {
    ["piva"]=>
    string(11) "12485671007"
    ["cf"]=>
    string(11) "12485671007"
    ["denominazione"]=>
    string(20) "ALTRAVIA SERVIZI SRL"
 [1]=>
  object(stdClass)#42 (10) {
    ["id"]=>
    string(24) "4242424242"
    ["denominazione"]=>
    string(18) "xxx Altravia Esempio 2"
    ...
 */
```

5. Modulo Marche Temporali
---------------------------------------------------------------------------

[](#5-modulo-marche-temporali)

- `availability`
- `checkLotto`
- `purcahse`

### 5.1. Esempi

[](#51-esempi)

```
// Controlliamo la disponibilitá di una marca di inforcert o aruba
$disponibilita = $this->openapi->marcheTemporali->availability('infocert', 1);

// Se le marche sono disponibili, acquistiamone una
if ($disponibilita->availability > 0) {
    try {
        $marca = $this->openapi->marcheTemporali->purcahse('infocert', 1);
    } catch (\OpenApi\classes\exception\OpenApiMarcheTemporaliException $e) {
        error_log(var_dump($e));
    }
}
```

6. Modulo SMS
--------------------------------------------------

[](#6-modulo-sms)

- `getRecipients`
- `getMessage`
- `sendMore`
- `sendOne`

### 6.1. Inviare un SMS

[](#61-inviare-un-sms)

Per inviare un SMS, per prima cosa definiamo i destinatari:

```
$recipient = '+39-3939989741';
// OR
$recipients = [
    [
        'number' => '+39-3939989741',
        'fields' => ['nome' => 'NomeDestinatario']
    ]
];
```

Possiamo ora procedere ad inviare un SMS:

```
try {
    $priority = 1;
    $options = null;
    $singleSms = $this->openapi->SMS->sendOne('Nome del mittente', $recipient, 'lorem ipsum', null, $priority, $options);
} catch (\OpenApi\classes\exception\OpenApiConnectionsException $e) {
    throw 'Non è stato possibile recapitare il messaggio';
}
```

Possiamo anche speficiare i prefissi in modo indipendente:

```
$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, null);
```

O passare delle opzioni

```
$options = ['timestamp_send' => '2021-04-20']
$this->openapi->SMS->sendOne('Nome del mittente', '3939989741', 'lorem ipsum', '+42', 1, $options);
```

7. Modulo Visengine
--------------------------------------------------------------

[](#7-modulo-visengine)

Come prima cosa, settiamo l'hash della visura che vogliamo richiedere

```
// https://developers.openapi.it/services/visengine
$this->openapi->visengine->setHash($visura->hash);
```

A questo punto, possiamo lanciare `createRequest`, che ritornerà una istanza vuota della visura che andremo a creare della struttura richiesta

```
$request = $this->openapi->visengine->createRequest();
```

Prodediamo a completare l'oggetto, che potremmo passare a sendRequest quando pronto

```
$request->setJson(['$0' => 'abcd', '$1' => '12485671007']);
                    // url di callback,  oggetto con dati aggiuntivi, metodo
$request->setCallbackData('https://example.com', new stdClass(), 'POST');
$visura = $this->openapi->visengine->sendRequest($request);
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance55

Moderate activity, may be stable

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.4% 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.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~113 days

Total

8

Last Release

1589d ago

Major Versions

v0.9.0 → v1.0.02020-09-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/b332fb47035d30a06fc799d5a41198d08e502307513dd3a683f4532f03d88ec7?d=identicon)[openapi.it](/maintainers/openapi.it)

---

Top Contributors

[![pberanrdiniAltravia](https://avatars.githubusercontent.com/u/68341384?v=4)](https://github.com/pberanrdiniAltravia "pberanrdiniAltravia (19 commits)")[![francescobianco](https://avatars.githubusercontent.com/u/472171?v=4)](https://github.com/francescobianco "francescobianco (5 commits)")[![pberanrdini](https://avatars.githubusercontent.com/u/99032905?v=4)](https://github.com/pberanrdini "pberanrdini (5 commits)")[![lpaderiAltravia](https://avatars.githubusercontent.com/u/85158884?v=4)](https://github.com/lpaderiAltravia "lpaderiAltravia (1 commits)")[![mijorus](https://avatars.githubusercontent.com/u/39067225?v=4)](https://github.com/mijorus "mijorus (1 commits)")[![SimoneDesantisAltravia](https://avatars.githubusercontent.com/u/67371387?v=4)](https://github.com/SimoneDesantisAltravia "SimoneDesantisAltravia (1 commits)")

### Embed Badge

![Health badge](/badges/altravia-openapi/health.svg)

```
[![Health](https://phpackages.com/badges/altravia-openapi/health.svg)](https://phpackages.com/packages/altravia-openapi)
```

###  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)
