NAV Navbar
javascript php shell

Introduction

const Scape = require('scape-js');

let scape = new Scape('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
<?php

use Ideea\Scape;

Scape::boot('52372b13c197b319cf2985122cfe062a8a351141c28975b235f153079d81f8b04');

This is the documentation for Scape API. This API is used for uploading images, creating buckets, and managing images.

Buckets

Create Bucket

POST - /groups/{group_id}/buckets/create

scape.createBucket({
    name: 'my-unique-bucket-name',
    group_id: '09a35d4b-2432-419e-81a2-253538b1bbae'
}).then((newBucket) => {
  console.log(newBucket);
})
<?php

$bucket = $scape->createBucket([
  'name' => 'my-unique-bucket-name'
]);
curl 'https://scape.ideea.io/api/v1/groups/12420628-7d15-4a2b-91fb-af8e27c4943f/buckets/create' \
  -X POST \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json;' \
  --data-binary '{"name":"my-unique-bucket-name"}'

Response

{
  "id": "09a35d4b-2432-419e-81a2-253538b1bbae",
  "group_id": "12420628-7d15-4a2b-91fb-af8e27c4943f",
  "name": "my-unique-bucket-name",
}

To create a new bucket make a post request to /groups/{group_id}/buckets/create. This will craete the bucket with the provided data.

HTTP Endpoint

POST http://scape.ideea.io/api/v1/groups/{group_id}/buckets/create

Request Payload

Parameter Required Description
name true The bucket name. This must contain only lower-case letters and hyphens

Get Buckets

GET /groups/{group_id}/buckets

scape.getBuckets('12420628-7d15-4a2b-91fb-af8e27c4943f').then((buckets) => {
  buckets.map(bucket => {
      console.log(bucket)
  })
})
<?php

$buckets = $scape->getBuckets('12420628-7d15-4a2b-91fb-af8e27c4943f');

foreach($buckets as $bucket){
  echo $bucket->id;       // "09a35d4b-2432-419e-81a2-253538b1bbae"
  echo $bucket->group_id; // "12420628-7d15-4a2b-91fb-af8e27c4943f"
  echo $bucket->name;     // "my-unique-bucket-name"
}
curl 'https://scape.ideea.io/api/v1/groups/12420628-7d15-4a2b-91fb-af8e27c4943f/buckets' \
  -X GET \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response

[
  {
    "id": "09a35d4b-2432-419e-81a2-253538b1bbae",
    "group_id": "12420628-7d15-4a2b-91fb-af8e27c4943f",
    "name": "my-unique-bucket-name",
  },
  ...
]

To get an array of all of the buckets owned by a group. Use the .getBuckets(GroupID) method.

HTTP Endpoint

GET http://scape.ideea.io/api/v1/groups/{group_id}/buckets

Get Single Bucket

GET - /buckets/{bucket_id}

scape.getBucket('09a35d4b-2432-419e-81a2-253538b1bbae').then((bucket) => {
  console.log(bucket)
})
<?php

$bucket = $scape->getBucket('09a35d4b-2432-419e-81a2-253538b1bbae');

echo $bucket->id; // "09a35d4b-2432-419e-81a2-253538b1bbae"
echo $bucket->group_id; // "12420628-7d15-4a2b-91fb-af8e27c4943f"
curl 'https://scape.ideea.io/api/v1/buckets/09a35d4b-2432-419e-81a2-253538b1bbae' \
  -X GET \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response

{
  "id": "09a35d4b-2432-419e-81a2-253538b1bbae",
  "group_id": "12420628-7d15-4a2b-91fb-af8e27c4943f",
  "name": "my-unique-bucket-name",
},

To get a single bucket use .getBucket(BucketID)

HTTP Endpoint

GET http://scape.ideea.io/api/v1/buckets/{bucket_id}

Delete A Bucket

DELETE - /bucket/{bucket_id}/delete

scape.deleteBucket('09a35d4b-2432-419e-81a2-253538b1bbae').then((bucket) => {
    console.log(bucket.id);
})
<?php

$deletedBucket = $scape->deleteBucket('09a35d4b-2432-419e-81a2-253538b1bbae');

echo $deletedBucket->id;
curl 'https://scape.ideea.io/api/v1/buckets/09a35d4b-2432-419e-81a2-253538b1bbae/delete' \
  -X DELETE \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response

{
  "id": "709ee024-bf38-4a08-a4f6-1f20178ef1ba",
}

To delete a bucket make DELETE request to /buckets/{bucket_id}/delete.

HTTP Endpoint

POST http://scape.ideea.io/api/v1/buckets/{bucket_id}/delete

Images

Upload Image

POST - https://scape-upload.ideea.io/scape

const Scape = require('scape-js')
const fs = require('fs')

var scape = new Scape('6B1AEBDF03B69CC1FB59BD33162410979213A8FF4CF59CAE54E3436D5535E318')

var image = fs.readFileSync('./image.png')

scape.upload(image, {
    bucket_id: '09a35d4b-2432-419e-81a2-253538b1bbae'
}).then(function (image) {
    console.log(image)
})
<?php

$image = $scape->upload('/path/to/my/image.jpg', "09a35d4b-2432-419e-81a2-253538b1bbae");

echo $image->url; // "https://cdn.scape.ideea.io/00595909-34d0-4de4-a4fe-402a0c2285ba.jpg"
curl https://scape-upload.ideea.io/scape \
  -X POST \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F image=@/path/to/image.jpg \
  -F bucket_id=09a35d4b-2432-419e-81a2-253538b1bbae

Response

{
  "id": "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1",
  "group_id": "2f8fdea3-b875-4926-90c8-5a1b11b818c8",
  "bucket_id": "09a35d4b-2432-419e-81a2-253538b1bbae",
  "url": "http://cdn.scape.ideea.io/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1.jpg",
  "file_size": 46890,
  "created_at": "2019-03-02 20:33:13"
}

To create a new bucket make a post request to /groups/{group_id}/buckets/create. This will craete the bucket with the provided data.

HTTP Endpoint

POST https://scape-upload.ideea.io/scape

Request Payload

Parameter Required Description
image true The image
bucket true The bucket that this image will be stored in.

Get Images

GET /buckets/{bucket_id}/images

scape.getImages('09a35d4b-2432-419e-81a2-253538b1bbae').then((images) => {
  images.map(image => {
      console.log(image)
  })
})
<?php

$images = $scape->getImages('09a35d4b-2432-419e-81a2-253538b1bbae');

foreach($images as $image){
  echo $image->id;          // "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1"
  echo $image->group_id;    // "2f8fdea3-b875-4926-90c8-5a1b11b818c8"
  echo $image->bucket_id;   // "09a35d4b-2432-419e-81a2-253538b1bbae"
  echo $image->url;         // "http://cdn.scape.ideea.io/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1.jpg"
}
curl 'https://scape.ideea.io/api/v1/buckets/09a35d4b-2432-419e-81a2-253538b1bbae/images' \
  -X GET \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response

[
  {
    "id": "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1",
    "group_id": "2f8fdea3-b875-4926-90c8-5a1b11b818c8",
    "bucket_id": "09a35d4b-2432-419e-81a2-253538b1bbae",
    "url": "http://cdn.scape.ideea.io/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1.jpg",
    "file_size": 46890,
    "created_at": "2019-03-02 20:33:13"
  }
  ...
]

To get an array of all of the image in a bucket, use the .getImages(BucketID).

To paginate the results use .getImages(BucketID, {page: 2})

HTTP Endpoint

GET http://scape.ideea.io/api/v1/buckets/{bucket_id}/images

Get Single Image

GET - /buckets/{bucket_id}/image/{image_id}

scape.getImage('09a35d4b-2432-419e-81a2-253538b1bbae', '0738a0bb-c36c-4c2e-af6e-756d6d0c41d1').then((bucket) => {
  console.log(bucket)
})
<?php

$image = $scape->getImage('09a35d4b-2432-419e-81a2-253538b1bbae', '0738a0bb-c36c-4c2e-af6e-756d6d0c41d1');

echo $image->id; // "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1"
echo $image->url; // "http://cdn.scape.ideea.io/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1.jpg"
curl 'https://scape.ideea.io/api/v1/buckets/09a35d4b-2432-419e-81a2-253538b1bbae/images/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1' \
  -X GET \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response

{
  "id": "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1",
  "group_id": "2f8fdea3-b875-4926-90c8-5a1b11b818c8",
  "bucket_id": "09a35d4b-2432-419e-81a2-253538b1bbae",
  "url": "http://cdn.scape.ideea.io/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1.jpg",
  "file_size": 46890,
  "created_at": "2019-03-02 20:33:13"
}

To get a single image use .getImage(BucketID, ImageID)

HTTP Endpoint

GET http://scape.ideea.io/api/v1/buckets/{bucket_id}/images/{image_id}

Delete an Image

DELETE - /buckets/{bucket_id}/images/{image_id}/delete

scape.deleteImage('09a35d4b-2432-419e-81a2-253538b1bbae', '0738a0bb-c36c-4c2e-af6e-756d6d0c41d1').then((deletedImage) => {
  console.log(deletedImage.id)
})
<?php

$deletedImage = $scape->deleteImage('09a35d4b-2432-419e-81a2-253538b1bbae', '0738a0bb-c36c-4c2e-af6e-756d6d0c41d1');

echo $deletedImage->id; // "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1"
curl 'https://scape.ideea.io/api/v1/buckets/09a35d4b-2432-419e-81a2-253538b1bbae/images/0738a0bb-c36c-4c2e-af6e-756d6d0c41d1/delete' \
  -X DELETE \
  -H 'Authorization: Bearer ACCESS_TOKEN'

Response

{
  "id": "0738a0bb-c36c-4c2e-af6e-756d6d0c41d1"
}

To delete an image use .deleteImage(BucketID, ImageID)

HTTP Endpoint

GET http://scape.ideea.io/api/v1/buckets/{bucket_id}/images/{image_id}/delete

Errors

The Ideea API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The kitten requested is hidden for administrators only.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access a kitten with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The kitten requested has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many kittens! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.