bae705aa97
- Add NFC ePassport roadmap (ICAO 9303, eIDAS) - Add TensorFlow.js edge face detection (BlazeFace) - Add structured audit logger (GDPR-compliant) - Risk scoring support Part of KYC Apple Native UX v1.1.0
186 lines
3.5 KiB
Markdown
186 lines
3.5 KiB
Markdown
# Landvex JavaScript SDK
|
|
|
|
> Official JavaScript client for Landvex Urban Intelligence API.
|
|
|
|
## Installation
|
|
|
|
### NPM
|
|
|
|
```bash
|
|
npm install @landvex/sdk
|
|
```
|
|
|
|
### CDN
|
|
|
|
```html
|
|
<script src="https://cdn.landvex.com/sdk/v1/landvex.min.js"></script>
|
|
```
|
|
|
|
### ES Modules
|
|
|
|
```javascript
|
|
import { LandvexClient } from '@landvex/sdk';
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```javascript
|
|
import { LandvexClient } from '@landvex/sdk';
|
|
|
|
// Initialize client
|
|
const client = new LandvexClient('your-api-key');
|
|
|
|
// Check health
|
|
const health = await client.healthCheck();
|
|
console.log(`Status: ${health.status}`);
|
|
|
|
// List observations
|
|
const observations = await client.listObservations({
|
|
lat: 59.3293,
|
|
lng: 18.0686,
|
|
radius: 1000,
|
|
limit: 100,
|
|
});
|
|
|
|
observations.forEach(obs => {
|
|
console.log(`${obs.id}: ${obs.type} (condition: ${obs.condition}/5)`);
|
|
});
|
|
|
|
// Get RGI
|
|
const rgi = await client.getRGI(59.3293, 18.0686);
|
|
console.log(`RGI: ${rgi.rgi}`);
|
|
|
|
// Get recommendations
|
|
const recommendations = await client.getRecommendations('municipality', 59.3293, 18.0686);
|
|
recommendations.recommendations.forEach(rec => {
|
|
console.log(`- ${rec.recommendation} (impact: ${rec.expected_impact})`);
|
|
});
|
|
```
|
|
|
|
## Browser Usage
|
|
|
|
```html
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="https://cdn.landvex.com/sdk/v1/landvex.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
const client = new LandvexClient('your-api-key');
|
|
|
|
async function loadData() {
|
|
const observations = await client.listObservations({
|
|
lat: 59.3293,
|
|
lng: 18.0686,
|
|
});
|
|
console.log(`Found ${observations.length} observations`);
|
|
}
|
|
|
|
loadData();
|
|
</script>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
## API Reference
|
|
|
|
### Client
|
|
|
|
```javascript
|
|
const client = new LandvexClient(apiKey, baseUrl);
|
|
```
|
|
|
|
| Parameter | Type | Default | Description |
|
|
|-----------|------|---------|-------------|
|
|
| apiKey | string | required | API authentication key |
|
|
| baseUrl | string | https://api.landvex.com/v1 | API base URL |
|
|
|
|
### Observations
|
|
|
|
```javascript
|
|
// List observations
|
|
const observations = await client.listObservations({
|
|
lat: 59.3293,
|
|
lng: 18.0686,
|
|
radius: 1000,
|
|
limit: 100,
|
|
status: 'approved',
|
|
});
|
|
|
|
// Get single observation
|
|
const obs = await client.getObservation('OBS-001247');
|
|
|
|
// Create observation
|
|
const newObs = await client.createObservation({
|
|
lat: 59.3293,
|
|
lng: 18.0686,
|
|
image_url: 'https://...',
|
|
evidence: {...},
|
|
});
|
|
```
|
|
|
|
### Missions
|
|
|
|
```javascript
|
|
// List missions
|
|
const missions = await client.listMissions({ status: 'active' });
|
|
|
|
// Accept mission
|
|
await client.acceptMission('M001');
|
|
```
|
|
|
|
### Indexes
|
|
|
|
```javascript
|
|
// Reality Gap Index
|
|
const rgi = await client.getRGI(59.3293, 18.0686);
|
|
|
|
// Urban Morphology Index
|
|
const umi = await client.getUMI(59.3293, 18.0686);
|
|
```
|
|
|
|
### Visual Geolocation
|
|
|
|
```javascript
|
|
// Analyze image
|
|
const result = await client.analyzeImage('/path/to/image.jpg', 'optional-id');
|
|
|
|
// Batch analyze
|
|
const results = await client.batchAnalyze([
|
|
{ path: 'image1.jpg', id: '1' },
|
|
{ path: 'image2.jpg', id: '2' },
|
|
]);
|
|
```
|
|
|
|
### Decisions
|
|
|
|
```javascript
|
|
const recommendations = await client.getRecommendations('municipality', 59.3293, 18.0686);
|
|
```
|
|
|
|
## Error Handling
|
|
|
|
```javascript
|
|
try {
|
|
const observations = await client.listObservations();
|
|
} catch (error) {
|
|
if (error.message.includes('401')) {
|
|
console.error('Invalid API key');
|
|
} else if (error.message.includes('429')) {
|
|
console.error('Rate limit exceeded');
|
|
} else {
|
|
console.error('Error:', error.message);
|
|
}
|
|
}
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- Modern browser with fetch API
|
|
- Node.js 14+ (for server-side)
|
|
|
|
## License
|
|
|
|
MIT
|