Authentication

In order to make authorized calls to Habitify APIs, you must obtain your API Key from client-app(mobile app, web-app). This page describes the different ways of obtaining an API Key.
API Key is required for every resource.

1. Obtaining API Key

From Mobile Apps(iOS, Android)

  1. 1.
    Open Settings
  2. 2.
    Open API Credential
  3. 3.
    Copy API Key or send to your desktop by tapping Send Via...

From Web App

  1. 1.
    Open API Credential by navigating to Profile & Settings > API Credential
  2. 2.
    Copy API Key

2. Using API Key

All requests must include an HTTP Header field Authorization with value is the API Key.
CURL
NodeJS
Go
Swift
Example HTTP Request
$ curl "https://api.habitify.me/habits" \
-H "Authorization: {API_KEY}" \
const request = require('request');
const options = {
method: 'GET',
url: 'https://api.habitify.me/habits',
headers: { Authorization: '{API_KEY}' }
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.habitify.me/habits"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "{API_KEY}")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import Foundation
let headers = ["Authorization": "{API_KEY}"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.habitify.me/habits")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()