Essential tools, libraries, and resources for PERS API integration.
The official TypeScript library providing type-safe contracts and DTOs for PERS API integration.
📦 Package Size vs Runtime Impact: While the npm package is 1.2 MB (includes comprehensive TypeScript definitions), modern bundlers with tree-shaking typically include only 0.44-0.67 KB in your final bundle - that's 99.9%+ elimination!
npm install @explorins/pers-shared- Package Name:
@explorins/pers-shared - Registry: npmjs.org
- License: MIT
- Maintainer: eXplorins Development Team
- DTOs: Complete type definitions for all API request/response objects
- Interfaces: TypeScript contracts for authentication, users, campaigns, transactions
- Types & Enums: Authentication types, error codes, transaction statuses
- Value Objects: Immutable data structures like
Address,StructuredError - Error Types: TypeScript error interfaces and enums for type-safe error handling
import type {
UserDTO,
TransactionStatus,
StructuredError,
PasskeysAuthRequestDTO,
UserAuthResponseDTO
} from '@explorins/pers-shared';
// Type-safe API requests
const authRequest: PasskeysAuthRequestDTO = {
authToken: "external_provider_jwt_token"
};
// Structured error handling
try {
const response = await fetch('/auth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(authRequest)
});
if (!response.ok) {
const error: StructuredError = await response.json();
if (error.category === 'SECURITY') {
console.error('Authentication failed:', error.message);
// Handle authentication error with proper error code
}
return;
}
const user: UserAuthResponseDTO = await response.json();
console.log(`Authenticated user: ${user.email}`);
} catch (error) {
console.error('Network error:', error);
}
// Type-safe response handling
async function authenticateUser(token: string): Promise<UserAuthResponseDTO> {
const response = await fetch('/auth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ authToken: token })
});
return response.json() as Promise<UserAuthResponseDTO>;
}// Browser-optimized import for smaller bundle size
import { UserDTO, CampaignDTO, Address } from '@explorins/pers-shared/browser';
// Type-safe API client interface
interface PERSApiClient {
authenticate(request: PasskeysAuthRequestDTO): Promise<UserAuthResponseDTO>;
getBalance(userId: string): Promise<UserTokenBalancesDTO>;
getCampaigns(): Promise<CampaignDTO[]>;
}
// React component example
import React from 'react';
import type { UserTokenBalancesDTO } from '@explorins/pers-shared/browser';
interface UserBalanceProps {
user: UserTokenBalancesDTO;
}
const UserBalance: React.FC<UserBalanceProps> = ({ user }) => {
return (
<div>
<h2>{user.email}</h2>
<p>Wallet: {user.walletAddress?.getValue()}</p>
{user.tokenBalances?.map(balance => (
<div key={balance.tokenId}>
{balance.tokenName}: {balance.balance}
</div>
))}
</div>
);
};<template>
<div>
<h2 v-if="user">{{ user.email }}</h2>
<div v-for="campaign in campaigns" :key="campaign.id">
{{ campaign.name }}
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import type { UserDTO, CampaignDTO } from '@explorins/pers-shared/browser';
const user = ref<UserDTO | null>(null);
const campaigns = ref<CampaignDTO[]>([]);
onMounted(async () => {
try {
const userResponse = await fetch('/api/user/me');
if (userResponse.ok) {
user.value = await userResponse.json() as UserDTO;
}
const campaignsResponse = await fetch('/api/campaigns');
if (campaignsResponse.ok) {
campaigns.value = await campaignsResponse.json() as CampaignDTO[];
}
} catch (error) {
console.error('API Error:', error);
}
});
</script>// Type-safe API requests const authRequest: PasskeysAuthRequestDTO = { authToken: "external_provider_jwt_token" };
// Structured error handling using ErrorFactory try { const user = await authenticate(authRequest); console.log(Authenticated user: ${user.email}); } catch (error) { if (error === Errors.authenticationRequired()) { console.error('Authentication failed:', error.message); // Handle authentication error with proper error code } }
- **Auto-completion**: All PERS types and interfaces
- **Error Detection**: TypeScript validation for API contracts
- **Quick Info**: Hover documentation for all DTOs
- **Go to Definition**: Navigate to type definitions
#### **WebStorm/IntelliJ**
Full TypeScript integration:
- **Smart Code Completion**: Context-aware suggestions
- **Refactoring Support**: Rename and restructure with confidence
- **Error Highlighting**: Real-time validation
- **Import Organization**: Auto-import management
### **Build Tool Integration**
#### **Webpack**
```javascript
// webpack.config.js - Tree shaking configuration
module.exports = {
optimization: {
usedExports: true,
sideEffects: false // @explorins/pers-shared is side-effect free
}
};// vite.config.js - Optimized for PERS library
import { defineConfig } from 'vite';
export default defineConfig({
optimizeDeps: {
include: ['@explorins/pers-shared']
}
});// rollup.config.js - Tree shaking optimization
export default {
external: ['@explorins/pers-shared'],
output: {
format: 'es'
}
};- Swagger UI: Available at
/swaggerwhen running PERS API server - OpenAPI Spec: Complete API specification with examples
- Postman Collection: Ready-to-use API collection for testing
- Integration Patterns: Common use cases and implementations
- Sample Applications: Full working examples in different frameworks
- Best Practices: Recommended implementation approaches
- Documentation: Comprehensive API documentation and guides
- API Status: Real-time API status monitoring
- Developer Portal: Developer resources and community
- Technical Support: Contact integration team for API assistance
- Bug Reports: Submit issues through official channels
- Feature Requests: Propose enhancements via developer portal
Install the Library
npm install @explorins/pers-sharedSet Up TypeScript
{ "compilerOptions": { "strict": true, "moduleResolution": "node", "esModuleInterop": true } }Configure Your IDE
- Enable TypeScript language service
- Install PERS-specific extensions (if available)
- Set up auto-import preferences
Start Building
import { UserDTO } from '@explorins/pers-shared'; // Your PERS integration starts here!
- Review the Authentication Guide for API access setup
- Explore the Platform Overview for architectural understanding
- Check the interactive API documentation for endpoint details
- Join the developer community for best practices and support
PERS API V2 delivers substantial performance enhancements across all operations:
- Faster Response Times: Up to 3x improvement in API response speeds
- Enhanced Scalability: Optimized infrastructure handles higher concurrent loads
- Reduced Latency: Streamlined request processing with improved efficiency
- Better Resource Usage: Optimized memory and processing patterns
PERS API V2 introduces significant improvements but requires migration from previous versions:
- Plural Resource Names: All endpoints now use plural naming conventions
/campaign→/campaigns/user→/users/token→/tokens/balance→/balances/redemption→/redemptions
- RESTful Paths: Role-agnostic URLs with decorator-based authorization
- Nested Resources: Improved resource relationships (e.g.,
/campaign-claims,/campaign-triggers)
- Unified Authentication: Streamlined
/auth/tokenendpoint for multiple flows - Structured Errors: Enhanced error responses with correlation IDs and security filtering
- Consistent DTOs: Standardized data transfer objects across all endpoints
- Update Library: Install latest
@explorins/pers-sharedfor new types - Update URLs: Change all endpoint URLs to use plural resource names
- Review Authentication: Verify authentication patterns work with new endpoints
- Error Handling: Update error handling for new structured error format. See Error Handling for details.
- Testing: Validate integration in sandbox environment before production
Migrating to V2 provides immediate performance benefits with no additional configuration required. Applications typically see faster response times and improved reliability upon migration.
Legacy endpoints remain functional during transition period. Contact support for migration timeline and assistance.
For detailed migration assistance, contact our integration team.