Skip to main content

Uppy 4.0 is here: TypeScript rewrite, Google Photos, React hooks, and much more.

Instagram

The @uppy/instagram plugin lets users import files from their Instagram account.

tip

Try out the live example or take it for a spin in StackBlitz.

When should I use this?

When you want to let users import files from their Instagram account.

A Companion instance is required for the Instagram plugin to work. Companion handles authentication with Instagram, downloads the files, and uploads them to the destination. This saves the user bandwidth, especially helpful if they are on a mobile connection.

You can self-host Companion or get a hosted version with any Transloadit plan.

npm install @uppy/instagram

Use

Using Instagram requires setup in both Uppy and Companion.

Use in Uppy

import Uppy from '@uppy/core';
import Dashboard from '@uppy/dashboard';
import Instagram from '@uppy/instagram';

import '@uppy/core/dist/style.min.css';
import '@uppy/dashboard/dist/style.min.css';

new Uppy()
.use(Dashboard, { inline: true, target: '#dashboard' })
.use(Instagram, { companionUrl: 'https://your-companion.com' });

Use with Transloadit

import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';
import Instagram from '@uppy/instagram';

uppy.use(Instagram, {
companionUrl: COMPANION_URL,
companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
});

You may also hit rate limits, because the OAuth application is shared between everyone using Transloadit.

To solve that, you can use your own OAuth keys with Transloadit’s hosted Companion servers by using Transloadit Template Credentials. Create a Template Credential on the Transloadit site. Select “Companion OAuth” for the service, and enter the key and secret for the provider you want to use. Then you can pass the name of the new credentials to that provider:

import { COMPANION_URL, COMPANION_ALLOWED_HOSTS } from '@uppy/transloadit';
import Instagram from '@uppy/instagram';

uppy.use(Instagram, {
companionUrl: COMPANION_URL,
companionAllowedHosts: COMPANION_ALLOWED_HOSTS,
companionKeysParams: {
key: 'YOUR_TRANSLOADIT_API_KEY',
credentialsName: 'my_companion_dropbox_creds',
},
});

Use in Companion

To sign up for API keys, go to the Instagram Platform from Meta.

Create a project for your app if you don’t have one yet.

The app page has a "Redirect URIs" field. Here, add:

https://$YOUR_COMPANION_HOST_NAME/instagram/redirect

If you are using Transloadit hosted Companion:

https://api2.transloadit.com/companion/instagram/redirect

Meta will give you an OAuth client ID and client secret.

Configure the Instagram key and secret in Companion. With the standalone Companion server, specify environment variables:

export COMPANION_INSTAGRAM_KEY="Instagram OAuth client ID"
export COMPANION_INSTAGRAM_SECRET="Instagram OAuth client secret"

When using the Companion Node.js API, configure these options:

companion.app({
providerOptions: {
instagram: {
key: 'Instagram OAuth client ID',
secret: 'Instagram OAuth client secret',
},
},
});

Development

Among Uppy-supported providers, Instagram is the only provider at the time of writing that requires https even in dev mode. So, to test your integration in development, you need to use some reverse proxy. The easiest way to do it is to use https://redirectmeto.com.

In your .env, set:

COMPANION_DOMAIN="redirectmeto.com/http://localhost:3020"
COMPANION_PROTOCOL="https"

On https://developers.facebook.com/apps/.../instagram-basic-display/basic-display page, in the “Valid OAuth Redirect URIs” field, add https://redirectmeto.com/http://localhost:3020/instagram/redirect.

API

Options

id

A unique identifier for this plugin (string, default: 'Instagram').

title

Title / name shown in the UI, such as Dashboard tabs (string, default: 'Instagram').

target

DOM element, CSS selector, or plugin to place the drag and drop area into (string, Element, Function, or UIPlugin, default: Dashboard).

companionUrl

URL to a Companion instance (string, default: null).

companionHeaders

Custom headers that should be sent along to Companion on every request (Object, default: {}).

companionAllowedHosts

The valid and authorised URL(s) from which OAuth responses should be accepted (string or RegExp or Array, default: companionUrl).

This value can be a string, a RegExp pattern, or an Array of both. This is useful when you have your Companion running on several hosts. Otherwise, the default value should do fine.

companionCookiesRule

This option correlates to the RequestCredentials value (string, default: 'same-origin').

This tells the plugin whether to send cookies to Companion.

locale

export default {
strings: {
pluginNameInstagram: 'Instagram',
},
};