SDKs & Libraries
Build applications faster with our comprehensive collection of official SDKs, libraries, and development tools. Appmint SDKs provide type-safe, well-documented interfaces to all platform services with built-in error handling, retry logic, and performance optimizations.
SDK Overview
Multi-Language Support
Official SDKs Available:
- JavaScript/TypeScript - Full-featured SDK for web and Node.js
- Python - Comprehensive SDK for backend and data processing
- Java - Enterprise-ready SDK with Spring integration
- Go - High-performance SDK for microservices
- PHP - Full-featured SDK for web development
- Ruby - Rails-friendly SDK with ActiveRecord integration
- Swift - Native iOS SDK with modern async/await support
- Kotlin/Java - Android SDK with coroutines support
- C#/.NET - SDK for .NET applications and Azure integration
- Rust - Fast, safe SDK for systems programming
SDK Features
Common Features Across All SDKs:
- Authentication - Automatic token management and refresh
- Error Handling - Comprehensive error types and retry logic
- Type Safety - Full type definitions and IntelliSense support
- Async Support - Modern async/await patterns
- Pagination - Automatic handling of paginated responses
- Rate Limiting - Built-in rate limit handling
- Caching - Intelligent request caching
- Logging - Structured logging and debugging support
JavaScript/TypeScript SDK
Installation
# npm
npm install @appmint/sdk
# yarn
yarn add @appmint/sdk
# pnpm
pnpm add @appmint/sdk
Quick Start
import { Appmint } from '@appmint/sdk';
// Initialize the client
const appmint = new Appmint({
apiKey: 'your-api-key',
projectId: 'your-project-id',
environment: 'production' // or 'staging', 'development'
});
// Create a user
const user = await appmint.auth.createUser({
email: 'user@example.com',
password: 'secure-password',
profile: {
firstName: 'John',
lastName: 'Doe'
}
});
// Store data
const document = await appmint.database.collection('posts').create({
title: 'Hello World',
content: 'This is my first post',
authorId: user.id
});
// Upload file
const file = await appmint.storage.upload({
file: fileInput.files[0],
path: 'uploads/images/',
public: true
});
Advanced Configuration
// Advanced client configuration
const appmint = new Appmint({
apiKey: process.env.APPMINT_API_KEY,
projectId: process.env.APPMINT_PROJECT_ID,
// Retry configuration
retry: {
attempts: 3,
delay: 1000,
backoff: 'exponential'
},
// Timeout settings
timeout: 30000,
// Custom headers
headers: {
'X-Custom-Header': 'value'
},
// Debug mode
debug: process.env.NODE_ENV === 'development',
// Custom base URL (for on-premise)
baseURL: 'https://api.your-domain.com'
});
// Configure authentication
appmint.auth.configure({
// Custom token storage
tokenStorage: {
get: () => localStorage.getItem('token'),
set: (token) => localStorage.setItem('token', token),
remove: () => localStorage.removeItem('token')
},
// Auto-refresh tokens
autoRefresh: true,
// Custom authentication callbacks
onTokenRefresh: (token) => console.log('Token refreshed'),
onAuthError: (error) => console.error('Auth error', error)
});
React Integration
import { AppmintProvider, useAppmint, useAuth, useDatabase } from '@appmint/react';
// Provider setup
function App() {
return (
<AppmintProvider
apiKey="your-api-key"
projectId="your-project-id"
>
<Dashboard />
</AppmintProvider>
);
}
// Using hooks
function Dashboard() {
const { user, login, logout } = useAuth();
const { data, loading, error } = useDatabase('posts', {
where: { published: true },
orderBy: { createdAt: 'desc' },
limit: 10
});
if (loading) return <div>Loading...</div>;
if (error) return <div>Error: {error.message}</div>;
return (
<div>
<h1>Welcome {user?.profile?.firstName}</h1>
{data.map(post => (
<article key={post.id}>
<h2>{post.title}</h2>
<p>{post.content}</p>
</article>
))}
</div>
);
}
Real-time Features
// Real-time subscriptions
const subscription = appmint.realtime
.collection('messages')
.where('chatId', '==', 'chat-123')
.onSnapshot((snapshot) => {
console.log('New messages:', snapshot.docs);
});
// Unsubscribe
subscription.unsubscribe();
// WebSocket connection
const socket = appmint.realtime.connect({
channels: ['chat:123', 'notifications'],
onMessage: (message) => {
console.log('Received:', message);
},
onError: (error) => {
console.error('WebSocket error:', error);
}
});
Python SDK
Installation
pip install appmint-sdk
# Or with optional dependencies
pip install appmint-sdk[async,redis,dev]
Quick Start
from appmint import Appmint
import asyncio
# Initialize client
appmint = Appmint(
api_key='your-api-key',
project_id='your-project-id'
)
# Synchronous usage
user = appmint.auth.create_user(
email='user@example.com',
password='secure-password',
profile={
'first_name': 'John',
'last_name': 'Doe'
}
)
# Store data
document = appmint.database.collection('posts').create({
'title': 'Hello Python',
'content': 'This is a Python post',
'author_id': user.id
})
print(f"Created post: {document.id}")
# Asynchronous usage
async def main():
async_client = appmint.async_client()
users = await async_client.database.collection('users').find({
'status': 'active'
})
print(f"Found {len(users)} active users")
asyncio.run(main())
Django Integration
# settings.py
APPMINT = {
'API_KEY': os.environ.get('APPMINT_API_KEY'),
'PROJECT_ID': os.environ.get('APPMINT_PROJECT_ID'),
'ENVIRONMENT': 'production'
}
# models.py
from django.db import models
from appmint.django import AppmintModel
class Post(AppmintModel):
title = models.CharField(max_length=200)
content = models.TextField()
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
# Automatically syncs with Appmint database
class Meta:
appmint_collection = 'posts'
appmint_sync = True
# views.py
from appmint.django import require_auth
@require_auth
def dashboard(request):
# User is automatically authenticated via Appmint
posts = request.user.posts.all()
return render(request, 'dashboard.html', {'posts': posts})
FastAPI Integration
from fastapi import FastAPI, Depends
from appmint.fastapi import get_current_user, AppmintAuth
app = FastAPI()
auth = AppmintAuth(api_key='your-api-key', project_id='your-project-id')
@app.get("/profile")
async def get_profile(current_user: dict = Depends(get_current_user)):
return {"user": current_user}
@app.post("/posts")
async def create_post(
post_data: dict,
current_user: dict = Depends(get_current_user)
):
post = await auth.client.database.collection('posts').create({
**post_data,
'author_id': current_user['id']
})
return post
Java SDK
Installation
<!-- Maven -->
<dependency>
<groupId>io.appmint</groupId>
<artifactId>appmint-java-sdk</artifactId>
<version>2.0.0</version>
</dependency>
// Gradle
implementation 'io.appmint:appmint-java-sdk:2.0.0'
// For Spring Boot integration
implementation 'io.appmint:appmint-spring-boot-starter:2.0.0'
Quick Start
import io.appmint.sdk.Appmint;
import io.appmint.sdk.auth.User;
import io.appmint.sdk.database.Document;
public class AppmintExample {
public static void main(String[] args) {
// Initialize client
Appmint appmint = Appmint.builder()
.apiKey("your-api-key")
.projectId("your-project-id")
.environment(Environment.PRODUCTION)
.build();
// Create user
User user = appmint.auth().createUser(
CreateUserRequest.builder()
.email("user@example.com")
.password("secure-password")
.profile(Map.of(
"firstName", "John",
"lastName", "Doe"
))
.build()
);
// Store data
Document document = appmint.database()
.collection("posts")
.create(Map.of(
"title", "Hello Java",
"content", "This is a Java post",
"authorId", user.getId()
));
System.out.println("Created post: " + document.getId());
}
}
Spring Boot Integration
// Configuration
@Configuration
@EnableAppmint
public class AppmintConfig {
@Bean
public AppmintProperties appmintProperties() {
return AppmintProperties.builder()
.apiKey("${appmint.api-key}")
.projectId("${appmint.project-id}")
.build();
}
}
// Service
@Service
public class PostService {
@Autowired
private AppmintClient appmintClient;
public List<Post> getPublishedPosts() {
return appmintClient.database()
.collection("posts")
.find(Query.where("published", true))
.stream()
.map(this::mapToPost)
.collect(Collectors.toList());
}
@AppmintAuth // Requires authenticated user
public Post createPost(Post post, User currentUser) {
Map<String, Object> data = Map.of(
"title", post.getTitle(),
"content", post.getContent(),
"authorId", currentUser.getId(),
"published", false
);
Document document = appmintClient.database()
.collection("posts")
.create(data);
return mapToPost(document);
}
}
// Controller
@RestController
@RequestMapping("/api/posts")
public class PostController {
@Autowired
private PostService postService;
@GetMapping
public List<Post> getPosts() {
return postService.getPublishedPosts();
}
@PostMapping
@AppmintAuth
public Post createPost(@RequestBody Post post, @CurrentUser User user) {
return postService.createPost(post, user);
}
}
Go SDK
Installation
go get github.com/appmint/go-sdk
Quick Start
package main
import (
"context"
"fmt"
"log"
"github.com/appmint/go-sdk"
)
func main() {
// Initialize client
client, err := appmint.NewClient(&appmint.Config{
APIKey: "your-api-key",
ProjectID: "your-project-id",
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
// Create user
user, err := client.Auth.CreateUser(ctx, &appmint.CreateUserRequest{
Email: "user@example.com",
Password: "secure-password",
Profile: map[string]interface{}{
"firstName": "John",
"lastName": "Doe",
},
})
if err != nil {
log.Fatal(err)
}
// Store data
doc, err := client.Database.Collection("posts").Create(ctx, map[string]interface{}{
"title": "Hello Go",
"content": "This is a Go post",
"authorId": user.ID,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Created post: %s\n", doc.ID)
}
Gin Integration
package main
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/appmint/go-sdk"
"github.com/appmint/go-sdk/middleware"
)
func main() {
// Initialize Appmint client
client, _ := appmint.NewClient(&appmint.Config{
APIKey: "your-api-key",
ProjectID: "your-project-id",
})
r := gin.Default()
// Add Appmint middleware
r.Use(middleware.AppmintAuth(client))
// Public route
r.GET("/posts", func(c *gin.Context) {
posts, err := client.Database.Collection("posts").Find(c, map[string]interface{}{
"published": true,
})
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusOK, posts)
})
// Protected route
r.POST("/posts", middleware.RequireAuth(), func(c *gin.Context) {
user := middleware.GetCurrentUser(c)
var postData map[string]interface{}
if err := c.ShouldBindJSON(&postData); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
postData["authorId"] = user.ID
postData["published"] = false
post, err := client.Database.Collection("posts").Create(c, postData)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
return
}
c.JSON(http.StatusCreated, post)
})
r.Run(":8080")
}
Mobile SDKs
iOS (Swift)
Installation
// Package.swift
dependencies: [
.package(url: "https://github.com/appmint/ios-sdk", from: "2.0.0")
]
# Podfile
pod 'AppmintSDK'
Quick Start
import AppmintSDK
class ViewController: UIViewController {
private var appmint: AppmintClient!
override func viewDidLoad() {
super.viewDidLoad()
// Initialize client
appmint = AppmintClient(
apiKey: "your-api-key",
projectId: "your-project-id"
)
setupAuth()
}
private func setupAuth() {
// Login user
Task {
do {
let user = try await appmint.auth.login(
email: "user@example.com",
password: "password"
)
print("Logged in user: \(user.id)")
await loadPosts()
} catch {
print("Login error: \(error)")
}
}
}
private func loadPosts() async {
do {
let posts = try await appmint.database
.collection("posts")
.where("published", isEqualTo: true)
.order(by: "createdAt", descending: true)
.limit(10)
.get()
await MainActor.run {
updateUI(with: posts)
}
} catch {
print("Error loading posts: \(error)")
}
}
}
// SwiftUI Integration
import SwiftUI
struct ContentView: View {
@StateObject private var auth = AppmintAuth()
@StateObject private var posts = PostStore()
var body: some View {
NavigationView {
if auth.isAuthenticated {
PostListView()
.environmentObject(posts)
} else {
LoginView()
.environmentObject(auth)
}
}
.onAppear {
auth.configure(
apiKey: "your-api-key",
projectId: "your-project-id"
)
}
}
}
Android (Kotlin)
Installation
// app/build.gradle
dependencies {
implementation 'io.appmint:android-sdk:2.0.0'
}
Quick Start
class MainActivity : AppCompatActivity() {
private lateinit var appmint: AppmintClient
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Initialize client
appmint = AppmintClient.Builder()
.apiKey("your-api-key")
.projectId("your-project-id")
.build()
setupAuth()
}
private fun setupAuth() {
lifecycleScope.launch {
try {
val user = appmint.auth.login(
email = "user@example.com",
password = "password"
)
Log.d("Auth", "Logged in user: ${user.id}")
loadPosts()
} catch (e: Exception) {
Log.e("Auth", "Login error", e)
}
}
}
private suspend fun loadPosts() {
try {
val posts = appmint.database
.collection("posts")
.where("published", "==", true)
.orderBy("createdAt", Query.Direction.DESCENDING)
.limit(10)
.get()
withContext(Dispatchers.Main) {
updateUI(posts)
}
} catch (e: Exception) {
Log.e("Posts", "Error loading posts", e)
}
}
}
// Jetpack Compose Integration
@Composable
fun PostScreen(viewModel: PostViewModel = hiltViewModel()) {
val posts by viewModel.posts.collectAsState()
val isLoading by viewModel.isLoading.collectAsState()
LaunchedEffect(Unit) {
viewModel.loadPosts()
}
LazyColumn {
items(posts) { post ->
PostCard(
post = post,
onLike = { viewModel.likePost(post.id) }
)
}
}
}
SDK Configuration & Best Practices
Environment Configuration
// Multi-environment setup
const getAppmintConfig = () => {
const env = process.env.NODE_ENV;
const configs = {
development: {
apiKey: process.env.APPMINT_DEV_API_KEY,
projectId: process.env.APPMINT_DEV_PROJECT_ID,
baseURL: 'https://dev-api.appmint.io',
debug: true
},
staging: {
apiKey: process.env.APPMINT_STAGING_API_KEY,
projectId: process.env.APPMINT_STAGING_PROJECT_ID,
baseURL: 'https://staging-api.appmint.io',
debug: false
},
production: {
apiKey: process.env.APPMINT_API_KEY,
projectId: process.env.APPMINT_PROJECT_ID,
baseURL: 'https://api.appmint.io',
debug: false
}
};
return configs[env] || configs.development;
};
const appmint = new Appmint(getAppmintConfig());
Error Handling
// Comprehensive error handling
try {
const user = await appmint.auth.createUser(userData);
} catch (error) {
if (error instanceof AppmintError) {
switch (error.code) {
case 'USER_EXISTS':
showError('User already exists');
break;
case 'INVALID_EMAIL':
showError('Please enter a valid email address');
break;
case 'WEAK_PASSWORD':
showError('Password must be at least 8 characters');
break;
case 'RATE_LIMIT_EXCEEDED':
showError('Too many requests. Please try again later.');
break;
default:
showError('An unexpected error occurred');
}
} else {
// Network or other errors
showError('Connection error. Please check your internet connection.');
}
}
// Global error handler
appmint.onError((error) => {
console.error('Appmint SDK Error:', error);
// Send to error tracking service
errorTracker.captureException(error);
// Show user-friendly message
if (error.code === 'AUTHENTICATION_EXPIRED') {
redirectToLogin();
}
});
Performance Optimization
// Caching configuration
const appmint = new Appmint({
apiKey: 'your-api-key',
projectId: 'your-project-id',
// Enable caching
cache: {
enabled: true,
ttl: 60 * 5, // 5 minutes
maxSize: 100 // Max 100 cached responses
},
// Request deduplication
dedupe: true,
// Batch requests
batch: {
enabled: true,
maxBatchSize: 10,
batchDelay: 50 // ms
}
});
// Use pagination for large datasets
const posts = await appmint.database
.collection('posts')
.limit(20)
.paginate();
// Implement infinite scroll
let cursor = null;
const loadMorePosts = async () => {
const result = await appmint.database
.collection('posts')
.limit(10)
.startAfter(cursor)
.get();
cursor = result.lastDoc;
return result.docs;
};
Testing & Development Tools
SDK Testing Utilities
// Testing with Jest
import { AppmintTestClient } from '@appmint/sdk/testing';
describe('User Service', () => {
let appmint: AppmintTestClient;
beforeEach(() => {
appmint = new AppmintTestClient();
});
test('should create user', async () => {
// Mock the API response
appmint.mock.auth.createUser.mockResolvedValue({
id: 'user-123',
email: 'test@example.com'
});
const user = await appmint.auth.createUser({
email: 'test@example.com',
password: 'password'
});
expect(user.id).toBe('user-123');
expect(appmint.mock.auth.createUser).toHaveBeenCalledWith({
email: 'test@example.com',
password: 'password'
});
});
});
Debug Mode
// Enable debug mode
const appmint = new Appmint({
apiKey: 'your-api-key',
projectId: 'your-project-id',
debug: true, // Enables detailed logging
// Custom logger
logger: {
log: (level, message, data) => {
console.log(`[${level.toUpperCase()}] ${message}`, data);
}
}
});
// Performance monitoring
appmint.onRequest((request) => {
console.time(`Request ${request.id}`);
});
appmint.onResponse((response) => {
console.timeEnd(`Request ${response.requestId}`);
});
SDK Migration & Updates
Version Migration Guide
// Migrating from v1 to v2
// Old v1 syntax
const appmint = new Appmint('api-key', 'project-id');
const user = await appmint.createUser(userData);
// New v2 syntax
const appmint = new Appmint({
apiKey: 'api-key',
projectId: 'project-id'
});
const user = await appmint.auth.createUser(userData);
// Migration helper
import { migrateFromV1 } from '@appmint/sdk/migrate';
const v2Client = migrateFromV1(v1Client);
Keeping SDKs Updated
# Check for updates
npm outdated @appmint/sdk
# Update to latest version
npm update @appmint/sdk
# Update to specific version
npm install @appmint/sdk@2.1.0
Community SDKs & Extensions
Community Contributions
Unofficial SDKs (Community Maintained):
- Dart/Flutter -
appmint_flutter
- React Native -
react-native-appmint
- Vue.js -
vue-appmint
- Svelte -
svelte-appmint
- Elixir/Phoenix -
appmint_ex
Contributing to SDKs
# Clone SDK repository
git clone https://github.com/appmint/javascript-sdk
# Install dependencies
npm install
# Run tests
npm test
# Build SDK
npm run build
# Submit pull request
Contribution Guidelines:
- Follow existing code style and conventions
- Add tests for new features
- Update documentation
- Ensure backward compatibility
- Add changelog entries
SDK Support & Resources
Getting Help
SDK Documentation:
- API Reference - Complete SDK method documentation
- Guides & Tutorials - Step-by-step implementation guides
- Examples Repository - Sample applications and code snippets
- Video Tutorials - Visual learning resources
Support Channels:
- GitHub Issues - Bug reports and feature requests
- Community Forum - Developer discussions and help
- Discord - Real-time developer chat
- Stack Overflow - Tag questions with
appmint
SDK Roadmap
Upcoming Features:
- Real-time subscriptions for all SDKs
- Offline-first capabilities
- Advanced caching strategies
- GraphQL client integration
- Edge computing support
Quick Reference
Installation Commands
# JavaScript/TypeScript
npm install @appmint/sdk
# Python
pip install appmint-sdk
# Java (Maven)
<dependency>
<groupId>io.appmint</groupId>
<artifactId>appmint-java-sdk</artifactId>
<version>2.0.0</version>
</dependency>
# Go
go get github.com/appmint/go-sdk
# PHP
composer require appmint/php-sdk
# Ruby
gem install appmint
Basic Usage Patterns
// Initialize
const appmint = new Appmint({ apiKey, projectId });
// Authentication
await appmint.auth.login(email, password);
// Database operations
await appmint.database.collection('posts').create(data);
await appmint.database.collection('posts').find(query);
// File operations
await appmint.storage.upload(file, path);
// Real-time
appmint.realtime.collection('messages').onSnapshot(callback);
Ready to start building with our SDKs? Choose your preferred language and dive into the comprehensive documentation and examples.