In this guide we'll cover how to get an API token, make your first request, and where to go next to find all the information you need to take full advantage of our API.

Getting an API token

Before you can make requests to the Cake Slice API, you'll need an API token which can be acquired by contacting us. All requests to the Cake Slice API require authentication via API tokens in the Authorization header.

API tokens are considered sensitive and should not be shared externally or made public. They link the API calls you make to your organization and are used to meter usage for billing.

Making your first request

After grabbing an API token, you're ready to make your first call to the Cake Slice API. Below, you can see how to send a GET request to the test endpoint, which simply returns a 200 response code and empty payload if successful.

Example request

const headers  = { "Authorization": `Bearer ${token}` }
const response = await fetch("https://cakeslice.com/api/v1/test", { headers })

await response.json()

File Mover example

Alright, let's see an example of a real request. The following shows how to transfer an image from a given URL to an S3 bucket. Substitute in your own API token and S3 bucket_name and give it a try. Or, check out the full File Mover specification to see how to tweak it to your needs.

File Mover request

const response = await fetch(
    method: "POST",
    headers: {
      "Authorization": `Bearer ${token}`,
      "Content-Type": "application/json"
    body: JSON.stringify({
      source: {
        type: "url",
        url:  "https://www.nasa.gov/sites/default/files/thumbnails/image/curiosity_selfie.jpg",
      destination: {
        type:        "s3",
        bucket_name: "example_bucket",
        file_name:   "curiosity_selfie.jpg"

await response.json()

What's next?

Great, you're now set up with an API token and have made your first request. Here are a few links that might be handy as you venture further into the Cake Slice API: