Horizon Framework

API Client

ApiClientV1 provides access to the Platform APIs and metadata

// No framework
import { ApiClientV1 } from '@skedulo/horizon-core'

const apiClient = new ApiClientV1({ auth, platformApiDomain })
const response = await apiClient.query.getObjects({ resourceId: '123' })
...

// React
import { useApiClient } from '@skedulo/horizon-core'

const MyComponent = () => {
  const apiClient = useApiClient()

  useEffect(() => {
    apiClient?.query.getObjects({ resourceId: '123' }).then(...)
  }, [apiClient])

  return null
}

Access user and tenant information

The ApiClientV1 instance provides access to the user and tenant information.

import { useApiClient } from '@skedulo/horizon-core'

const apiClient = useApiClient()

// Access user and tenant info
apiClient.userId() // string
apiClient.tenantId() // string
apiClient.isSalesforce() // boolean
apiClient.isSkedulo() // boolean