API Documentation
  • Getting Started
  • Changelog
  • Authentication
  • Date Format
  • Response API
  • Core Resources
    • Journal
    • Habits
      • Status
      • Logs
      • Goal
        • Periodicity
    • Actions List
    • Notes
    • Moods
    • Areas
  • Enum
    • Action Status
    • Mood Value
    • Note Type
    • Unit Type
    • Log Method
    • Time Of Day
Powered by GitBook
On this page
  • 1. Obtaining API Key
  • From Mobile Apps(iOS, Android)
  • From Web App
  • 2. Using API Key

Was this helpful?

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.

PreviousChangelogNextDate Format

Last updated 3 years ago

Was this helpful?

API Key is required for every resource.

1. Obtaining API Key

From Mobile Apps(iOS, Android)

  1. Open Settings

  2. Open API Credential

  3. Copy API Key or send to your desktop by tapping Send Via...

From Web App

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

  2. Copy API Key

2. Using API Key

All requests must include an HTTP Header field Authorization with value is the API Key.

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()

API Credential