mtf-api
v0.1.0
Published
Monotype Fonts API NodeJS client
Downloads
11
Maintainers
Readme
Node.js client library for MTF API
📚 Documentation - 🚀 Getting Started - 💻 API Reference - 💬 Feedback
Documentation
- FAQs - frequently asked questions about mtf-api.
- Docs Site - explore our docs site and learn more about MTF API
Getting Started
Requirements
This library supports the following tooling versions:
- Node.js:
>=18.15.0
Installation
Using npm in your project directory run the following command:
npm install mtf-api
Configure the API Client
Initialize your client class with a refresh token.
Response type
With the exception of constructor, all methods return in comma ok pattern. Example:
const [value, err] = await mtf.someMethod(params)
if(err){
// something went wrong
}
// use value
const MtfClient = require('mtf-api');
const mtf = new MtfClient({
refreshToken: '{YOUR_API_V1_REFRESH_TOKEN}' // required
accessToken: '' // optional
scope: '' // optional
expiresAt: '' // optional
tokenType: '' // optional
});
Authorize
All requests will be authorized before API call if token has expired. Only necessary to force generate new access token.
Uses refreshToken
from the instance.
const [authData, err] = await mtf.authorize();
Fonts
const [fonts, err] = await mtf.fonts({
// options
})
Font Details
const [font, err] = await mtf.font(fontId, {
// options
})
Font Download
Does not support options, successful response is an object with downloadLink
const [download, downloadError] = await mtf.download(sampleFontId)
// download -> {downloadLink: URL}
For other examples see the EXAMPLES.md document.