aerochain-node-sdk
v1.0.0
Published
Official Node.js SDK for the Aerochain API
Maintainers
Readme
Aerochain Node SDK
Official Node.js SDK for the Aerochain API - The blockchain-based aviation parts traceability platform.
Installation
npm install aerochain-node-sdkQuick Start
Authentication with Email/Password
import { AerochainClient } from 'aerochain-node-sdk';
const client = new AerochainClient({
baseURL: 'https://api.aerochain.com',
auth: {
type: 'credentials',
email: '[email protected]',
password: 'your-password',
},
});
await client.initialize();
const parts = await client.parts.list();
console.log(parts);Authentication with API Key
import { AerochainClient } from 'aerochain-node-sdk';
const client = new AerochainClient({
baseURL: 'https://api.aerochain.com',
auth: {
type: 'apiKey',
apiKey: 'your-api-key',
},
});
const parts = await client.parts.list();
console.log(parts);Features
- ✅ Email/Password authentication with automatic JWT token renewal
- ✅ API Key authentication
- ✅ Full TypeScript support
- ✅ Automatic token refresh
- ✅ Comprehensive API coverage
API Reference
Client Initialization
const client = new AerochainClient(config);
await client.initialize(); // Required for credentials authParts
// List parts
const parts = await client.parts.list({ page: 1, filters: { status: 'active' } });
// Get single part
const part = await client.parts.get('part-id');
// Create part
const newPart = await client.parts.create({
serialNumber: 'SN123',
partNumber: 'PN456',
manufacturer: 'org-id',
});
// Create part with event
const formData = new FormData();
formData.append('serialNumber', 'SN123');
formData.append('file', fileBuffer, 'document.pdf');
const partWithEvent = await client.parts.createWithEvent(formData);Event Shares
// List event shares
const shares = await client.eventShares.list({
entityType: 'part',
status: 'pending',
direction: 'received',
});
// Create event share
const share = await client.eventShares.create({
entityType: 'part',
entityUidHex: '0x123...',
toOrganization: 'org-id',
});
// Accept event share
await client.eventShares.accept('share-id');
// Decline event share
await client.eventShares.decline('share-id');
// Cancel event share
await client.eventShares.cancel('share-id');Part Events
// List part events
const events = await client.partEvents.list({ partId: 'part-id' });
// Create part event
const event = await client.partEvents.create({
eventType: 'inspected',
eventDate: '2024-01-01',
partId: 'part-id',
});Aircraft
// List aircraft
const aircraft = await client.aircraft.list();
// Get single aircraft
const plane = await client.aircraft.get('aircraft-id');
// Create aircraft
const newAircraft = await client.aircraft.create({
registration: 'N12345',
msn: 'MSN123',
modelId: 'model-id',
});Organizations
// Get organization
const org = await client.organizations.get('org-id');Users
// Get user
const user = await client.users.get('user-id');Error Handling
try {
const parts = await client.parts.list();
} catch (error) {
if (error.response?.status === 401) {
console.error('Authentication failed');
} else if (error.response?.status === 422) {
console.error('Validation errors:', error.formErrors);
} else {
console.error('Error:', error.message);
}
}TypeScript Support
This SDK is written in TypeScript and includes complete type definitions. All types are exported from the main package:
import { AerochainClient, Part, PartEvent, EventShare, Organization } from 'aerochain-node-sdk';Contributing
We welcome contributions! Please see our Contributing Guide for details.
Versioning
This project follows Semantic Versioning. For the versions available, see the tags on this repository.
See CHANGELOG.md for a detailed history of changes.
Support
- Documentation: FILTERS.md for available filters
- Issues: GitHub Issues
- Examples: See the examples directory
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Built with ❤️ by the Aerochain team for the aviation industry.
