@nice2dev/ui-api
v1.4.64
Published
Nice2Dev API & Integration Platform — OpenAPI editor, API testing, integration builder
Maintainers
Readme
@nice2dev/ui-api
Nice2Dev API & Integration Platform — API client and documentation, integrations, integration builder for React applications.
Features
NiceApiClient - send requests and document the API
- Request builder: parameters, nine body kinds, every auth kind (API key, bearer, basic, digest, OAuth 2, AWS SigV4, HMAC signatures, mTLS, custom headers)
- Environments and variables,
{{secret:KEY}}from the host - Import curl, OpenAPI / Swagger, Postman, HAR, GraphQL, WSDL; export OpenAPI, Postman, HAR, Markdown
- Documentation mode: operations, models (editable, with references), security schemes
NiceIntegrationBuilder - Visual flow builder
- Drag-and-drop flow design
- Connector library
- Transformation mapping
- Error handling
- Scheduling
Installation
npm install @nice2dev/ui-api
# or
pnpm add @nice2dev/ui-apiUsage
API client
import { NiceApiClient } from '@nice2dev/ui-api';
import '@nice2dev/ui-api/style.css';
function App() {
return (
<NiceApiClient
defaultValue={collection}
environments={[{ id: 'dev', name: 'Development', values: [{ key: 'baseUrl', value: 'http://localhost:3000' }] }]}
onChange={saveCollection}
/>
);
}Integration Builder
import { NiceIntegrationBuilder } from '@nice2dev/ui-api';
import '@nice2dev/ui-api/style.css';
function App() {
return (
<NiceIntegrationBuilder
connectors={[
{ id: '1', name: 'Slack', type: 'communication', authType: 'oauth2', operations: [] },
{ id: '2', name: 'Salesforce', type: 'crm', authType: 'oauth2', operations: [] },
]}
onSave={(flow) => saveFlow(flow)}
onRun={(flow) => executeFlow(flow)}
/>
);
}API Client (1.4.11)
NiceApiClient: Scalar / Swagger UI-style client and documentation on the core model below. It
imports curl, OpenAPI, Postman, HAR, GraphQL or WSDL and exports OpenAPI, Postman, HAR or Markdown.
import { NiceApiClient, importOpenApi } from '@nice2dev/ui-api';
<NiceApiClient
defaultValue={importOpenApi(openApiYaml)}
environments={[{ id: 'dev', name: 'Dev', values: [{ key: 'token', value: '{{secret:API_TOKEN}}' }] }]}
sendRequest={hostProxyTransport} // your proxy: the browser's fetch meets CORS
resolveSecret={(key) => vault.get(key)}
mode="both" // 'consume' | 'document' | 'both'
/>;Core without React — @nice2dev/ui-api/core (1.4.9)
The model and converters the API tools are built on, usable in Node (importers in CI, generators, a host's proxy). Nothing in it imports React or another package.
- Model:
NiceApiCollection→ folders →NiceApiRequest(one parameter list with a location per row: query / path / header / cookie; nine body kinds incl. GraphQL and SOAP; authinherit, API key, Bearer, Basic, Digest, OAuth 2, AWS SigV4, HMAC, mTLS, custom), variables ({{name}}, secrets only as{{secret:KEY}}), environments. - Import / export: curl (bash, cmd, PowerShell), OpenAPI 3.0 / 3.1 and Swagger 2.0 (JSON or
YAML,
$refacross files throughresolveRef), Postman Collection v2.1 (v2.0 read) and environments, HAR 1.2, GraphQL introspection, WSDL 1.1 (SOAP 1.1 / 1.2 envelopes).importApiDocument(text)recognises the format. - Code samples: curl, fetch, C# HttpClient, PowerShell, Python (
generateCode). - Sending:
resolveRequest(variables + auth signing with Web Crypto),sendApiRequest(answers a Digest challenge),fetchTransportor the host's own transport; OAuth 2 token helpers (client credentials, password, authorization code with PKCE, device flow, refresh). - Also: a YAML reader / writer, mock data from schemas, Markdown docs.
import {
importApiDocument,
exportOpenApiYaml,
generateCode,
sendApiRequest,
fetchTransport,
variableScope,
} from '@nice2dev/ui-api/core';
const { collection } = importApiDocument(openApiYamlText);
const request = collection!.items[0];
if (request.kind === 'request') {
console.log(generateCode(request, 'csharp'));
const { response } = await sendApiRequest(request, fetchTransport(), {
variables: variableScope(collection, environment),
resolveSecret: (key) => vault.get(key),
});
}
const yaml = exportOpenApiYaml(collection!);License
See LICENSE file.
