Making Requests

To start making requests, first check that you're using the correct API key as described in the Overview. Once you have the correct API key, simply send the API key in the headers through OAuth 2.0 Bearer Auth or Basic Auth. An API key must accompany every request.

You'll find curl examples for each individual endpoint directly in the docs, but here are some examples using common languages. The example is for getting patients, but you can just switch out the URL, and it would be the same.

To replace Basic for Bearer, you just need to send on your HTTP Headers a key, value pair with Authorization and Bearer {your api key}

GET requests

require 'open-uri'
require 'json' 
my_api_key = "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
JSON.parse(open("https://api.staging.hint.com/api/provider/patients", http_basic_authentication: [my_api_key, '']).read)
require 'open-uri'
require 'json' 

my_api_key = "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
endpoint = "https://api.staging.hint.com/api/provider/patients"
headers = {
    "Authorization" => "Bearer #{my_api_key}"
}
JSON.parse(open(endpoint, headers).read)
// You must npm install superagent.
var superagent = require('superagent')
var myApiKey =  "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
superagent
  .get("https://api.staging.hint.com/api/provider/patients")
  .auth(myApiKey, "")
  .end(function(err, res) {
    // patients!
    console.log(res)
  });
# You must install requests
import requests
api_key = "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
res = requests.get('https://api.staging.hint.com/api/provider/patients', auth=(api_key, ""))
patients = res.json()
; You must install clj-http.client
(ns my-app.core
  (:require [clj-http.client :as client]))

(let [my-api-key "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"]
  (client/get "https://api.staging.hint.com/api/provider/patients" {:basic-auth [my-api-key, ""]}))
$username = '3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw';
$password = ''
$url = "https://api.staging.hint.com/api/provider/patients"
 
$context = stream_context_create(array(
    'http' => array(
        'header'  => "Authorization: Basic " . base64_encode("$username:$password")
    )
));
$data = file_get_contents($url, false, $context);
$api_key = '3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw';
$url = "https://api.staging.hint.com/api/provider/patients"
 
$context = stream_context_create(array(
    'http' => array(
        'header'  => "Authorization: Bearer " . $api_key)
    )
));
$data = file_get_contents($url, false, $context);
curl -i 'https://api.staging.hint.com/api/provider/patients' \
     -H 'Authorization: Bearer 3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw' -v

POST/PATCH requests

# You must install HTTParty
include HTTParty
my_api_key = "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
params = {patient: {first_name: "Reginald", last_name: "Dwight", email: "[email protected]"}}
response =
  HTTParty.post("https://api.staging.hint.com/api/provider/patients", 
    body: params, basic_auth: {username: my_api_key, pass: ''})
// You must npm install superagent.
var superagent = require('superagent')
var myApiKey =  "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
var params = {patient: {first_name: "Reginald", last_name: "Dwight", email: "[email protected]"}}

superagent
  .post("https://api.staging.hint.com/api/provider/patients")
  .auth(myApiKey, "")
  .send(params)
  .end(function(err, res) {
    // patients!
    console.log(res)
  });
# You must install requests
import requests
import json
api_key = "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
params = {patient: {first_name: "Reginald", last_name: "Dwight", email: "[email protected]"}}

res = requests.post('https://api.staging.hint.com/api/provider/patients', data=json.dumps(params), auth=(api_key, ""))

patients = res.json()
; You must install clj-http.client
(ns my-app.core
  (:require [clj-http.client :as client]))

(let [my-api-key "3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw"
      params {patient: {first_name: "Reginald", last_name: "Dwight", email: "[email protected]"}}]
  (client/post "https://api.staging.hint.com/api/provider/patients" 
    {:basic-auth [my-api-key, ""]
     :form-params params
     :content-type :json}))
$apiKey = '3ljlQa6VeG0iB9WgrgywbgC1GwPUfM3WMzw';
$password = '';
$url = "https://api.staging.hint.com/api/provider/patients"

// The data to send to the API
$postData = array(
    'patient' => array(
        'first_name' => 'Reginald',
      'last_name' => 'Dwight',
        'email' => '[email protected]'
        )
);

// Setup cURL
$ch = curl_init($url);
curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
        CURLOPT_USERPWD => "$apiKey:$password");
    CURLOPT_HTTPHEADER => array(
        'Content-Type: application/json'
    ),
    CURLOPT_POSTFIELDS => json_encode($postData)
));

// Send the request
$response = curl_exec($ch);

// Decode the response
$responseData = json_decode($response, TRUE);

๐Ÿ“˜

PUT and PATCH are treated the same.

Anywhere you see a "PATCH" method in these docs, our API will also support "PUT". From an HTTP semantics standpoint, since we do not expect (nor want) you to send us the entire new version of the object you wish to change, it is preferred to use PATCH. However, if for technical reasons this is not possible, then a PUT is also acceptable, and it will be treated the same as a PATCH request.

๐Ÿšง

Use The Correct Endpoint in Production!

The examples listed above use api.staging.hint. This is by design so that you can easily copy/paste and test endpoints with a functioning (staging) API key. However, our production api is just api.hint. We show this URL in the actual endpoint documentation, but just make sure you're using the right one for production!


Whatโ€™s Next
Did this page help you?