JavaScript API Reference

  • This is for the version 3.x of the widget. If you're looking for the widget v2 docs, check here
  • Here’s how you migrate from v2 to v3.

Our JavaScript API is an extensive set of tools allowing you to adjust the widget behavior and implement advanced worfkflows like uploading files from URL, moderating uploaded content, and playing with the widget appearance. You can use it with or without the widget, as standalone components.

It is important to note that as stated in the Widget Configuration section, widget options can be set in three ways.

  • Globally, on page load.
  • Locally, when a new widget is created.
  • By passing the settings object.

JavaScript global variables are put in your <script> tag,

  UPLOADCARE_PUBLIC_KEY = 'demopublickey';

Local options are set in the <input> element as data attributes,

<input type="hidden" role="uploadcare-uploader"

You can also pass most of the widget options as an argument holding the settings object to the methods listed in this JavaScript API reference. For instance,

uploadcare.openDialog(null, {
  publicKey: 'demopublickey',
  imagesOnly: true,
  crop: '300x200'