Skip to main content
The Amazon S3 Connector API lets an unattended integration deliver the rows of a Narrative dataset as files into an S3 bucket you own. Narrative delivers each new batch as it lands, and can also deliver the batches from up to 30 days before you connect the dataset. A person signs in once to create an API key and once to set up the bucket, and the integration works from the API key after that. Complete the prerequisites and set up API access on this page before you follow the guide.

Choose a guide

File delivery

Create a dataset, upload rows, connect it to your bucket, and keep delivering as new rows arrive.

Prerequisites

API key

Create the key under Settings → API Keys with read and write on datasets and connections, write on uploads, and read on installations, apps, and app_profiles. See API Keys for the procedure and the Permissions Reference for what each resource covers. Create it from a shared team account rather than a personal login, so the integration keeps working when someone changes roles.

S3 Connector installed

The S3 Connector is app 7. Find your installation of it:
Record the installation ID. If no record has "app_id": 7, install the S3 Connector from the Narrative Marketplace.

A profile for your bucket

A connector profile names one S3 bucket and the file format Narrative writes into it. You set up a profile once per bucket, in the Narrative UI, with access to the bucket’s settings in AWS:
1

Open the connector

In Narrative, go to Installed Apps, select S3 Connector, and choose Add profile.
2

Name the profile and bucket

Enter a profile name, a description, and the name of the bucket Narrative delivers to.
3

Apply the bucket policy in AWS

Copy the bucket policy the wizard shows, and apply it in the AWS console under the bucket’s Permissions → Bucket policy, or with aws s3api put-bucket-policy. The policy lets Narrative’s delivery role write, list, and delete objects in the bucket. You can also fetch the policy over the API, as shown in Get the bucket policy.
4

Tag the bucket in AWS

Add the tag the wizard shows to the bucket, under Properties → Tags. The tag is named NARRATIVE_S3_CONNECTOR_ID, and its value ties the bucket to your company.
5

Test access

Run the wizard’s access test. Narrative writes, lists, and deletes a test object in the bucket and reads the tag.
6

Choose the file format and save

Choose CSV, TSV, JSON, or Parquet. For CSV or TSV, also set the delimiter, quote, and escape characters, and whether to include a header row. Choose Save and finish, and the profile is enabled and ready for connections.
Every request in the guide then uses the profile ID. List your profiles shows how to look it up.

Set up API access

The guide talks to two hosts, and each takes its own credential:

Get an installation token

The S3 connector authenticates requests with an installation token, which you get by exchanging your API key. Use the installation ID from S3 Connector installed:
Store access_token as $INSTALLATION_TOKEN. It lasts about three hours, so request a new one at the start of each run of your integration. Confirm that both hosts answer:
Send the API key to api.narrative.io and the installation token to aws-s3.narrativeconnectors.com.
API keys contain characters that shells mangle. Read the key from a file or an environment variable rather than pasting it inline.

List your profiles

The Narrative API lists the profiles under your installation, with the status of each:
The S3 connector returns the same profiles along with the bucket and file format of each:
To read one profile, call GET /profiles/{profile_id} on the connector, which returns the same shape. Use a profile whose status is enabled, and record its id.

Get the bucket policy

The connector generates the bucket policy for a bucket name:
Apply the policy exactly as the connector returns it, with Narrative’s delivery role in Principal.

Read the delivery settings schema

Each connection carries delivery settings for the connector’s delivery interface. The schema lists every setting with its type and description:
The connector serves the same schema at https://aws-s3.narrativeconnectors.com/interfaces/delivery, with no credential. What the connection does explains each field.

What the connection does

A connection’s quick_settings set where and how the connection writes files. The S3 Connector has one interface, delivery. The file format, compression, and CSV options come from the profile.

Existing and new rows

A connection delivers every snapshot written to the dataset after the connection is created. The historical_data_enabled quick setting decides whether the connection also delivers data that was already in the dataset when you created it:
  • With historical_data_enabled set to true, the connection first delivers data already in the dataset, then keeps delivering new snapshots as they land.
  • With historical_data_enabled set to false, the connection delivers only snapshots written after it was created.
How far back the first delivery reaches depends on the connector, and each connector’s guide states it. For the S3 Connector, historical_data_enabled delivers the dataset’s snapshots from the last historical_period_seconds before the connection was created. After that, each new snapshot is delivered as it lands. Each source file in a snapshot becomes one object in the bucket, under <bucket_prefix>/snapshotId=<snapshot ID>/. A delivery only adds objects. When you overwrite the dataset, the new snapshot lands in a new folder and the earlier folders stay in the bucket.

Amazon S3 Connector

Supported file formats and delivery options

Connector Interfaces

Why a dataset connects to an interface rather than a connector

API Keys

Create and rotate keys for programmatic access