In this article
Table of Contents | ||||
---|---|---|---|---|
|
Overview
This use case demonstrates how you can use SnapLogic Data Science to configure SnapLogic Pipelines as REST APIs to receive requests from external applications. Currently, we support the following two types of REST APIs that are called tasks in SnapLogic:
...
Triggered Task | Ultra Task | |
---|---|---|
Objective | Trigger the API using a URL | Real-time API that has a very low response time |
Latency | High | Very low |
Resource Consumption | Start a new Pipeline execution for each request | The Pipeline is active all the time |
Number of Documents | Any number of input/output documents | 1 input document for 1 output document |
This document explains how you can use the SnapLogic platform to run the Pipelines as APIs and is structured as follows:
- Data Science API Pipeline: Describes the Pipeline you must build to run as an API.
- Request format: Describes the request format to send API requests.
- Configuring and managing Ultra Tasks: Describes how to schedule and manage Ultra Tasks.
- Testing Ultra Tasks: Describes how to test the Ultra Tasks.
...
- In the Designer page, click the triangle on the right to expand the Designer toolbar. Then, click the Calendar icon to open the Create Task dialog.
- Select Ultra in Run policy and remove the Bearer Token to remove authentication.
We recommend that you use a Snap to perform authentication inside the Pipeline. This can either be a Filter Snap that simply compares . To authenticate within the pipeline, send the static tokensnaplogic_ml_showcase
using the JSON Generator Snap through the REST Post Snap to send a request to the Ultra Task. - Use a Filter Snap in Data Science API Pipeline to compare your authentication details against a static token, a Snap that can connect to your session database, or a REST Post Snap, if you use external authentication service.as shown in the below screenshot. This step verifies the static token passed from the ultra task.
- Optional. Specify Instances. This is the number of API instances to be run in parallel across nodes in the Snaplex.
We recommend that you use at least two API instances to provide fault tolerance. You can find more information about Ultra Tasks here.
...
- Click Create in the Create Task dialog and click Show tasks in this project in Manager to go to the Manager page.
- Click the task name to edit the task settings.
- Click next to the task, and then click Details. The task detail popup appears, complete with the HTTP Endpoint URL.
- Click Details to see the task statistics. You can see that there are 7 API instances that have started so far.
However, only 2 API instances are running as shown in the following image from the Dashboard page. The API instance stops, and a new one is created if the Pipeline fails.
Testing Ultra Tasks
There are many tools that you can use to test your Ultra Tasks (APIs). However, if you would like to have a regression/automated test, we recommend that you build a Pipeline to do this, so you can schedule it to run on a daily/weekly basis.
Pipeline
Use the JSON Generator Snap to generate a sample request and use the REST Post Snap to send a request to the Ultra Task. You can download this Pipeline here.
...