api assets - GetmeUK/hangar51 GitHub Wiki
The following list of API endpoints allow assets to be managed.
List assets for the current account.
- 
qA query string that will filter the list of assets returned. The*character can be used as a wildcard, e.g*.jpgfor find all files with the jpg extension.
- 
typeThe type of asset to return can befileorimage.
curl "http://hangar51.local/?api_key={api_key}&q={query}&type={asset_type}"
-
{
  "status": "success",
  "payload": {
    "assets": [
      {
        "created": "2016-03-27 14:20:01",
        "store_key": "file.bf6yfw.zip",
        "type": "file",
        "uid": "bf6yfw"
      }, {
        "created": "2016-03-27 14:27:44",
        "store_key": "image.lxfngl.jpg",
        "type": "image",
        "uid": "lxfngl"
      }
    ],
    "total_assets": 2t,
    "total_pages": 1
  }
}
Get the details of an asset.
- 
uidThe 6 digit asset unique Id.
curl "http://hangar51.local/get?api_key={api_key}&uid={uid}"
-
{
  "status": "success",
  "payload": {
    "created": "2016-03-27 14:27:44",
    "ext": "jpg",
    "meta": {
      "filename": "image.jpg",
      "image": {
        "mode": "RGB",
        "size": [
          720,
          960
        ]
      },
      "length": 130793
    },
    "modified": "2016-03-27 14:27:44",
    "name": "image",
    "store_key": "image.lxfngl.jpg",
    "type": "image",
    "uid": "lxfngl",
    "variations": []
  }
}
Download the asset.
- 
uidThe 6 digit asset unique Id.
curl "http://hangar51.local/download?api_key={api_key}&uid={uid}"
Upload an asset.
- 
assetThe file or image to store.
- 
nameA name for the asset (if not provided the file name will be used).
curl -F "[email protected]" "http://hangar51.local/upload?api_key={api_key}&name={name}"
-
{
  "status": "success",
  "payload": {
    "created": "2016-03-27 14:27:44",
    "ext": "jpg",
    "meta": {
      "filename": "image.jpg",
      "image": {
        "mode": "RGB",
        "size": [
          720,
          960
        ]
      },
      "length": 130793
    },
    "modified": "2016-03-27 14:27:44",
    "name": "image",
    "store_key": "image.lxfngl.jpg",
    "type": "image",
    "uid": "lxfngl",
    "variations": []
  }
}
Generate one of more image variations for an image asset.
- 
uidThe 6 digit asset unique Id.
- 
variationsA dictionary of variations to generate for the asset in JSON format.
- 
on_deliveryDetermines if the process should wait for the variation to be created or run the task in background and return straight away. The value should be'wait'(the default) or'peg_it'(it really doesn't matter what you send as an alternative to wait).
- 
webhookA URL to call (using GET) once the variation has been generated. Only applicable ifon_deliveryis not set to wait and the task will run in the background. The webhook URL will be called with the folloing attributes:- 
account_nameThe name of the Hangar51 account.
- 
assetThe unique Id of the asset.
- 
variationsDetails of the generated variations.
 
- 
curl -d 'api_key={api_key}&uid={uid}&variations={variations}' http://hangar51.local/generate-variations
-
{
  "status": "success",
  "payload": {
    "thumb": {
      "ext": "webp",
      "meta": {
        "image": {
          "mode": "RGB",
          "size": [
            100,
            133
          ]
        },
        "length": 3004
      },
      "name": "thumb",
      "store_key": "image.lxfngl.thumb.j1l.webp",
      "version": "j1l"
    }
  }
}
Set the expiry date for an asset, once an asset expires it will be removed (along with any variations in the case of images).
- 
expiresIf not specified the asset will be set to never expire, if specified the value must be set as Epoch time (number of seconds since 1 January 1970).
- 
uidThe 6 digit asset unique Id.
curl -d 'api_key={api_key}&uid={uid}' http://hangar51.local/set-expires
- 
{
  "status": "success"
}