Registry / testing / apipost-grpc

apipost-grpc

JSON →
library2.0.7jsnpmunverified

Apipost's gRPC module for simulating gRPC client requests with parameter mocking support. Version 2.0.7. Designed for use with Apipost 8. Provides a client class to load .proto files, list services and methods, and send gRPC requests with optional SSL/TLS support. Differentiator: integrates with Apipost ecosystem for API testing workflows.

npm install apipost-grpc
INSTALL
IMPORT
SIG · APIPOST-GRPC
A
apipost-grpc
testingjavascriptv2.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ApipostGrpc
import { ApipostGrpc } from 'apipost-grpc'
import ApipostGrpc from 'apipost-grpc'
Named export, not default. CommonJS: const { ApipostGrpc } = require('apipost-grpc')
ApipostGrpc
const { ApipostGrpc } = require('apipost-grpc')
const ApipostGrpc = require('apipost-grpc')
Must destructure the named export in CommonJS
ApipostGrpc
import type { ApipostGrpc } from 'apipost-grpc'
import { ApipostGrpc } from 'apipost-grpc'
Use type import only when type-checking, not runtime; runtime requires value import

Initialize a gRPC client, send a request with headers and JSON body, and log the response.

import { ApipostGrpc } from 'apipost-grpc'; import path from 'path'; const gRpcClient = new ApipostGrpc({ proto: path.resolve(__dirname, './protos/HelloWorld.proto'), }); const target = { request: { url: '127.0.0.1:50051', header: [ { is_checked: '1', key: 'content-type', value: 'application/grpc' }, ], body: { raw: JSON.stringify({ name: 'jim', city: 'Shanghai' }) }, }, }; gRpcClient.request('Greeter', 'SayHello', target).then((response) => { console.log(response); });
Debug
Known issues
gotchaProto file path must be absolute; relative paths may fail at runtime.
fix
Use path.resolve(__dirname, relativePath) to construct absolute path.
affects: *
gotcharequest() expects target.request.header as array of objects with is_checked, key, value. Missing or malformed header may cause errors.
fix
Ensure header array matches the exact schema, including is_checked as string '1' or '0'.
affects: *
gotchabody.raw must be a JSON string; passing an object will cause gRPC serialization error.
fix
Use JSON.stringify on the body object before assigning to raw.
affects: *
gotchaSSL config expects paths to certificate files, not the certificate content. Providing content will be read incorrectly.
fix
Provide path strings (e.g., ca: '/path/to/ca.crt') to ssl option.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'apipost-grpc'
Package not installed or import path incorrect.
fix
Run 'npm install apipost-grpc' and ensure import is correct (named export).
TypeError: gRpcClient.request is not a function
Incorrect import: likely imported default instead of named export.
fix
Use 'import { ApipostGrpc } from 'apipost-grpc'' for ESM or 'const { ApipostGrpc } = require('apipost-grpc')' for CJS.
Error: ENOENT: no such file or directory, open '.../protos/HelloWorld.proto'
Proto file path is relative or incorrect.
fix
Use an absolute path: path.resolve(__dirname, './protos/HelloWorld.proto').
Upgrade
Version history
2.0.7latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredCore gRPC client library
protobufjsrequiredProtobuf parsing and reflection
Agent activity
44 hits · last 30 days
node
40
OpenAI (training)
1
Resources
apipost-grpc — npm install apipost-grpc · libregistry