Quick Start

obtain api credentials sign in to the spike admin console at admin spikeapi com under applications , view your app id and hmac key (keep your hmac key confidential) once you have these credentials, you can start using spikeapi integration flow users will be redirected to a data provider website and users will be asked to submit authentication details once the user authorizes access to their data, spike returns the user back to the application using the callback url (you can edit it on the spike admin console) below part is relevant for the direct integrations with the providers through the sdk excluding apple health and health connect for apple health and health connect part please go straight to the quick start docid\ ofagvott jzk wqyd5z4g mobile sdk integration initialization for a user to establish connections with data providers, authenticate the user using a simple function which generates a url to the data provider page let url = spikeconnection getintegrationiniturl(provider garmin) uiapplication shared open(url(string url), options \[ ], completionhandler nil) required function parameters provider (string) name of the data provider apple health / health connect initialization in order to be able to retrieve data from apple health and health connect you will need to establish a connection and request relevant permissions from the user to set up the spike sdk create spikeconnectionv3 instance with your spike application id, auth token and user id unique to each of your users import spike from 'react native spike sdk'; const connection = await spike createconnectionapiv3( "applicationid", "signature", "enduserid" ); once the connection is established you should ask user to grant you access to the relevant health data // this call may present user with os native modal asking for read // permissions needed to get steps and distance data if you want to // present it only once, you should list all the statistic types you // plan to use otherwise, you can call this only before you actually // want to use the data spikeconnection requesthealthpermissions(\[statisticstype steps, statisticstype distancetotal]) for android there are more methods that let you get permissions granted by user, check if health connect is installed or should be updated, etc if you are ok with spikesdk handling these, you can use requesthealthpermissions only on ios requesthealthpermissions is the only method that has to be called keep in mind, that you should do it before trying to read data from android health connect or apple healthkit api authentication for a user to establish connection to spike authentication must be done application user id should be be constant throughout entire user lifecycle user requires no pre registration and will be valid from the moment of first provider integration is authorized curl location 'https //app api spikeapi com/v3/auth/hmac' \\ \ header 'content type application/json' \\ \ header 'accept application/json' \\ \ data '{ "application id" 9999, "application user id" "my application user 123", "signature" "string" }' required parameters application id (int) application id is constant and can be found on your console after login it's unique identifyer of your application application user id (string) id you have selected to uniquely identify user on your own system, for e g " my application user 123 " signature (string) signature generated per each user using hmac const crypto = require('crypto'); // example signuser("my application user 123") function signuser(userid) { const hmackey = "hmac key from admin console"; const hmac = crypto createhmac('sha256', hmackey); hmac update(userid); return hmac digest('hex'); }import hmac import hashlib \# example sign user("my application user 123") def sign user(user id str) > str hmac key = b"hmac key from admin console" h = hmac new(hmac key, user id encode(), hashlib sha256) return h hexdigest()import ( &#x9;"crypto/hmac" &#x9;"crypto/sha256" &#x9;"encoding/hex" ) // example signuser("my application user 123") func signuser(userid string) (string, error) { &#x9;m = hmac new(sha256 new, \[]byte("hmac key from admin console")) &#x9; , err = m write(\[]byte(userid)) &#x9;if err != nil { &#x9; return "", err &#x9;} &#x9;return hex encodetostring(m sum(nil)), nil }\<?php // example signuser("my application user 123") function signuser($userid) { $hmackey = "hmac key from admin console"; $hmac = hash hmac('sha256', $userid, $hmackey, false); return $hmac; } api integration initialization api integration initialization to connect users with data providers, first make an api call to get a redirect url then redirect users to this url to start the oauth integration process api endpoint https //app api spikeapi com/v3/providers/{provider slug}/integration/init url provider slug is a canonical name of a provider, eg fitbit, garmin, huawei, oura, etc query parameters redirect uri (string, url) optional url to redirect the user back to after the integration is complete must be a whitelisted domain for your application state (string) optional state parameter that will be passed back to your redirect uri can be used to maintain state between the request and callback so to get back an integration url for garmin you would make the following call curl x get "https //app api spikeapi com/v3/providers/garmin/integration/init url" h "authorization bearer eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9 eyjpc3mioii5otk5iiwic3viijoiyxbwbgljyxrpb24tdxnlci1pzc0xmjmifq xni1y4tkrjdisehwuqdmk9em htpojtmzbou30nmd y" which returns { "provider slug" "garmin", "path" "https //app api spikeapi com/v3/providers/garmin/integration/init/ic/8usq2pfxn1g6zfic3viijoiyxvsqk9bgjbeacdiclovyuahr5fo0qic3viijoiyxjuchcfg8o2auqlw" } you can then redirect the user to path which would initiate the integration process data retrieval once you have created a sdk connection or user authorized themselves directly through the provider page you are able to retrieve their data in order to do that you will need to utilise our sdk or api endpoitns please refer to the more detailed guide in our dedicated sdk guides or api reference spikesdk ios docid\ qj3cwccqxehhs7ihl1ufc spikesdk android docid\ fvsea5vnt0ig 84d2qprf spikesdk react native docid\ hoe1en5oqggh ydynofwl spikesdk flutter docid 7iimoq118rccvehrjh is introduction docid\ bhzndeybg2el guovivz4 data retention policy with our newest api version we are changing the approach how we are dealing with the user data in order for our clients to retrieve their user data more easily we will be storing user data on our end through the spike console you are able to change for how long you would like to for us to store your user data the option to not store the data remains available please also note that data retention policy directly correlates with the historical data for example if you will set up your data retention policy for 10 days, you will be able to retrieve user data for the past 10 days