API
API Quickstart: Issue & Fund Cards in Minutes
2024-01-05
API, developers, integration, virtual cards, documentation
Kripicard API Quickstart Guide
Welcome to the Kripicard API! This guide will get you issuing and funding virtual cards in minutes.
Prerequisites
Before you begin:
- Active Kripicard platform account
- API credentials from your dashboard
- Basic knowledge of REST APIs
- KRIPI tokens for card issuance
## Authentication
All API requests require authentication using your API key:
``javascript
const headers = {
  'Authorization': 'Bearer YOUR_API_KEY',
  'Content-Type': 'application/json'
}
`
## Quick Start: Issue Your First Card
Step 1: Create a Card
javascript
const createCard = async () => {
  const response = await fetch('https://api.kripicard.com/v1/cards', {
    method: 'POST',
    headers: headers,
    body: JSON.stringify({
      type: 'virtual',
      currency: 'USD',
      limit: 1000,
      name: 'My First Card'
    })
  })
  
  const card = await response.json()
  console.log('Card created:', card.id)
  return card
}
`
### Step 2: Fund the Card
javascript
const fundCard = async (cardId, amount) => {
  const response = await fetch(https://api.kripicard.com/v1/cards/${cardId}/fund, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify({
      amount: amount,
      currency: 'USDT'
    })
  })
  
  const result = await response.json()
  console.log('Card funded:', result.balance)
  return result
}
`
### Step 3: Check Card Status
javascript
const getCardDetails = async (cardId) => {
  const response = await fetch(https://api.kripicard.com/v1/cards/${cardId}, {
    headers: headers
  })
  
  const card = await response.json()
  console.log('Card details:', card)
  return card
}
`
## Complete Example
Here's a complete example that creates, funds, and activates a card:
javascript
const kripicard = {
  apiKey: 'YOUR_API_KEY',
  baseUrl: 'https://api.kripicard.com/v1',
  
  async request(endpoint, options = {}) {
    const response = await fetch(${this.baseUrl}${endpoint}, {
      ...options,
      headers: {
        'Authorization': Bearer ${this.apiKey},
        'Content-Type': 'application/json',
        ...options.headers
      }
    })
    
    if (!response.ok) {
      throw new Error(API Error: ${response.statusText})
    }
    
    return response.json()
  },
  
  async createAndFundCard(cardData, fundingAmount) {
    try {
      // Create card
      const card = await this.request('/cards', {
        method: 'POST',
        body: JSON.stringify(cardData)
      })
      
      // Fund card
      const funding = await this.request(/cards/${card.id}/fund, {
        method: 'POST',
        body: JSON.stringify({
          amount: fundingAmount,
          currency: 'USDT'
        })
      })
      
      // Activate card
      const activation = await this.request(/cards/${card.id}/activate, {
        method: 'POST'
      })
      
      return {
        card,
        funding,
        activation
      }
    } catch (error) {
      console.error('Error:', error.message)
      throw error
    }
  }
}
// Usage
const main = async () => {
  const result = await kripicard.createAndFundCard({
    type: 'virtual',
    currency: 'USD',
    limit: 5000,
    name: 'Production Card'
  }, 1000)
  
  console.log('Card ready for use:', result.card.id)
}
main()
`
## Advanced Features
### Webhook Integration
Set up webhooks to receive real-time transaction notifications:
javascript
const setupWebhook = async () => {
  const webhook = await kripicard.request('/webhooks', {
    method: 'POST',
    body: JSON.stringify({
      url: 'https://your-app.com/webhook',
      events: ['transaction.created', 'card.funded', 'card.blocked']
    })
  })
  
  console.log('Webhook configured:', webhook.id)
}
`
### Transaction Monitoring
Monitor card transactions in real-time:
javascript
const getTransactions = async (cardId, limit = 10) => {
  const transactions = await kripicard.request(/cards/${cardId}/transactions?limit=${limit})
  
  transactions.data.forEach(tx => {
    console.log(Transaction: ${tx.amount} ${tx.currency} at ${tx.merchant})
  })
  
  return transactions
}
`
### Batch Operations
Process multiple cards efficiently:
javascript
const batchCreateCards = async (cardConfigs) => {
  const promises = cardConfigs.map(config => 
    kripicard.createAndFundCard(config.cardData, config.fundingAmount)
  )
  
  const results = await Promise.all(promises)
  console.log(Created ${results.length} cards successfully)
  
  return results
}
`
## Error Handling
Implement robust error handling for production use:
javascript
const handleApiError = (error) => {
  switch (error.code) {
    case 'INSUFFICIENT_FUNDS':
      console.log('Please add more KRIPI tokens to your account')
      break
    case 'CARD_LIMIT_EXCEEDED':
      console.log('You have reached your card limit')
      break
    case 'INVALID_CURRENCY':
      console.log('Currency not supported')
      break
    default:
      console.log('Unexpected error:', error.message)
  }
}
`
## Rate Limits and Best Practices
### Rate Limits
- Card Creation: 10 requests per minute
- Funding Operations: 20 requests per minute
- Query Operations: 100 requests per minute
### Best Practices
1. Cache responses when possible
2. Implement exponential backoff for retries
3. Use webhooks instead of polling
4. Validate data before API calls
5. Monitor your usage through the dashboard
## Testing
Use our sandbox environment for testing:
javascript
const testConfig = {
  apiKey: 'test_YOUR_SANDBOX_KEY',
  baseUrl: 'https://sandbox-api.kripicard.com/v1'
}
``
## Next Steps
Now that you're up and running:
1. Explore the complete Kripicard API docs for advanced features
2. Check Kripicard pricing for production rate limits
3. Join our developer community for support
4. Implement webhooks for real-time updates
## Support
Need help? Our developer support team is here to assist:
- Documentation: Full Kripicard API docs available
- Community: Join our Discord for peer support  
- Direct Support: Email api-support@kripicard.com
- Status Page: Monitor API uptime and incidents
Ready to scale your integration? Visit the Kripicard platform to upgrade your account and unlock higher limits.
*This quickstart covers the basics. For comprehensive documentation, visit our Kripicard API docs section.*
Before you begin:
- Active Kripicard platform account
- API credentials from your dashboard
- Basic knowledge of REST APIs
- KRIPI tokens for card issuance
## Authentication
All API requests require authentication using your API key:
``
javascript
const headers = {
  'Authorization': 'Bearer YOUR_API_KEY',
  'Content-Type': 'application/json'
}
`
## Quick Start: Issue Your First Card
Step 1: Create a Card
javascript
const createCard = async () => {
  const response = await fetch('https://api.kripicard.com/v1/cards', {
    method: 'POST',
    headers: headers,
    body: JSON.stringify({
      type: 'virtual',
      currency: 'USD',
      limit: 1000,
      name: 'My First Card'
    })
  })
  
  const card = await response.json()
  console.log('Card created:', card.id)
  return card
}
`
### Step 2: Fund the Card
javascript
const fundCard = async (cardId, amount) => {
  const response = await fetch(https://api.kripicard.com/v1/cards/${cardId}/fund, {
    method: 'POST',
    headers: headers,
    body: JSON.stringify({
      amount: amount,
      currency: 'USDT'
    })
  })
  
  const result = await response.json()
  console.log('Card funded:', result.balance)
  return result
}
`
### Step 3: Check Card Status
javascript
const getCardDetails = async (cardId) => {
  const response = await fetch(https://api.kripicard.com/v1/cards/${cardId}, {
    headers: headers
  })
  
  const card = await response.json()
  console.log('Card details:', card)
  return card
}
`
## Complete Example
Here's a complete example that creates, funds, and activates a card:
javascript
const kripicard = {
  apiKey: 'YOUR_API_KEY',
  baseUrl: 'https://api.kripicard.com/v1',
  
  async request(endpoint, options = {}) {
    const response = await fetch(${this.baseUrl}${endpoint}, {
      ...options,
      headers: {
        'Authorization': Bearer ${this.apiKey},
        'Content-Type': 'application/json',
        ...options.headers
      }
    })
    
    if (!response.ok) {
      throw new Error(API Error: ${response.statusText})
    }
    
    return response.json()
  },
  
  async createAndFundCard(cardData, fundingAmount) {
    try {
      // Create card
      const card = await this.request('/cards', {
        method: 'POST',
        body: JSON.stringify(cardData)
      })
      
      // Fund card
      const funding = await this.request(/cards/${card.id}/fund, {
        method: 'POST',
        body: JSON.stringify({
          amount: fundingAmount,
          currency: 'USDT'
        })
      })
      
      // Activate card
      const activation = await this.request(/cards/${card.id}/activate, {
        method: 'POST'
      })
      
      return {
        card,
        funding,
        activation
      }
    } catch (error) {
      console.error('Error:', error.message)
      throw error
    }
  }
}
// Usage
const main = async () => {
  const result = await kripicard.createAndFundCard({
    type: 'virtual',
    currency: 'USD',
    limit: 5000,
    name: 'Production Card'
  }, 1000)
  
  console.log('Card ready for use:', result.card.id)
}
main()
`
## Advanced Features
### Webhook Integration
Set up webhooks to receive real-time transaction notifications:
javascript
const setupWebhook = async () => {
  const webhook = await kripicard.request('/webhooks', {
    method: 'POST',
    body: JSON.stringify({
      url: 'https://your-app.com/webhook',
      events: ['transaction.created', 'card.funded', 'card.blocked']
    })
  })
  
  console.log('Webhook configured:', webhook.id)
}
`
### Transaction Monitoring
Monitor card transactions in real-time:
javascript
const getTransactions = async (cardId, limit = 10) => {
  const transactions = await kripicard.request(/cards/${cardId}/transactions?limit=${limit})
  
  transactions.data.forEach(tx => {
    console.log(Transaction: ${tx.amount} ${tx.currency} at ${tx.merchant})
  })
  
  return transactions
}
`
### Batch Operations
Process multiple cards efficiently:
javascript
const batchCreateCards = async (cardConfigs) => {
  const promises = cardConfigs.map(config => 
    kripicard.createAndFundCard(config.cardData, config.fundingAmount)
  )
  
  const results = await Promise.all(promises)
  console.log(Created ${results.length} cards successfully)
  
  return results
}
`
## Error Handling
Implement robust error handling for production use:
javascript
const handleApiError = (error) => {
  switch (error.code) {
    case 'INSUFFICIENT_FUNDS':
      console.log('Please add more KRIPI tokens to your account')
      break
    case 'CARD_LIMIT_EXCEEDED':
      console.log('You have reached your card limit')
      break
    case 'INVALID_CURRENCY':
      console.log('Currency not supported')
      break
    default:
      console.log('Unexpected error:', error.message)
  }
}
`
## Rate Limits and Best Practices
### Rate Limits
- Card Creation: 10 requests per minute
- Funding Operations: 20 requests per minute
- Query Operations: 100 requests per minute
### Best Practices
1. Cache responses when possible
2. Implement exponential backoff for retries
3. Use webhooks instead of polling
4. Validate data before API calls
5. Monitor your usage through the dashboard
## Testing
Use our sandbox environment for testing:
javascript
const testConfig = {
  apiKey: 'test_YOUR_SANDBOX_KEY',
  baseUrl: 'https://sandbox-api.kripicard.com/v1'
}
``## Next Steps
Now that you're up and running:
1. Explore the complete Kripicard API docs for advanced features
2. Check Kripicard pricing for production rate limits
3. Join our developer community for support
4. Implement webhooks for real-time updates
## Support
Need help? Our developer support team is here to assist:
- Documentation: Full Kripicard API docs available
- Community: Join our Discord for peer support
- Direct Support: Email api-support@kripicard.com
- Status Page: Monitor API uptime and incidents
Ready to scale your integration? Visit the Kripicard platform to upgrade your account and unlock higher limits.
*This quickstart covers the basics. For comprehensive documentation, visit our Kripicard API docs section.*
