Skip to main content

API Requests with @corva/ui

Dev Center frontend applications can use preconfigured clients from @corva/ui/clients. The clients handle the application authentication context and expose methods for common HTTP verbs.

import { corvaAPI, corvaDataAPI } from '@corva/ui/clients';
ClientAPI
corvaAPIPlatform API at api.corva.ai
corvaDataAPIData API at data.corva.ai

Available methods include get, post, put, patch, and del.

Find wells with the Platform API

import Jsona from 'jsona';
import { corvaAPI } from '@corva/ui/clients';

const formatter = new Jsona();

export async function fetchWells() {
const response = await corvaAPI.get('/v2/wells', {
visibility: 'visible',
per_page: 100,
sort: 'name',
order: 'asc',
fields: ['well.name', 'well.asset_id'],
});

return formatter.deserialize(response);
}

Platform API responses use JSON:API conventions. Deserialize them when the application benefits from a simpler object shape.

Read records with the Data API

import { corvaDataAPI } from '@corva/ui/clients';

export async function fetchLatestWits(assetId) {
return corvaDataAPI.get('/api/v1/data/corva/wits/', {
query: JSON.stringify({ asset_id: assetId }),
sort: JSON.stringify({ timestamp: -1 }),
limit: 100,
fields: 'timestamp,asset_id,data.hole_depth,data.bit_depth',
});
}

Method signatures

const result = await client.get(path, queryParams);

Application guidance

  • Request only the fields the component renders.
  • Cancel or ignore stale requests when the selected asset changes.
  • Show loading, empty, and error states.
  • Keep query construction outside render functions.
  • Combine the initial request with socketClient when the view needs live updates.