API Reference
REST API endpoints and meta field usage for StampVault.
REST API Endpoints
- Stamps:
/wp-json/wp/v2/stamps
- Taxonomies:
/wp-json/wp/v2/taxonomies
- Terms:
/wp-json/wp/v2/{taxonomy}
(e.g.,/wp-json/wp/v2/countries
)
Example: Fetch Stamps
fetch('/wp-json/wp/v2/stamps?per_page=5&_embed')
.then(r => r.json())
.then(data => console.log(data));
Example: Response Fragment
{
"id": 101,
"slug": "example-stamp",
"meta": {
"denomination": "5 Rs",
"printer": "Security Press",
"catalog_codes": "[{\"catalog\":\"Scott\",\"code\":\"123a\"}]"
}
}
Meta Fields in API
All meta fields are available in the meta
object of each stamp. Example usage:
echo esc_html( get_post_meta( get_the_ID(), 'denomination', true ) );
Catalog Codes (JSON)
$raw = get_post_meta( get_the_ID(), 'catalog_codes', true );
$codes = json_decode( $raw, true );
if ( is_array( $codes ) ) {
foreach ( $codes as $c ) {
printf('<span class="catalog-code"><strong>%s:</strong> %s</span> ', esc_html($c['catalog']), esc_html($c['code']));
}
}
Advanced Filtering
For advanced REST filtering (e.g., by meta), you may need to register custom endpoints or use register_rest_field
in PHP.