Skip to content

anyroadcom/mini_stitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Wrapper for Stitch Data's Import API

The Stitch Import API is a REST API that allows you to push arbitrary data into your data warehouse. Once the data enters the Import API, it’ll be processed and sent through Stitch like data from any other integration.

Setup

α) include the gem

Rails:

gem 'stitch_data', github: 'theminijohn/mini_stitch'
β) Authentication

Authentication with the Import API is done with a single API access token placed in the Authorization header of your request and your client ID, which will be used in the request body.

# initializers/mini_stitch.rb
MiniStitch.configure do |config|
  config.token = "your-api-token"
  config.client_id = "your-client-id"
end

This gem also supports a second configuration (for a separate Stitch account) should you want to import data to two different accounts. While secondary_token and secondary_client_id are optional, token and client_id are not.

# initializers/mini_stitch.rb
MiniStitch.configure do |config|
  config.token = "your-api-token"
  config.client_id = "your-client-id"
  config.secondary_token = "your-api-token"
  config.secondary_client_id = "your-client-id"
end

Usage

I recommend you take a look at the Stitch Data Import Api Doc to get the gist of what the upsert, validate & status methods do. Yes, this gem has only 3 methods ☀️

!! For the Wrapper to successfully accept and process your data, your call must contain all of the request fields listed below:

  • table_name | String This field contains the name of the destination table

  • sequence | String This property tells the Import API the order in which data points in the request body should be considered. See Defining Sequence for more info. The most straightforward way is to use Time.now.to_i to get the current time in posix format.

  • key_names | Array | 🔑 This field defines the Primary Key and will contain an array of field names that uniquely identify the row that the record belongs to. Primary Keys identify unique rows within a table and ensure that only the most recently updated version of that record appears in your data warehouse.

  • data | Array of Hashes This field contains the data to be upserted into your data warehouse.

  1. Status

The status endpoint can be used to determine if the Import API is operating correctly.

MiniStitch.status
  1. Validate

The validate endpoint can be used to validate requests but will not persist them to Stitch

MiniStitch::Api.new(table_name, sequence, [key_names], [data]).validate!
  1. Upsert

The upsert endpoint is used to push data into your data warehouse.

MiniStitch::Api.new(table_name, sequence, [key_names], [data]).upsert!

About

Ruby Wrapper for Stitch Data's Import API (IAPI)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6