npm install @api7/portal-sdk axios
# or
yarn add @api7/portal-sdk axios
# or
pnpm add @api7/portal-sdk axiosaxios is a peer dependency, so it must be installed alongside this package. Most package managers will install it for you automatically, but if not, add it explicitly.
This package supports both ESM and CJS.
Call APIs directly from your backend, e.g. within a server function.
import { API7Portal } from '@api7/portal-sdk'
const client = new API7Portal({
endpoint: 'https://portal.example.com',
token: 'a7prt-...',
getDeveloperId: async () => await getDeveloperIdFromSession(), // optional
});The getDeveloperId is optional, you can also manually set the default request header as HEADER_DEVELOPER_ID on your own axios instance.
import axios from 'axios'
import { API7Portal, HEADER_DEVELOPER_ID } from '@api7/portal-sdk'
const instance = axios.create({
headers: { [HEADER_DEVELOPER_ID]: "YOUR_DEVELOPER_ID" },
});
const client = new API7Portal({ ..., axios: instance });const apps = await client.apiProduct.list();
console.log(apps);This SDK targets API7 Enterprise 3.9+. Minimum version per feature:
| Feature | Client property | 3.9.x | 3.10.x |
|---|---|---|---|
| API Products | apiProduct |
3.9.0 | 3.10.0 |
| Applications | application |
3.9.0 | 3.10.0 |
| Application Credentials | application.credential |
3.9.0 | 3.10.0 |
| Credentials (cross-application) | credential |
3.9.0 | 3.10.0 |
| Subscriptions | subscription |
3.9.0 | 3.10.0 |
| Developers | developer |
3.9.0 | 3.10.0 |
| Approvals | approval |
3.9.14 | 3.10.1 |
| DCR Providers | dcrProvider |
3.9.0 | 3.10.0 |
| Labels | misc |
3.9.0 | 3.10.0 |
| System Settings | systemSetting |
3.9.0 | 3.10.0 |
Method-level detail lives in each method's @since JSDoc tag.
When you call an API, APIError is the only type of error expected to be thrown, whether it's an error on the REST API or a network error. You can access the request and response there, and also access the underlying AxiosError when needed.
import { APIError } from '@api7/portal-sdk'
try {
const apps = await client.apiProduct.list();
} catch (error) {
if (APIError.isAPIError(error)) {
console.error('API Error:', error.message, 'Status Code:', error.statusCode);
console.error('Underlying Error:', error.rawError()); // Access the underlying AxiosError
} else {
console.error('Unexpected Error:', error);
}
}