REST APIs

Connect your ForgeZap applications to external REST APIs. Fetch data from services, integrate with third-party platforms, and build powerful data-driven applications.

API Integration

ForgeZap makes it easy to connect to any REST API. Configure endpoints, handle authentication, and transform data to work seamlessly with your components.

Supported APIs

Pre-configured APIs

Development APIs

  • • JSONPlaceholder - Test data
  • • ReqRes - User management
  • • HTTPBin - HTTP testing
  • • Postman Echo - API testing

Popular Services

  • • GitHub API - Repository data
  • • Weather APIs - Weather data
  • • News APIs - News articles
  • • Currency APIs - Exchange rates

Custom APIs

Connect to any REST API by providing the endpoint URL and configuration:

Any REST API endpoint
API key authentication
OAuth integration
Custom headers and parameters

Setting Up API Connections

Basic Configuration

Navigate to Data Sources → REST APIs
Click "Add New API Connection"
Enter API endpoint URL
Configure authentication if required
Test the connection

Authentication Methods

API Key

  • • Header-based authentication
  • • Query parameter authentication
  • • Bearer token authentication
  • • Custom header formats

OAuth

  • • OAuth 2.0 flow
  • • Client credentials
  • • Authorization code flow
  • • Refresh token handling

API Configuration Examples

JSONPlaceholder API

Example configuration for the JSONPlaceholder test API:

Endpoint Configuration

text
Base URL: https://jsonplaceholder.typicode.com
Method: GET
Endpoint: /posts
Authentication: None

Sample Response

json
[
  {
    "id": 1,
    "title": "sunt aut facere repellat",
    "body": "quia et suscipit...",
    "userId": 1
  }
]

GitHub API

Example configuration for the GitHub API with authentication:

Endpoint Configuration

text
Base URL: https://api.github.com
Method: GET
Endpoint: /repos/{owner}/{repo}/issues
Authentication: Bearer Token
Headers: {
  "Authorization": "Bearer YOUR_GITHUB_TOKEN",
  "Accept": "application/vnd.github.v3+json"
}

Query Parameters

text
?state=open&sort=created&direction=desc&per_page=10

Data Transformation

Transform API responses to work with your components. Extract specific fields, format data, and handle different response structures.

Field Mapping

Map API response fields to component properties:

Extract specific fields from API responses
Rename fields for component compatibility
Handle nested JSON structures
Apply data transformations

Data Processing

Extract Nested Data

javascript
// Original API response
{
  "user": {
    "profile": {
      "name": "John Doe",
      "email": "john@example.com"
    }
  }
}

// Extract to component
{
  "name": "{{user.profile.name}}",
  "email": "{{user.profile.email}}"
}

Transform Data

javascript
// Transform date format
"created_at": "{{formatDate(item.created_at, 'MMM DD, YYYY')}}"

// Transform text
"status": "{{item.status.toUpperCase()}}"

// Calculate values
"total": "{{item.price * item.quantity}}"

Error Handling

Common API Errors

HTTP Status Codes

  • • 400 - Bad Request
  • • 401 - Unauthorized
  • • 403 - Forbidden
  • • 404 - Not Found
  • • 429 - Rate Limited
  • • 500 - Server Error

Error Handling

  • • Retry failed requests
  • • Show user-friendly messages
  • • Fallback to cached data
  • • Log errors for debugging

Rate Limiting

Many APIs have rate limits. ForgeZap automatically handles rate limiting and provides retry mechanisms for failed requests.

Real-time Updates

Data Refresh

Automatic data refresh at configurable intervals
Manual refresh triggers
Smart caching to reduce API calls

Performance

Use appropriate refresh intervals to balance data freshness with API rate limits. Consider caching strategies for frequently accessed data.

Best Practices

API Security

Always use HTTPS endpoints and secure your API keys. Never expose sensitive credentials in client-side code or public repositories.

Error Handling

Implement proper error handling for API failures. Provide fallback data and user-friendly error messages when APIs are unavailable.

Data Validation

Validate API responses before using them in components. Handle cases where expected fields might be missing or have unexpected formats.