In today's fast-paced business environment, data is the lifeblood of informed decision-making. The Fivetran REST API offers a powerful solution to automate and optimize your data pipeline, making it more efficient and adaptable than ever before. In this guide, we'll explore the benefits of Fivetran's REST API and demonstrate how it can revolutionize your data management.
Chapter 1: The power of Fivetran REST API
Imagine you're tasked with centralizing data from multiple departments, each with its own database. Setting up connectors manually for a few databases is straightforward, but what about when you have hundreds or even thousands of them? Fivetran's REST API makes it a breeze to automate the deployment, configuration and management of connectors, saving you time and effort.
Use cases
Let's dive into some common scenarios where the Fivetran REST API shines:
- Pipeline management: Create, manage and control access to pipelines programmatically.
- Data transformation: Orchestrate your data model and transformation layer effortlessly.
- Data governance: Ensure data quality and security with ease.
- Resource management: Handle every Fivetran resource seamlessly.
Chapter 2: A real-world scenario
Picture this: You work for an organization aiming to centralize data across various departments within a data warehouse. Each department has its dedicated database with similar structures. While configuring a single database is manageable through Fivetran's user interface, anticipating the need for adding more departments or switching data warehouses requires a more scalable approach.
You decide to automate resource deployment, management and pipeline execution, envisioning a seamless end-to-end process that encompasses the following steps:
- Create a new destination.
- Establish a webhook to monitor events.
- Add new connectors to the destination.
- Configure connector schemas.
- Execute a synchronization on the connectors.
- Execute a transformation to model the data.
Chapter 3: Getting started
Before diving in, familiarize yourself with these essential resources:
- API docs & FAQ: Your go-to references for API knowledge.
- API framework code samples: Code snippets for easy integration.
- API reference: Detailed API documentation.
- Webhook example: Learn how to accept Fivetran webhooks easily for development and testing
Choose your tool
While Fivetran's API framework is implemented in Python, you can use the REST API with various tools like Postman, Airflow or Terraform. However, for our purposes, we will focus on Python with the API framework.
Key components
The API framework has several elements you should familiarize yourself with:
- config.json: where your credentials, secrets and API payloads are stored
- Authentication: where you access the Fivetran API using API keys.
- the "atlas" function: how you delegate calls of the Fivetran API
- examples: sample scripts of common Fivetran API tasks
Authentication essentials
Every journey with the Fivetran REST API regardless of your choice of tool begins with authentication using an API Key and API Secret Key. These keys link actions to user permissions and can be generated in the Fivetran dashboard’s API Keys section.
Chapter 4: Taking action
The start of any Fivetran REST API script will begin with authentication using the API Keys you generated from the Fivetran UI. Once you’ve passed the keys into the authentication function, we can begin making the API calls to achieve our vision.
Destination and groups
Before we create our destination, let's start by setting up a Group using the Group Management API. Think of this Group as an organizational magic box, neatly containing destinations, connectors, users, transformations, logs and webhooks in a highly organized manner. It's the key to streamlining your data operations.
Now, when it comes to configuring your Fivetran destination, you're in for a treat! We've made it a breeze with our Destination Management API. Each destination comes with its unique setup parameters, all clearly explained in our Destination Config documentation for your convenience.
The best part? Once your API call works its magic, you'll spot your shiny new destination in the Destinations tab of your Fivetran Dashboard, proudly displaying its "Connected" status.
![](png/661050371fc218f2c1b9837c_rhyjvbov3u9v21bndr3jjs8wssawnhpp-78tvgmlzp0aryx1zywtwwr4ny4zzljf1vi7faovj4stnzz5bwg2bcjifvjbqkxd4knfw5c3_en43mv5kdzeayqgg1w0r2qu0isjdyncrvr7wmh9u7rguoy.png)
But wait, there's more. Clicking on the destination opens the door to a world of configuration possibilities, allowing you to fine-tune the setup.
![](png/66105040e619f0a38cb4ff38_tognmpvsla48zbc4dbnsabmn1tjmcqn6fiu6g4brkcw6klxztxzjhvelmrwsz98ejhubd9tg8beydrsipdhbrnalzzgz8jx6qb7xbyjgoyhldc_r1rp9b1vjil7pcatvq7jwbqlexvkzeqvzttaeuuy.png)
And here's the kicker: If you've already set up a group and destination, no worries. You can skip this step and dive straight into provisioning webhooks, bulk creating connectors or executing transformations to supercharge your data journey. The power is in your hands.
Webhook magic
Webhooks play a crucial role in capturing events from automation scripts, allowing external tools to orchestrate actions based on these events. This allows data operations to become agile, real-time and effortlessly responsive. The next step in a data pipeline can run without delay, or errors encountered can be swiftly addressed.
The Webhook Management API supports several event types which can be specified in the Create Webhook API call. Example {sync_start, sync_end, dbt_run_start, dbt_run_succeeded}
Chapter 5: Connector creation
Enter the realm of Connector Management API, a close cousin to our Destination Management API. Much like destinations, every connector comes with its own unique set of parameters during setup, and we've got you covered with easy-to-follow JSON payload configurations for all of our connectors. This payload encompasses crucial details, including connection specifics, network settings and storage configurations. Plus, don't forget about TLS Certificates and setup tests — they're a breeze to validate and execute through the Connector Management API.
![](png/66105050482552f0f0291740_pxeijh2oczi0rlqxwvspg9-bx5xbpfq9ymv48gu_7bzv03eyxjjioy8xvtxhwhmvwawdycr5xfrzfpnbubzpdekrqn8jedi0libinw68scwlstkph9uof4l7bhqx1-lfsgrvjafaieaxsoovmdr35s0.png)
Now, brace yourself for the magic of Python scripting, offering the unmatched power of scalability. With it, you can effortlessly iterate over unlimited connector configurations, creating them in bulk without breaking a sweat.
Here's the beauty of it all: the config.json file. You define all your parameters in it, and your script does the rest. It reads in the config, hands it over to the atlas function and seamlessly loops through all your defined parameters, deploying a fleet of resources at your command.
Schema customization
Now, let's talk about flexibility — especially for database connectors. Imagine having the power to fine-tune your connectors by adjusting schemas, tables and columns on the fly, ensuring they align seamlessly with your evolving requirements. It's like having a magic wand for your data.
The Modify Connector Schema Config API is at your beck and call, ready to be invoked whenever you need to tweak what datasets are synchronized. In the ever-changing world of data and business requirements, this type of API interaction becomes your secret weapon, allowing you to adapt swiftly and propagate changes across all your connectors.
Here's the game-changer: Embrace the config.json, your ultimate control center. It's the place where all your changes come together, reducing the need for extensive code changes as your data and business requirements change. Plus, it makes looping over all your connectors a walk in the park. Say goodbye to complexity and hello to agility.
Chapter 6: Synchronization and transformation
When it comes to the exciting world of data syncing, you're spoiled for choice. Picture this: you can let Fivetran work its magic by handling the scheduling automatically. By default, every connector we create is set to sync data every six hours. But here's the beauty of it: You're the boss, and you can tailor it to suit your business rhythm. Need it faster or slower? No problem, we've got you covered.
Now, for those of you who desire even more control and tighter integrations, we've got a gem in our toolkit called the connector sync endpoint in our connector management API . With it, you become the maestro, dictating precisely when that connector sync takes the stage. This means your data pipeline seamlessly slips into your existing processes, making transitions from one job to another a breeze. Syncing data has never been this dynamic.
Data transformation
When it comes to scheduling and executing transformations, you're in the driver's seat, with several exciting options to choose from. The path you take depends entirely on your unique business needs:
- Integrated scheduling: Imagine transformations synchronized seamlessly with your connector syncs, triggering immediately upon the successful completion of one or more connector syncs.
- Partially integrated scheduling: Here, transformations dance to the connector syncs' rhythm but also have their own moves, running at predefined intervals (e.g., every hour).
- Independent Scheduling: For those who crave autonomy, transformations follow their own beat, running on a schedule you define.
These schedules are as flexible as they come, with the power to configure them right in the Fivetran Dashboard or programmatically through the transformations management API. But that's not all! We've got an ace up our sleeve – the run transformation endpoint. It gives you the ultimate control over when a transformation takes center stage, ensuring it fits perfectly into your data pipeline's choreography.
Chapter 8: Conclusion
This guide has showcased the power of only a small subset of the Fivetran REST API. You can take your automation further with other APIs not discussed here such as the metadata, team, role, user, certificate and log service management APIs. And while only briefly touched on, the entirety of your transformation setup can be done programmatically.
- Linking a dbt project
- Retrieving dbt project models
- Creating a transformation
- Modifying a transformation
In summary, we've outlined and touched on the key components of creating an automation script for a Fivetran data pipeline. This script streamlines the creation and management of Fivetran resources, captures critical events, and constructs reporting data models. It's a flexible solution that can adapt to your organization's evolving needs.
Whether you're scaling up or fine-tuning your data pipeline, the Fivetran REST API offers a single point of entry to reduce manual work and ensure your data pipeline scales with your organization.
Get your API key now. For further assistance and consultation, don't hesitate to reach out to a Fivetran expert. For users who want a more technical deep dive into the steps outlined above, check out our post in the Fivetran Community.