Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FDA DSCSA & EU FMD Drug Serialization API — TypeScript / JavaScript SDK

npm version License: MIT Stanza API

US FDA DSCSA 4-element & EU FMD 2D DataMatrix barcode parser, Modulo-10 check digit validator, and NDC-to-GTIN converter in sub-5ms.

Official, zero-dependency Node.js and TypeScript client for FDA DSCSA & EU FMD Drug Serialization API, powered by the Stanza Micro-API Network. Delivers deterministic, sub-5ms V8 isolate execution directly to your application without 3rd-party proxies.


📦 Installation

npm install @stanzaapi/pharma-dscsa
# or
pnpm add @stanzaapi/pharma-dscsa
# or
yarn add @stanzaapi/pharma-dscsa

🚀 Quickstart

import { PharmaDscsaClient } from '@stanzaapi/pharma-dscsa';

// Initialize client (API key optional for sandbox tier evaluation)
const client = new PharmaDscsaClient({
  apiKey: process.env.STANZA_API_KEY,
});

async function main() {
  const result = await client.parse('(01)00300012345678(21)100000000001(17)261231(10)LOT12345');

  if (result.success) {
    console.log('Verification Success:', result.data);
  } else {
    console.error('Validation Error:', result.error, result.code);
  }
}

main().catch(console.error);

📄 Example JSON Response

{
  "success": true,
  "data": {
    "gtin": "00300012345678",
    "serial_number": "100000000001",
    "expiration_date": "2026-12-31",
    "lot_number": "LOT12345"
  }
}

⚙️ Client Configuration Options

Option Type Default Description
apiKey string process.env.STANZA_API_KEY Your Stanza API Key. Required for high-throughput production tiers.
baseUrl string https://api.stanzaapi.com/pharma-dscsa Public edge API base URL.
timeoutMs number 15000 Request timeout in milliseconds (uses native AbortSignal.timeout).

🛡️ Response Envelope & Error Handling

All responses return a typed envelope:

export interface ApiResponse<T> {
  success: boolean;
  data?: T;
  error?: string;
  code?: 'VALIDATION_ERROR' | 'UNAUTHORIZED' | 'PAYLOAD_TOO_LARGE' | 'RATE_LIMITED' | 'INTERNAL_ERROR';
}

🔗 Related Resources

📄 License

MIT © Stanza — Powered by Stanza.

Releases

Packages

Contributors

Languages