Generate PPTX presentations with SlidePack
Tags: powerpoint, tutorial, productivity, automation
Published: 2023-09-04 04:09:08

[SlidePack](https://slidepack.io/) is a Web API we developed that lets you generate PowerPoint presentations using template PPTX files and JSON data. A typical use case is when you need to create weekly or monthly reports in PowerPoint that are basically the same every time, just with different data inserted.

![SlidePack screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5jnappkxv0eic4ji7ep.png)

In January 2022 we began providing a free plan so that anyone can experiment with SlidePack. Here's a quick tutorial to help you take it for a test drive.

## What is SlidePack?

In short, it's a templating engine that outputs PPTX files. It's provided as a Web API with [free and paid plans](https://slidepack.io/en/pricing).

Upload a zip file containing
* A PPTX file with `{placeholder}`s
* JSON data
* Images and videos you want to embed

and you get a rendered PPTX as output.

The free plan lets you render 50 slides per month. Your first month also comes with 500 free slides so you can experiment with different template PPTX designs.

## Creating your first template PPTX and JSON

* [Official Docs](https://docs.slidepack.io/en)
* [Example templates](https://docs.slidepack.io/en/examples)

Template syntax is similar to HTML templating engines you may be familiar with. Place `{text in curly braces}` in your PPTX like so:

![Basic template with placeholders](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbnzs4i9n4dmhfboefqi.png)

and prepare your data.json like so:

```jsonc
{
  "slides": [
    {
      "template": 1,
      "text1": "Text boxes can be placed anywhere in a slide.",
      "text2": "Fonts and styles from the template are preserved.",
      "text3": "Text box properties like auto-sizing are also preserved.",
      "text4": "You can",
      "text5": "replace",
      "text6": "text in",
      "text7": "tables."
    }
  ]
}
```

to get this output:

![Basic output slide](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3wkoj2140vv6mr1iidq.png)

There are different syntaxes for things like variable table rows with arrays, manipulating charts, embedding images and videos, and overwriting existing styles. Your template can of course contain multiple slides, and your output can repeat any of those slides any number of times.

For a full list of features and how to use them, please refer to our [API Docs](https://docs.slidepack.io/en).

## Test driving the API on the Web Console

You can try out the SlidePack API without writing client code by using the [Web Console](https://slidepack.io/app).

You'll need to sign up for an account if you haven't yet.

![Screenshot of web console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jls3atxts25shn3e9n6h.png)

After logging in,

1. Go to Sessions and click **Create New Session**.
2. Click **Upload Zip** on your newly created session.
3. Select your zip and upload. [(Grab a sample zip here)](https://docs.slidepack.io/en/examples)
4. Click **Upload Zip and Render**.
5. If your render is successful, you'll be taken back to the Sessions page where you can download the output file.

## Using the API

From here on we'll guide you through how to render a PPTX programmatically through the API.

1. [Create your API token](#create-api-token)
2. [Create a Session](#create-session)
3. [Upload your zip file](#upload-zip)
4. [Render and download output file](#render)

### Create your API token <a name="create-api-token"></a>

Authentication is done with a Bearer token in the HTTP header. Click **Create New API Token** in the Dashboard. to get yours. Copy and paste this token somewhere safe, and make sure you don't share it with anyone.

### Create a Session <a name="create-session"></a>

The first thing to do is create a rendering Session. We'll refer to the created Session UUID when we upload, render, and download files for this particular rendering run.

Issue a POST request like so:

```shell
curl -X "POST" "https://slidepack.io/sessions" \
     -H 'Authorization: Bearer {api_token}'
```

to get a response like:

```jsonc
{
  "session": {
    "uuid": "f0155f9f-d3f3-4fa9-9f8d-70f8fd2f9c36",
    "is_rendered": null,
    "message": null,
    "created_at": "2020-08-13T13:14:32.000000Z",
    "updated_at": "2020-08-13T13:14:32.000000Z"
  },
  "upload": {
    "action": "https://slidepack-api.s3.ap-northeast-1.amazonaws.com",
    "method": "POST",
    "enctype": "multipart/form-data",
    "params": {
      "acl": "private",
      "key": "sessions/zip/f0155f9f-d3f3-4fa9-9f8d-70f8fd2f9c36.zip",
      "Content-Type": "application/zip",
      "X-Amz-Security-Token": "***",
      "X-Amz-Credential": "***",
      "X-Amz-Algorithm": "AWS4-HMAC-SHA256",
      "X-Amz-Date": "20200813T131432Z",
      "Policy": "***",
      "X-Amz-Signature": "***"
    }
  }
}
```

`session` contains general info about this session along with its UUID. `upload` contains parameters needed for the upload step.

### Upload your zip file <a name="upload-zip"></a>

You'll be uploading your input zip file directly to SlidePack's S3 bucket using multipart/form-data.

A minimum input zip needs to contain:
* **template.pptx** - A PPTX file with placeholders
* **data.json** - Data to populate the template with

You can browse [our examples](https://docs.slidepack.io/en/examples) to get started.

All the information you need for this step is provided in the `upload` field of the session data received in the previous step:

* `upload.action` is the URL you'll be POSTing to
* `upload.params` is the form data to POST along with your file

We just need to add the actual file:

```shell
curl -X "POST" "https://slidepack-api.s3.ap-northeast-1.amazonaws.com/" \
     -F "acl=private" \
     -F "key=sessions/zip/{uuid}.zip" \
     -F "Content-Type=application/zip" \
     -F "X-Amz-Security-Token=***" \
     -F "X-Amz-Credential=***" \
     -F "X-Amz-Algorithm=AWS4-HMAC-SHA256" \
     -F "X-Amz-Date=***" \
     -F "Policy=***" \
     -F "X-Amz-Signature=***" \
     -F "file=@/path/to/your/data.zip"
```

You'll get a `204 No Content` if your upload is successful.

### Render and download output file <a name="render"></a>

Once uploading is done, we tell SlidePack to execute the render.

We do this by POSTing to `https://slidepack.io/sessions/{uuid}/render`, where `uuid` is `session.uuid` received in the session info.

```shell
curl -X "POST" "https://slidepack.io/sessions/{uuid}/render" \
     -H 'Authorization: Bearer {api_token}'
```

You'll get a response like this:

```jsonc
{
  "session": {
    "uuid": "f0155f9f-d3f3-4fa9-9f8d-70f8fd2f9c36",
    "is_rendered": true,
    "message": "Render succeeded.",
    "created_at": "2020-08-13T13:14:32.000000Z",
    "updated_at": "2020-08-13T13:17:43.000000Z"
  },
  "download_url": "https://slidepack-api.s3.ap-northeast-1.amazonaws.com/..."
}
```

Now all you need to do is get the output file from the `download_url`:

```shell
curl "https://slidepack-api.s3.ap-northeast-1.amazonaws.com/..." -o output.pptx
```

(Or, you can visit that URL in your browser.)

## Feedback welcome!

That's all for a quick run through the basics of SlidePack. Let us know in the comments if you get stuck or have any questions.

We're not a well known service, but we've been serving non-trivial business uses for several years now.

We are constantly adding and refining features too. Any feedback/feature requests are welcome!

Contact form:  https://slidepack.io/en/contact
Our rep Satoshi Kita on twitter: https://twitter.com/kitar