Authentication (v2)

How to authenticate to the InnerSpace API

Summary

The InnerSpace API authenticates M2M clients using a session token. Exchange your credentials once at /v2/oauth/token to receive a session_id, then include it as a header on all subsequent API calls.

Developer Access

Contact [email protected] for developer access. They will provide you with a ClientID and ClientSecret.

They will need to know the usage of the credentials - whether it is needed for a backend service, a native application, a single-page web app or regular web app.

Backend Services

Backend services authenticate using the Client Credentials flow. Call /v2/oauth/token with your client_id and client_secret to receive a session_id, then include it as an X-Session-Id header on all subsequent API calls

Examples

Python Example
import requests            

  URL = "https://api.innerspace.io"                                                                                                              
   
  def get_session_id():                                                                                                                                    
      response = requests.post(                          
          url=f"{URL}/v2/oauth/token",
          json={                                                                                                                                           
              "client_id": "Your Client ID",
              "client_secret": "Your Client Secret",                                                                                                       
              "audience": "https://global-config.innerspace.io",
          },
          headers={"Content-Type": "application/json"},
      )                                                                                                                                                    
      response.raise_for_status()
      return response.json()["session_id"]                                                                                                                 
                                                         

  sample_graphql = {
      "operationName": "sample_graphql",
      "variables": {},
      "query": """                                                                                                                                         
          query sample_graphql {
              BUILDING_INSIGHTS(                                                                                                                           
                  where: {                               
                      DATE_PARTITION: {_eq: 20250501},
                      BUILDING_ID: {_eq: 71},
                      GRANULARITY: {_eq: "PT1H"},                                                                                                          
                      GROUP_ID: {_eq: "all-e707b3a8-0732-49ae-9156-13ff1138540e"},
                      SITE_ID: {_eq: 900000222}                                                                                                            
                  },                                                                                                                                       
                  order_by: {DATE_TIME_START: desc}
              ) {                                                                                                                                          
                  BUILDING_ID                            
                  DATE_TIME_START
                  OCCUPANCY_MEAN
                  GRANULARITY
                  GROUP_ID
                  SITE_ID                                                                                                                                  
              }
          }                                                                                                                                                
      """,                                               
  }

  session_id = get_session_id()
  response = requests.post(
      url=f"{URL}/v2/api",
      json=sample_graphql,
      headers={"X-Session-Id": session_id},                                                                                                                
  )
                                                                                                                                                           
  # re-authenticate if session expired and retry once                                                                                                      
  if response.status_code == 401:
      session_id = get_session_id()                                                                                                                        
      response = requests.post(                          
          url=f"{URL}/v2/api",
          json=sample_graphql,                                                                                                                             
          headers={"X-Session-Id": session_id},
      )                                                                                                                                                    
                                                         
  response.raise_for_status()
  print(response.json())

Last updated

Was this helpful?