PHPackages                             spatie/dropbox-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. spatie/dropbox-api

ActiveLibrary[API Development](/categories/api)

spatie/dropbox-api
==================

A minimal implementation of Dropbox API v2

1.24.0(2mo ago)3116.0M—1.2%83[1 PRs](https://github.com/spatie/dropbox-api/pulls)20MITPHPPHP ^8.1CI passing

Since Apr 19Pushed 2mo ago8 watchersCompare

[ Source](https://github.com/spatie/dropbox-api)[ Packagist](https://packagist.org/packages/spatie/dropbox-api)[ Docs](https://github.com/spatie/dropbox-api)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-dropbox-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (47)Used By (20)

A minimal implementation of Dropbox API v2
==========================================

[](#a-minimal-implementation-of-dropbox-api-v2)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3ca9ad2c0d29e96d737a1fbb1de5009060bfd99114f8710a2b5a480db7f29808/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f64726f70626f782d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/dropbox-api)[![GitHub Tests Action Status](https://camo.githubusercontent.com/40cc5692359cc0d046a5b6373868d3838e23494888936385db22b555d56369bc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f64726f70626f782d6170692f72756e2d74657374732e796d6c3f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/dropbox-api/actions?query=workflow%3ATests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/643d0ca1f2882526284267d5fe45b22e67b3707a5e9051b363882d7e04273a66/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f64726f70626f782d6170692f636f64652d7374796c652e796d6c3f6c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/spatie/dropbox-api/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/714c253398314e9e4f159473da3339cff992cc4a221d28bb609bb6bbf1fe903e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f64726f70626f782d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/dropbox-api)

This is a minimal PHP implementation of the [Dropbox API v2](https://www.dropbox.com/developers/documentation/http/overview). It contains only the methods needed for [our flysystem-dropbox adapter](https://github.com/spatie/flysystem-dropbox). We are open however to PRs that add extra methods to the client.

Here are a few examples on how you can use the package:

```
$client = new Spatie\Dropbox\Client($authorizationToken);

//create a folder
$client->createFolder($path);

//list a folder
$client->listFolder($path);

//get a temporary link
$client->getTemporaryLink($path);
```

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/b0b7dcd2b1f97b3ef28202371174e1f17fb1e2651c8041cbaa8f78baa6545ff7/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f64726f70626f782d6170692e6a70673f743d31)](https://spatie.be/github-ad-click/dropbox-api)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/dropbox-api
```

Usage
-----

[](#usage)

The first thing you need to do is get an authorization token at Dropbox. Unlike [other companies](https://google.com) Dropbox has made this very easy. You can just generate a token in the [App Console](https://www.dropbox.com/developers/apps) for any Dropbox API app. You'll find more info at [the Dropbox Developer Blog](https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/).

With an authorization token you can instantiate a `Spatie\Dropbox\Client`.

```
$client = new Spatie\Dropbox\Client($authorizationToken);
```

or alternatively you can implement `Spatie\Dropbox\TokenProvider`which will provide the access-token from its `TokenProvider->getToken(): string` method.

If you use oauth2 to authenticate and to acquire refresh-tokens and access-tokens, (like [thephpleague/oauth2-client](https://github.com/thephpleague/oauth2-client)), you can create an adapter that internally takes care of token-expiration and refreshing tokens, and at runtime will supply the access-token via the `TokenProvider->getToken(): string` method.

*(Dropbox announced they will be moving to short-lived access\_tokens mid 2021).*

```
// implements Spatie\Dropbox\TokenProvider
$tokenProvider = new AutoRefreshingDropBoxTokenService($refreshToken);
$client = new Spatie\Dropbox\Client($tokenProvider);
```

or alternatively you can authenticate as an App using your App Key &amp; Secret.

```
$client = new Spatie\Dropbox\Client([$appKey, $appSecret]);
```

If you only need to access the public endpoints you can instantiate `Spatie\Dropbox\Client` without any arguments.

```
$client = new Spatie\Dropbox\Client();
```

Dropbox Endpoints
-----------------

[](#dropbox-endpoints)

Look in [the source code of `Spatie\Dropbox\Client`](https://github.com/spatie/dropbox-api/blob/master/src/Client.php) to discover the methods you can use.

Here's an example:

```
$content = 'hello, world';
$client->upload('/dropboxpath/filename.txt', $content, $mode='add');

$from = '/dropboxpath/somefile.txt';
$to = '/dropboxpath/archive/somefile.txt';
$client->move($from, $to);
```

If the destination filename already exists, dropbox will throw an Exception with 'to/conflict/file/..'

The `upload()` and `move()` methods have an optional extra 'autorename' argument to try and let dropbox automatically rename the file if there is such a conflict.

Here's an example:

```
$from = '/dropboxpath/somefile.txt';
$to = '/dropboxpath/archive/somefile.txt';
$client->move($from, $to, $autorename=true);
// with autorename results in 'somefile (1).txt'
```

If you do not find your favorite method, you can directly use the `contentEndpointRequest` and `rpcEndpointRequest` functions.

```
public function contentEndpointRequest(string $endpoint, array $arguments, $body): ResponseInterface

public function rpcEndpointRequest(string $endpoint, array $parameters): array
```

Here's an example:

```
$client->rpcEndpointRequest('search', ['path' => '', 'query' => 'bat cave']);
```

If you need to change the subdomain of the endpoint URL used in the API request, you can prefix the endpoint path with `subdomain::`.

Here's an example:

```
$client->rpcEndpointRequest('content::files/get_thumbnail_batch', $parameters);
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

You can run `composer pint` to run the code style fixer, and `composer phpstan` to run the static analysis.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Alex Vanderbist](https://github.com/AlexVanderbist)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity65

Solid adoption and visibility

Community42

Growing community involvement

Maturity85

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~75 days

Recently: every ~268 days

Total

44

Last Release

86d ago

Major Versions

0.0.1 → 1.0.02017-04-19

PHP version history (5 changes)0.0.1PHP ^7.0

1.8.0PHP ^7.1

1.16.1PHP ^7.1||^8.0

1.20.0PHP ^7.1|^8.0

1.22.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (153 commits)")[![ilamp](https://avatars.githubusercontent.com/u/12907744?v=4)](https://github.com/ilamp "ilamp (28 commits)")[![jmsche](https://avatars.githubusercontent.com/u/3929498?v=4)](https://github.com/jmsche "jmsche (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (18 commits)")[![iget-esoares](https://avatars.githubusercontent.com/u/9450290?v=4)](https://github.com/iget-esoares "iget-esoares (18 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (12 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (9 commits)")[![IlFalco1992](https://avatars.githubusercontent.com/u/25423312?v=4)](https://github.com/IlFalco1992 "IlFalco1992 (9 commits)")[![masbug](https://avatars.githubusercontent.com/u/11191264?v=4)](https://github.com/masbug "masbug (6 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (5 commits)")[![mynameisbogdan](https://avatars.githubusercontent.com/u/707714?v=4)](https://github.com/mynameisbogdan "mynameisbogdan (5 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (4 commits)")[![hajrovica](https://avatars.githubusercontent.com/u/934110?v=4)](https://github.com/hajrovica "hajrovica (3 commits)")[![srmklive](https://avatars.githubusercontent.com/u/839335?v=4)](https://github.com/srmklive "srmklive (3 commits)")[![iWader](https://avatars.githubusercontent.com/u/2007548?v=4)](https://github.com/iWader "iWader (3 commits)")[![cklingsporn](https://avatars.githubusercontent.com/u/19943672?v=4)](https://github.com/cklingsporn "cklingsporn (3 commits)")[![joaopatrocinio](https://avatars.githubusercontent.com/u/28317418?v=4)](https://github.com/joaopatrocinio "joaopatrocinio (3 commits)")[![mozammil](https://avatars.githubusercontent.com/u/1447522?v=4)](https://github.com/mozammil "mozammil (3 commits)")

---

Tags

apidropboxphpspatieapidropboxv2Dropbox-API

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-dropbox-api/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-dropbox-api/health.svg)](https://phpackages.com/packages/spatie-dropbox-api)
```

###  Alternatives

[spatie/flysystem-dropbox

Flysystem Adapter for the Dropbox v2 API

3644.6M68](/packages/spatie-flysystem-dropbox)[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[srmklive/flysystem-dropbox-v2

Flysystem Adapter for Dropbox API v2

20179.1k9](/packages/srmklive-flysystem-dropbox-v2)[spatie/packagist-api

Fetch package info from Packagist

1301.8M11](/packages/spatie-packagist-api)[spatie/laravel-tinker-tools

Use short class names in an Artisan tinker session

13850.2k](/packages/spatie-laravel-tinker-tools)

PHPackages © 2026

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