Resource Examples
Resources are API integrations that developers can create, publish, and monetize on the marketplace. These examples demonstrate how to build resources for different use cases, from simple REST APIs to complex OAuth2 integrations and webhook receivers.
Each example shows the complete resource definition, authentication setup, and usage patterns in scripts.
Examples
Creating a cryptocurrency price API
This example demonstrates how to create a REST API resource that provides real-time cryptocurrency price data. The resource defines two methods: one for fetching a single price and another for batch price queries.
API Definition
Create the resource using the POST /api/sdk/v1/resources endpoint:
Result
The resource becomes available in the marketplace. Users can install it and call the defined methods from their scripts. This pattern works for any REST API that uses API key authentication.
Building a weather data integration
This example shows how to create a data source resource for weather information. The resource wraps a third-party weather API and exposes a simplified interface for retrieving current weather conditions.
API Definition
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.
Setting up a webhook receiver
This example demonstrates how to create a webhook resource that receives event notifications from external services. Webhook resources are useful for integrating with payment processors, CRM systems, and other services that push data to your application.
Webhook Configuration
Result
The webhook resource listens for incoming events and triggers your scripts when events arrive. The platform handles signature verification and event routing automatically.
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 and Monetization
Publishing to the marketplace
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
- Resources - Complete resource documentation
- Creating Resources - Step-by-step creation guide
- Script Examples - Using resources in scripts
- Template Examples - Resources in templates
- Authentication - Authentication guide