Docs

REST API

2 min readUpdated October 28, 2026

The admin screens run on a REST API you can use too. It has 12 routes under the namespace nahnu-fonts/v1, for example https://example.com/wp-json/nahnu-fonts/v1/fonts.

Authentication#

Every route needs a user with the manage_options capability (change it with the nahnu_fonts_capability filter), and one of:

  • a REST nonce (X-WP-Nonce header) for requests from the WordPress admin, or
  • an application password for requests from outside.
curl -u admin:"xxxx xxxx xxxx xxxx xxxx xxxx" \
  https://example.com/wp-json/nahnu-fonts/v1/fonts

Routes#

MethodRouteBody or queryDoes
GET/fontssearch, sourceThe library, admin preview CSS and build info
GET/fonts/{id}noneOne font (stored and public shape)
POST/fonts/{id}name, fallback, active, selector, preload[], remove_faces[]Update a font
DELETE/fonts/{id}noneDelete a font and its files
POST/fonts/{id}/redownloadnoneDownload a Google font again through the current source
GET/catalogrefreshThe Google Fonts list from the chosen source
POST/googlefamily, weights[], italic, subsets[], variableDownload and self-host a family
POST/custommultipart: name, fallback, id, faces (JSON), filesUpload custom font files. Pass id to add to an existing family
POST/adobeproject_idConnect an Adobe Fonts project
DELETE/adobenoneDisconnect it
GET, POST/settingssettingsRead or save settings
POST/rebuildnoneRebuild the stylesheet
POST/importmultipart: fileImport an export .zip
GET/jooosinoneWhat Jooosi Fon data exists to move
POST/jooosi/migratenoneMove fonts and settings from Jooosi Fon

Export#

Export isn’t a REST route, because it streams a file. Use:

wp-admin/admin-post.php?action=nahnu_fonts_export&_wpnonce=...[&fonts=inter,lora]

The nonce comes from wp_create_nonce( 'nahnu_fonts_export' ). Leave out fonts to export everything. From the command line, wp nahnu-fonts export is easier.

Example: add a Google Font#

curl -u admin:"xxxx xxxx xxxx xxxx xxxx xxxx" \
  -H "Content-Type: application/json" \
  -d '{"family":"Inter","weights":["400","700"],"italic":false,"subsets":["latin"]}' \
  https://example.com/wp-json/nahnu-fonts/v1/google

Errors#

Errors are standard WordPress REST errors with a code, a readable message and an HTTP status, for example 400 for bad input or 404 for an unknown font. Every error also fires the nahnu_fonts_rest_error action, handy for logging.

Adding routes#

Use the nahnu_fonts_rest_routes filter to add or change routes in the same namespace, with the same permission check. See Hooks.