REST API Examples
This section lists few examples of how to use the Fivetran Local Data Processing REST API.
Before proceeding with this section, it is recommended to read , and details for each REST API request is available in .
You can use to execute Local Data Processing REST API methods (GET, POST, PUT, PATCH, DELETE) from the command line. cURL is a command-line tool for getting or sending data including files using URL syntax.
Data (-d or --data) can be supplied directly on the command line or via a data file. For more information, see section .
Login
This is an example for logging into Local Data Processing using REST API. The user name myhubuser and password myhubuserpass supplied here is for the hub .
The access_token generated in the response for login must be used in all other REST API request headers for authentication.
Only v1 is supported for authentication request.
Request:
curl \
-X POST \
-d '{"username": "myhubuser", "password": "myhubuserpass"}' \
-H "Content-Type: application/json" \
http://localhost:4340/auth/v1/password
content_copyResponse:
{
"token_type": "bearer",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6pXVCJ9.eyJpc3MiOiJodHRwOi8vbWFsdGE6NTY5MDAiLCJzdWIiOiJW5l2w1bRxU",
"expires_in": 900
}%
content_copyCreate Location
Following is the format for creating a new location in Local Data Processing using REST request. For more information about this REST request, see (/hubs/{hub}/definition/locs) in Definition Interface.
It is mandatory to define location name (loc) and (props) for creating a location. Action definition (
actions) is optional.
'loc' : <ident> - parameter for defining name for the location
'props' : { - parameter for defining location properties that are required for location creation
prop<str> *: value<typeof_loc_prop>
}
'actions' ?: ( - parameter for defining action with parameters for the location
{
'type' : <ident>
'params' ?: {
param<str> *: val<scal>
}
}*
)
content_copyExamples for creating locations
- For authentication, the access_token received in the response must be supplied in the location creation request.
- A space is required before and after the word Bearer (
-H "Authorization: Bearer access_token).
In the following examples, click on the location propties to see its description and other valid values available for that specific property.
Oracle - The following example will create an Oracle location named mylocation.
LinuxWindowscurl \ -X POST \ -d '{"loc":"mylocation", "props": {"Class":"oracle", "Oracle_Home":"/oracle/1900", "Oracle_SID":"ORA1900", "Database_User":"mydb", "Database_Password":"mydbpassword", "Capture_Method":"DIRECT"}}' \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbWFsdGE6NTY5MDAiLCJzdWIiOiJodnIiLCJleHAiOjE2NDIxNjI3MTh9.Fd5x4uGzRimvj8Ykq867lXQTWuIQBVELzhvn3mfPv8U" \ -H "Content-Type: application/json" \ http://localhost:4340/api/latest/hubs/myhub/definition/locscontent_copyIf the location property is not defined, then this location can be used only as a target/integrate location.
SQL Server - The following example will create a SQL Server location named mylocation.
LinuxWindowscurl \ -X POST \ -d '{"loc":"mylocation", "props": {"Class": "sqlserver", "SqlServer_Server": "myserver", "Database_Name": "mydb", "Database_User": "mydbuser", "Database_Password": "mydbuserpassword", "Capture_Method": "DIRECT", "Supplemental_Logging": "CDCTAB_ARTICLE", "Log_Truncater": "CAP_JOB"}}' \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbWFsdGE6NTY5MDAiLCJzdWIiOiJodnIiLCJleHAiOjE2NDIxNjM0NTJ9.f6FYvAb7xh9DWtaJd_Y7-3vIeq9UIotFEoLutP5Qhgw" \ -H "Content-Type: application/json" \ http://localhost:4340/api/latest/hubs/myhub/definition/locscontent_copyIf the location property is not defined, then this location can be used only as a target/integrate location.
Snowflake - The following example will create a Snowflake location named mylocation.
LinuxWindowsWith staging:
curl \ -X POST \ -d '{"loc":"mylocation", "props": {"Class": "snowflake", "Database_Host": "myserver", "Database_Port": 443, "Snowflake_Role": "admin", "Snowflake_Warehouse": "mysnowflakewarehouse", "Database_Name": "mydb", "Database_Schema": "mysnowflakeschema", "Database_User": "mydbuser", "Database_Password": "mydbuserpassword", "Staging_Directory": "/mystagingdir", "File_Scheme": "s3s", "S3_Bucket": "mybucket", "AWS_Access_Key_Id": "TWENDUIOWNDH1Q", "AWS_Secret_Access_Key": "N5D98Ae0EssvnPaBXlCJiBmpyMpmiD"}}' \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbWFsdGE6NTY5MDAiLCJzdWIiOiJodnIiLCJleHAiOjE2NDIxNjU3MDN9.__QAHe15Mjz0YJGG3ZevgQkR0SO7cNIN0XRiZ9b6cfg" \ -H "Content-Type: application/json" \ http://localhost:4340/api/latest/hubs/myhub/definition/locscontent_copyWithout staging:
curl \ -X POST \ -d '{"loc":"mylocation", "props": {"Class": "snowflake", "Database_Host": "myserver", "Database_Port": 443, "Snowflake_Role": "admin", "Snowflake_Warehouse": "mysnowflakewarehouse", "Database_Name": "mydb", "Database_Schema": "mysnowflakeschema", "Database_User": "mydbuser", "Database_Password": "mydbuserpassword"}}' \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbWFsdGE6NTY5MDAiLCJzdWIiOiJodnIiLCJleHAiOjE2NDIxNjU3MDN9.__QAHe15Mjz0YJGG3ZevgQkR0SO7cNIN0XRiZ9b6cfg" \ -H "Content-Type: application/json" \ http://localhost:4340/api/latest/hubs/myhub/definition/locscontent_copySybase - The following example will create a Sybase location named mylocation.
LinuxWindowscurl \ -X POST \ -d '{"loc":"mylocation", "props": {"Class": "sybase", "Sybase": "/sybaseinstall_loc", "Sybase_CT_Library": "/sybase_ct_lib", "Database_Host": "mysybasenode", "Database_Port": 5000, "Database_Name": "mydb", "Sybase_Authentication_Method": "USER_PASS", "Database_User": "mydbuser", "Database_Password": "mydbuserpassword", "Capture_Method": "DIRECT", "Archive_Log_Path": "/logs",}}' \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbWFsdGE6NTY5MDAiLCJzdWIiOiJodnIiLCJleHAiOjE2NDIxNjY4NTJ9.8Ys5Zzk8AOdeAQ6GfeyXxIZ1iTfcxucnzuaJoA27A5o" \ -H "Content-Type: application/json" \ http://localhost:4340/api/latest/hubs/myhub/definition/locscontent_copy
After creating a location, it is recommended to test the location connection using (/hubs/{hub}/locs/{loc}/test) in File and DB Browse Interface.
Refresh Data
This is an example for data in Local Data Processing using API. For more information about this REST request, see (/hubs/{hub}/channels/{channel}/refresh) in Activate, Refresh, and Compare Interface.
It is mandatory to define source (source_loc) and target location (target_loc) name for refreshing data, all other parameters are optional.
curl \
-X POST \
-d '{"start_immediate":true,"source_loc":"mysrclocation","target_loc":"mytgtlocation","granularity":"bulk"}' \
-H "Authorization: Bearer cCI6IkpXVCJ9.eyJpc3MiOiJodHRHAiOjE2NDI0OTkwOi8vZ2Fib246NTY5MDAiLCJzdWIiOiJodnIiLCJle0NDF9.Rn4eJhDfI2fmDwKh_iiozgPrayfeDAVR6wlyeyJhbGciOiJIUzI1NiIsInR5849DMAp" \
-H "Content-Type: application/json" \
http://localhost:4340/api/latest/hubs/myhub/channels/mychannel/refresh
content_copy
Comments
0 comments
Please sign in to leave a comment.