Resource Examples
Practical examples for creating and publishing API integrations
Resources enable you to create, publish, and monetize API integrations on the marketplace. These examples demonstrate how to build resources for different use cases, from simple REST APIs to complex OAuth2 integrations.
Creating an API Resource
This example creates a cryptocurrency price API resource with API key authentication and pay-per-call pricing.
Request
Response
The resource is created in draft status and must be published before it appears in the marketplace.
Creating an LLM Resource
This example creates an OpenAI GPT-4 resource with bearer token authentication for chat completion.
Request
To create a chat UI with subdomain deployment (e.g., mychat.username.getmirra.app), bundle your LLM resource in a Template.
Weather Data Integration
This example shows how to create a data source resource for weather information with a simplified interface.
Request
Result
The resource provides a clean interface for weather data. Users authenticate once with their weather API key, then call methods without managing authentication in their scripts.
Installing and Using Resources
Installing a Resource
Users install resources before using them in scripts:
Installation creates a personal instance of the resource for the user. Each user maintains their own authentication credentials and usage metrics.
Authenticating with API Keys
Set up API key authentication for installed resources:
The platform stores credentials securely and injects them automatically when scripts call resource methods.
Authenticating with OAuth2
For OAuth2-enabled resources, provide client credentials:
The platform handles the OAuth2 flow, including token refresh, automatically. Scripts access resources without managing tokens.
Using Resources in Scripts
Access installed resources through the global resources object:
The resource name in the resources object matches the resource's identifier. All authentication and error handling happens automatically.
Publishing to Marketplace
Publishing a Resource
Make your resource available to other users:
Published resources appear in the marketplace. You earn revenue each time users call your resource's methods.
Browsing the Marketplace
Find available resources by category:
The response includes resource metadata, pricing information, and installation counts. Filter by category, tags, or search terms to find relevant integrations.
Monitoring Resource Usage
Track usage metrics and revenue for your published resources:
Metrics include total calls, unique users, revenue earned, and error rates. Use this data to optimize pricing and improve resource reliability.
Best Practices
API Design Guidelines
Design resources that are easy to use and maintain:
✅ Do:
- Use clear, descriptive method names (
getPrice, notfetch) - Document all parameters with types and descriptions
- Include response schema documentation
- Handle errors gracefully with meaningful messages
- Version your API to allow non-breaking updates
❌ Avoid:
- Unclear parameter names (
data,info,obj) - Missing or incomplete documentation
- Inconsistent response formats across methods
- Breaking changes without version updates
- Exposing internal implementation details
Authentication Patterns
Support standard authentication methods:
- API Key: Simple and widely supported—use for most REST APIs
- OAuth2: Required for services that need user authorization
- Webhook Signatures: Verify webhook authenticity using HMAC signatures
- Bearer Tokens: For APIs that use JWT or similar token schemes
Always store credentials securely. Never log or expose credentials in error messages or responses.
Pricing Strategies
Choose a pricing model that matches your resource's value:
- Free: Good for open data sources or promotional resources
- Pay-per-use: Charge per API call (e.g., $0.001 per request)
- Subscription: Fixed monthly fee for unlimited usage
- Tiered: Combine free tier with paid tiers for high-volume users
Consider your costs when setting prices. Include API provider fees, infrastructure costs, and support overhead.
Error Handling
Implement robust error handling in your resource:
Return clear error messages that help users debug issues without exposing sensitive information.
See Also
- Overview - Resource concepts and types
- Endpoints - Complete API reference
- Technical Notes - Authentication, pricing, and troubleshooting
- Scripts - Using resources in scripts
- Templates - Resources in templates