Skip to content

Commit

Permalink
docs(api): add variable stats and version api docs (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Apr 12, 2024
1 parent 9f95fb5 commit 6c6774f
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 16 deletions.
57 changes: 57 additions & 0 deletions website/docs/api/axis-registry.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Axis Registry
section: Reference
---

## Axis Registry

---

The Axis Registry endpoint gives detailed descriptions of variable axis tags and their corresponding values.

### HTTP Request

- `GET https://api.fontsource.org/v1/axis-registry`

### Response

The API response for the Fontlist endpoint is a JSON object.

#### Attributes:

Returns an object of:

| Attribute | Type | Description |
| --------- | -------------------------------------- | --------------- |
| [tag] | Record<string, AxisRegistryItem> | Axis tag object |

<br />

**AxisRegistryItem:**


| Attribute | Type | Description |
| ----------- | ------ | ------------------------------- |
| name | string | Axis name |
| description | string | Axis description |
| min | number | Minimum value possible for axis |
| max | number | Maximum value possible for axis |
| default | number | Default value for axis |
| precision | number | Precision |

#### Response example:

```json
{
...
"ARRR":{
"name":"AR Retinal Resolution",
"description":"Resolution-specific enhancements in AR/VR typefaces to optimize rendering across the different resolutions of the headsets making designs accessible and easy to read.",
"min":10,
"max":60,
"default":10,
"precision":0
},
...
}
```
7 changes: 4 additions & 3 deletions website/docs/api/font-id.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Variants is an object that creates records starting with `weight`, `style`, `sub
"normal": {
"latin": {
"url": {
"woff2": "https://cdn.jsdelivr.net/npm/@fontsource/abel/files/abel-latin-400-normal.woff2",
"woff": "https://cdn.jsdelivr.net/npm/@fontsource/abel/files/abel-latin-400-normal.woff",
"ttf": "https://api.fontsource.org/v1/fonts/abel/latin-400-normal.ttf"
"woff2": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.woff2",
"woff": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.woff",
"ttf": "https://cdn.jsdelivr.net/fontsource/fonts/abel@latest/latin-400-normal.ttf"
}
}
}
Expand All @@ -77,3 +77,4 @@ Variants is an object that creates records starting with `weight`, `style`, `sub
#### Example:

- `GET https://api.fontsource.org/v1/fonts/abel`
- `GET https://api.fontsource.org/v1/fonts/open-sans`
4 changes: 2 additions & 2 deletions website/docs/api/fontlist.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ The Fontlist API supports the following queries without values:

#### Example:

- `GET https://api.fontsource.org/fontlist?family)`
- `GET https://api.fontsource.org/fontlist?subsets)`
- `GET https://api.fontsource.org/fontlist?family`
- `GET https://api.fontsource.org/fontlist?subsets`
- `GET https://api.fontsource.org/fontlist?lastModified`

> **Note:** You cannot query for multiple properties at once.
2 changes: 1 addition & 1 deletion website/docs/api/fonts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The Fonts endpoint provides an array of individual font objects.

### HTTP Request

- `GET [https://api.fontsource.org/v1/fonts](https://api.fontsource.org/v1/fonts)`
- `GET https://api.fontsource.org/v1/fonts`
- `GET https://api.fontsource.org/v1/fonts?{query}`

### Response
Expand Down
2 changes: 1 addition & 1 deletion website/docs/api/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ The Fontsource API is a read-only API that can be accessed by any HTTP client. A
### Limits

- We reserve the right to add more properties to objects, but will never change or remove them.
- While the intention is not to throttle the API, we reserve the right to do so if necessary under fair use. The current hard limit is 2500 requests per 10 seconds.
- While the intention is not to throttle the API, we reserve the right to do so if necessary under fair use. The current hard limit is 2500 requests per 10 seconds but constant usage at this rate can result in a temporary ban.
70 changes: 70 additions & 0 deletions website/docs/api/stats.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Stats
section: Reference
---

## Stats

---

The Stats endpoint provides download statistics for each font.

### HTTP Request

- `GET https://api.fontsource.org/v1/stats/{id}`

### Response

The API response for the Stats endpoint is a JSON object that provides download statistics for each font.

#### Attributes:

Returns an object with:

| Attribute | Type | Description |
| --------- | ----------------------------- | ------------------------ |
| total | DownloadStats | Total download counts |
| static | DownloadStats | Static download counts |
| variable | Optional&lt;DownloadStats&gt; | Variable download counts |

<br />


**DownloadStats:**

| Attribute | Type | Description |
| ------------------- | ------ | -------------------------- |
| npmDownloadTotal | number | Total NPM download count |
| npmDownloadMonthly | number | Monthly NPM download count |
| jsDelivrHitsTotal | number | Total jsDelivr hits |
| jsDelivrHitsMonthly | number | Monthly jsDelivr hits |

#### Response example:

```json
{
"total":{
"npmDownloadTotal":8566215,
"npmDownloadMonthly":731202,
"jsDelivrHitsTotal":46488758,
"jsDelivrHitsMonthly":8210654
},
"static":{
"npmDownloadTotal":8288204,
"npmDownloadMonthly":637495,
"jsDelivrHitsTotal":46483427,
"jsDelivrHitsMonthly":8207141
},
"variable":{
"npmDownloadTotal":278011,
"npmDownloadMonthly":93707,
"jsDelivrHitsTotal":5331,
"jsDelivrHitsMonthly":3513
}
}
```

#### Example:

- `GET https://api.fontsource.org/v1/stats/abel`
- `GET https://api.fontsource.org/v1/stats/open-sans`
66 changes: 66 additions & 0 deletions website/docs/api/variable.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Variable
section: Reference
---

## Variable

---

The Variable endpoint allows you get specific axis data for a variable font.

### HTTP Request

- `GET https://api.fontsource.org/v1/variable/{id}`

### Response

The API response for the Variable endpoint is a JSON object that provides axis data for a variable font.

#### Attributes:

Returns an object with:

| Attribute | Type | Description |
| --------- | ------------------------------ | ----------- |
| family | string | Font family |
| axes | Record&lt;string, AxesData&gt; | Axis data |

<br />

**AxesData:**

| Attribute | Type | Description |
| --------- | ------ | ------------- |
| default | number | Default value |
| min | number | Minimum value |
| max | number | Maximum value |
| step | number | Step value |

#### Response example:

```json
{
"axes": {
"slnt": {
"default": "0",
"min": "-10",
"max": "0",
"step": "1"
},
"wght": {
"default": "400",
"min": "100",
"max": "900",
"step": "1"
}
},
"family": "Inter"
}
```

#### Example:

- `GET https://api.fontsource.org/v1/variable/inter`
- `GET https://api.fontsource.org/v1/variable/roboto-flex`
- `GET https://api.fontsource.org/v1/variable/wavefont`
67 changes: 67 additions & 0 deletions website/docs/api/version.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Version
section: Reference
---

## Version

---

The Version endpoint provides NPM version information for each package.

### HTTP Request

- `GET https://api.fontsource.org/v1/version/{id}`

### Response

The API response for the Version endpoint is a JSON object that provides NPM version information for each package.

#### Attributes:

Returns an object with:

| Attribute | Type | Description |
| -------------- | ------------------------ | --------------------------------------------- |
| latest | string | Latest static NPM version |
| static | string[] | Static NPM versions sorted newest to oldest |
| latestVariable | Optional&lt;string&gt; | Latest variable NPM version |
| variable | Optional&lt;string[]&gt; | Variable NPM versions sorted newest to oldest |

#### Response example:

```json
{
"latest": "5.0.4",
"static": [
"5.0.4",
"5.0.3",
"5.0.2",
"5.0.1",
"5.0.0",
"4.2.2",
"4.2.1",
"4.2.0",
"4.1.1",
"4.1.0",
"4.0.1",
"4.0.0"
],
"latestVariable": "5.0.7",
"variable": [
"5.0.7",
"5.0.6",
"5.0.5",
"5.0.4",
"5.0.3",
"5.0.2",
"5.0.1",
"5.0.0"
]
}
```

#### Example:

- `GET https://api.fontsource.org/v1/version/abel`
- `GET https://api.fontsource.org/v1/version/open-sans`
8 changes: 0 additions & 8 deletions website/docs/getting-started/subsets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,3 @@ import "@fontsource/open-sans/greek-700-italic.css";
This is not available for variable fonts.

> **Note:** We do not recommend using this method unless you have a specific reason to do so. The default CSS utilises the `unicode-range` property to only load the characters that are used on the page, which is more efficient than manually loading subsets.
### Unsupported Fonts

Due to NPM package size limitations, the following packages do not support this feature:

####

- `@fontsource/noto-serif-hk`
6 changes: 5 additions & 1 deletion website/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@
"introduction": "Introduction"
},
"Reference": {
"axis-registry": "Axis Registry",
"fontlist": "Fontlist",
"fonts": "Fonts",
"font-id": "Font ID",
"fonts": "Fonts"
"stats": "Stats",
"variable": "Variable",
"version": "Version"
}
}
}

0 comments on commit 6c6774f

Please sign in to comment.