PHPackages                             ceresaconsultoria/sdk-php-nuvemshop - 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. ceresaconsultoria/sdk-php-nuvemshop

ActiveLibrary[API Development](/categories/api)

ceresaconsultoria/sdk-php-nuvemshop
===================================

A PHP SDK for the Tienda Nube/Nuvem Shop API.

v1.0.4(3y ago)0261MITPHP

Since Oct 20Pushed 3y agoCompare

[ Source](https://github.com/ceresaconsultoria/sdk-php-nuvemshop)[ Packagist](https://packagist.org/packages/ceresaconsultoria/sdk-php-nuvemshop)[ RSS](/packages/ceresaconsultoria-sdk-php-nuvemshop/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Tienda Nube/Nuvem Shop SDK for PHP
==================================

[](#tienda-nubenuvem-shop-sdk-for-php)

This SDK provides a simplified access to the [API](https://github.com/TiendaNube/api-docs) of [Nuvem Shop](https://www.nuvemshop.com.br) / [Tienda Nube](https://www.tiendanube.com).

Installation
------------

[](#installation)

This SDK is mounted on top of [Requests for PHP](https://github.com/rmccue/Requests), so we recommend using [Composer](https://github.com/composer/composer) for installing.

Simply add the `ceresaconsultoria/sdk-php-nuvemshop` requirement to composer.json.

```
{
    "require": {
        "ceresaconsultoria/sdk-php-nuvemshop": ">=1.0"
    }
}
```

Then run `composer install` or `composer update` to complete the installation.

If you need an autoloader, you can use the one provided by Composer:

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

Authenticating Your App
-----------------------

[](#authenticating-your-app)

When a user installs your app, he will be taken to your specified Redirect URI with a parameter called `code` containing your temporary authorization code.

With this code you can request a permanent access token.

```
$code = $_GET['code'];

$auth = new TiendaNube\Auth(CLIENT_ID, CLIENT_SECRET);
$store_info = $auth->request_access_token($code);
```

The returned value will contain the id of the authenticated store, as well as the access token and the authorized scopes.

```
var_dump($store_info);
//array (size=3)
//  'store_id' => string '1234' (length=4)
//  'access_token' => string 'a2b544066ee78926bd0dfc8d7bd784e2e016b422' (length=40)
//  'scope' => string 'read_products,read_orders,read_customers' (length=40)
```

Keep in mind that future visits to your app will not go through the Redirect URI, so you should store the store id in a session.

However, if you need to authenticate a user that has already installed your app (or invite them to install it), you can redirect them to login to the Tienda Nube/Nuvem Shop site.

```
$auth = new TiendaNube\Auth(CLIENT_ID, CLIENT_SECRET);

//You can use one of these to obtain a url to login to your app
$url = $auth->login_url_brazil();
$url = $auth->login_url_spanish();

//Redirect to $url
```

After the user has logged in, he will be taken to your specified Redirect URI with a new authorization code. You can use this code to request a new request token.

Making a Request
----------------

[](#making-a-request)

The first step is to instantiate the `API` class with a store id and an access token, as well as a [user agent to identify your app](https://github.com/TiendaNube/api-docs#identify-your-app). Then you can use the `get`, `post`, `put` and `delete` methods.

```
$api = new TiendaNube\API(STORE_ID, ACCESS_TOKEN, 'Awesome App (contact@awesome.com)');
$response = $api->get("products");
var_dump($response->body);
```

You can access the headers of the response via `$response->headers` as if it were an array:

```
var_dump(isset($response->headers['X-Total-Count']));
//boolean true

var_dump($response->headers['X-Total-Count']);
//string '48' (length=2)
```

For convenience, the `X-Main-Language` header can be obtained from `$response->main_language`:

```
$response = $api->get("products/123456");
$language = $response->main_language;
var_dump($response->body->name->$language);
```

Other examples:

```
//Create a product
$response = $api->post("products", [
    'name' => 'Tienda Nube',
]);
$product_id = $response->body->id;

//Change its name
$response = $api->put("products/$product_id", [
    'name' => 'Nuvem Shop',
]);

//And delete it
$response = $api->delete("products/$product_id");

//You can also send arguments to GET requests
$response = $api->get("orders", [
    'since_id' => 10000,
]);
```

For list results you can use the `next`, `prev`, `first` and `last` methods to retrieve the corresponding page as a new response object.

```
$response = $api->get('products');
while($response != null){
    foreach($response->body as $product){
        var_dump($product->id);
    }
    $response = $response->next();
}
```

Exceptions
----------

[](#exceptions)

Calls to `Auth` may throw a `Tiendanube\Auth\Exception`:

```
try{
    $auth->request_access_token($code);
} catch(Tiendanube\Auth\Exception $e){
    var_dump($e->getMessage());
    //string '[invalid_grant] The authorization code has expired' (length=50)
}
```

Likewise, calls to `API` may throw a `Tiendanube\API\Exception`. You can retrieve the original response from these exceptions:

```
try{
    $api->get('products');
} catch(Tiendanube\API\Exception $e){
    var_dump($e->getMessage());
    //string 'Returned with status code 401: Invalid access token' (length=43)

    var_dump($e->response->body);
    //object(stdClass)[165]
    //  public 'code' => int 401
    //  public 'message' => string 'Unauthorized' (length=12)
    //  public 'description' => string 'Invalid access token' (length=20)
}
```

Requests that return 404 will throw a subclass called `Tiendanube\API\NotFoundException`.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~0 days

Total

5

Last Release

1301d ago

### Community

Maintainers

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

---

Top Contributors

[![fonse](https://avatars.githubusercontent.com/u/605137?v=4)](https://github.com/fonse "fonse (14 commits)")[![ceresaconsultoria](https://avatars.githubusercontent.com/u/56128744?v=4)](https://github.com/ceresaconsultoria "ceresaconsultoria (6 commits)")

### Embed Badge

![Health badge](/badges/ceresaconsultoria-sdk-php-nuvemshop/health.svg)

```
[![Health](https://phpackages.com/badges/ceresaconsultoria-sdk-php-nuvemshop/health.svg)](https://phpackages.com/packages/ceresaconsultoria-sdk-php-nuvemshop)
```

###  Alternatives

[razorpay/razorpay

Razorpay PHP Client Library

2024.8M44](/packages/razorpay-razorpay)[pubnub/pubnub

This is the official PubNub PHP SDK repository.

1314.6M17](/packages/pubnub-pubnub)[culqi/culqi-php

Cliente Culqi API para PHP

41356.8k1](/packages/culqi-culqi-php)[ahmadawais/sendy-php-api

Sendy PHP API Wrapper: Complete API interfacing.

8673.5k](/packages/ahmadawais-sendy-php-api)[epayco/epayco-php

Epayco API client for PHP

25187.2k3](/packages/epayco-epayco-php)[yunchuang/appstore-connect-api

sdk for appstore connect api

3865.3k](/packages/yunchuang-appstore-connect-api)

PHPackages © 2026

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