129 lines
2.2 KiB
Markdown
129 lines
2.2 KiB
Markdown
|
|
# HST Image Server API
|
||
|
|
|
||
|
|
## Base URL
|
||
|
|
|
||
|
|
```
|
||
|
|
https://tzrtech.org
|
||
|
|
```
|
||
|
|
|
||
|
|
## Endpoints
|
||
|
|
|
||
|
|
### GET /api/index.json
|
||
|
|
|
||
|
|
Returns all tables with their records.
|
||
|
|
|
||
|
|
**Response:**
|
||
|
|
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"_meta": {
|
||
|
|
"version": "1.1",
|
||
|
|
"updated": "2024-12-17T12:00:00Z",
|
||
|
|
"base_url": "https://tzrtech.org",
|
||
|
|
"image_url_pattern": "https://tzrtech.org/{mrf}.png",
|
||
|
|
"subdomain_pattern": "https://{ref}_{nombre}.tzrtech.org",
|
||
|
|
"tables": ["flg", "hst", "spe", "vue", "vsn"]
|
||
|
|
},
|
||
|
|
"hst": {
|
||
|
|
"count": 150,
|
||
|
|
"records": [
|
||
|
|
{
|
||
|
|
"ref": "ABC",
|
||
|
|
"nombre_es": "Nombre en español",
|
||
|
|
"nombre_en": "Name in English",
|
||
|
|
"mrf": "sha256hash...",
|
||
|
|
"rootref": "XYZ"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"flg": { ... },
|
||
|
|
"spe": { ... },
|
||
|
|
"vue": { ... },
|
||
|
|
"vsn": { ... }
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
## Image Access
|
||
|
|
|
||
|
|
### Direct URL
|
||
|
|
|
||
|
|
```
|
||
|
|
https://tzrtech.org/{mrf}.png
|
||
|
|
```
|
||
|
|
|
||
|
|
Example:
|
||
|
|
```
|
||
|
|
https://tzrtech.org/a1b2c3d4e5f6...png
|
||
|
|
```
|
||
|
|
|
||
|
|
### Subdomain URL
|
||
|
|
|
||
|
|
```
|
||
|
|
https://{ref}_{nombre}.tzrtech.org
|
||
|
|
```
|
||
|
|
|
||
|
|
Example:
|
||
|
|
```
|
||
|
|
https://crg_courage.tzrtech.org
|
||
|
|
```
|
||
|
|
|
||
|
|
This redirects to the direct image URL.
|
||
|
|
|
||
|
|
## Tables
|
||
|
|
|
||
|
|
| Table | Description |
|
||
|
|
|-------|-------------|
|
||
|
|
| `hst` | Hashtags - main semantic tags |
|
||
|
|
| `spe` | Specs - specifications |
|
||
|
|
| `flg` | Flags - status indicators |
|
||
|
|
| `vue` | Values - human values |
|
||
|
|
| `vsn` | Visions - archetypal visions |
|
||
|
|
|
||
|
|
## Record Schema
|
||
|
|
|
||
|
|
| Field | Type | Description |
|
||
|
|
|-------|------|-------------|
|
||
|
|
| `ref` | string | 3-letter unique code |
|
||
|
|
| `nombre_es` | string | Spanish name |
|
||
|
|
| `nombre_en` | string | English name |
|
||
|
|
| `mrf` | string | SHA-256 hash of image file |
|
||
|
|
| `rootref` | string | Parent reference (hierarchy) |
|
||
|
|
|
||
|
|
## Usage Examples
|
||
|
|
|
||
|
|
### JavaScript
|
||
|
|
|
||
|
|
```javascript
|
||
|
|
const response = await fetch('https://tzrtech.org/api/index.json');
|
||
|
|
const data = await response.json();
|
||
|
|
|
||
|
|
// Get all values
|
||
|
|
const values = data.vue.records;
|
||
|
|
|
||
|
|
// Build image URL
|
||
|
|
const imageUrl = `https://tzrtech.org/${values[0].mrf}.png`;
|
||
|
|
```
|
||
|
|
|
||
|
|
### Python
|
||
|
|
|
||
|
|
```python
|
||
|
|
import requests
|
||
|
|
|
||
|
|
response = requests.get('https://tzrtech.org/api/index.json')
|
||
|
|
data = response.json()
|
||
|
|
|
||
|
|
# Get all hashtags
|
||
|
|
hashtags = data['hst']['records']
|
||
|
|
|
||
|
|
# Build image URL
|
||
|
|
image_url = f"https://tzrtech.org/{hashtags[0]['mrf']}.png"
|
||
|
|
```
|
||
|
|
|
||
|
|
## CORS
|
||
|
|
|
||
|
|
The API allows cross-origin requests:
|
||
|
|
|
||
|
|
```
|
||
|
|
Access-Control-Allow-Origin: *
|
||
|
|
```
|