@unavatar/core 3.32.12 → 3.32.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
1
|
## Table of Contents
|
|
4
2
|
|
|
5
3
|
- [Introduction](#introduction)
|
|
@@ -8,11 +6,15 @@
|
|
|
8
6
|
- [How to add attribution](#how-to-add-attribution)
|
|
9
7
|
- [Remove attribution](#remove-attribution)
|
|
10
8
|
- [Authentication](#authentication)
|
|
9
|
+
- [Secret keys](#secret-keys)
|
|
10
|
+
- [Publishable keys](#publishable-keys)
|
|
11
|
+
- [Domain restrictions](#domain-restrictions)
|
|
11
12
|
- [Pricing](#pricing)
|
|
12
13
|
- [Cache](#cache)
|
|
13
14
|
- [Query parameters](#query-parameters)
|
|
14
15
|
- [TTL](#ttl)
|
|
15
16
|
- [Fallback](#fallback)
|
|
17
|
+
- [Token](#token)
|
|
16
18
|
- [JSON](#json)
|
|
17
19
|
- [Providers](#providers)
|
|
18
20
|
- [Apple Music](#apple-music)
|
|
@@ -76,7 +78,9 @@
|
|
|
76
78
|
|
|
77
79
|
---
|
|
78
80
|
|
|
79
|
-
Last updated on May
|
|
81
|
+
Last updated on May 13, 2026
|
|
82
|
+
|
|
83
|
+

|
|
80
84
|
|
|
81
85
|
## Introduction
|
|
82
86
|
|
|
@@ -168,6 +172,10 @@ Anonymous requests work without authentication. They are limited to 25 requests/
|
|
|
168
172
|
|
|
169
173
|
For [PRO](https://unavatar.io/checkout) users, the requests must include the API key as the `x-api-key` request header:
|
|
170
174
|
|
|
175
|
+
```html
|
|
176
|
+

|
|
177
|
+
```
|
|
178
|
+
|
|
171
179
|
```bash
|
|
172
180
|
curl "https://unavatar.io/github/kikobeats" -H "x-api-key: YOUR_API_KEY"
|
|
173
181
|
```
|
|
@@ -268,6 +276,116 @@ x-rate-limit-remaining: 24
|
|
|
268
276
|
x-rate-limit-reset: 1744243200
|
|
269
277
|
```
|
|
270
278
|
|
|
279
|
+
### Secret keys
|
|
280
|
+
|
|
281
|
+
Secret keys (`sk_`) are meant for server-side use only — never expose them publicly. They provide full access to all API operations: avatar lookups, key management, usage data, and billing.
|
|
282
|
+
|
|
283
|
+
Pass them via the `x-api-key` header:
|
|
284
|
+
|
|
285
|
+
```html
|
|
286
|
+

|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
curl "https://unavatar.io/github/kikobeats" -H "x-api-key: sk_YOUR_SECRET_KEY"
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
await fetch('https://unavatar.io/github/kikobeats', {
|
|
295
|
+
|
|
296
|
+
headers: {
|
|
297
|
+
|
|
298
|
+
'x-api-key': 'sk_YOUR_SECRET_KEY'
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
})
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
import requests
|
|
307
|
+
|
|
308
|
+
response = requests.get(
|
|
309
|
+
|
|
310
|
+
'https://unavatar.io/github/kikobeats',
|
|
311
|
+
|
|
312
|
+
headers={'x-api-key': 'sk_YOUR_SECRET_KEY'}
|
|
313
|
+
|
|
314
|
+
)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
```golang
|
|
318
|
+
package main
|
|
319
|
+
|
|
320
|
+
import "net/http"
|
|
321
|
+
|
|
322
|
+
func main() {
|
|
323
|
+
|
|
324
|
+
req, _ := http.NewRequest("GET", "https://unavatar.io/github/kikobeats", nil)
|
|
325
|
+
|
|
326
|
+
req.Header.Set("x-api-key", "sk_YOUR_SECRET_KEY")
|
|
327
|
+
|
|
328
|
+
resp, _ := http.DefaultClient.Do(req)
|
|
329
|
+
|
|
330
|
+
defer resp.Body.Close()
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
require 'net/http'
|
|
337
|
+
|
|
338
|
+
require 'uri'
|
|
339
|
+
|
|
340
|
+
uri = URI('https://unavatar.io/github/kikobeats')
|
|
341
|
+
|
|
342
|
+
request = Net::HTTP::Get.new(uri)
|
|
343
|
+
|
|
344
|
+
request['x-api-key'] = 'sk_YOUR_SECRET_KEY'
|
|
345
|
+
|
|
346
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
347
|
+
|
|
348
|
+
http.request(request)
|
|
349
|
+
|
|
350
|
+
end
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
```php
|
|
354
|
+
$ch = curl_init('https://unavatar.io/github/kikobeats');
|
|
355
|
+
|
|
356
|
+
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
357
|
+
|
|
358
|
+
'x-api-key: sk_YOUR_SECRET_KEY',
|
|
359
|
+
|
|
360
|
+
]);
|
|
361
|
+
|
|
362
|
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
363
|
+
|
|
364
|
+
$response = curl_exec($ch);
|
|
365
|
+
|
|
366
|
+
curl_close($ch);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Publishable keys
|
|
370
|
+
|
|
371
|
+
Publishable keys (`pk_`) are safe to use in client-side code. They can **only** fetch avatars — any attempt to call management endpoints (key add/remove/rotate, usage, billing) returns an error.
|
|
372
|
+
|
|
373
|
+
Pass them as a `token` query parameter, which makes them easy to use directly in HTML markup:
|
|
374
|
+
|
|
375
|
+
```html
|
|
376
|
+

|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Domain restrictions
|
|
380
|
+
|
|
381
|
+
Publishable keys support optional domain restrictions to prevent unauthorized use. When domain restrictions are configured, requests with that publishable key are only accepted from matching `Origin` or `Referer` domains.
|
|
382
|
+
|
|
383
|
+
Domains can be managed from the [dashboard](https://unavatar.io/dashboard?tab=credentials). Valid values include:
|
|
384
|
+
|
|
385
|
+
- `example.com` — exact domain match
|
|
386
|
+
- `*.example.com` — all subdomains of example.com
|
|
387
|
+
- `app.example.com` — a specific subdomain
|
|
388
|
+
|
|
271
389
|
## Pricing
|
|
272
390
|
|
|
273
391
|
Unavatar pricing is simple: you can start on the anonymous free tier, then authenticate with `x-api-key` to get additional included usage and metered billing for higher volume.
|
|
@@ -291,7 +409,7 @@ Every request has a cost in tokens (**\$0.005 per token**) based on the proxy ti
|
|
|
291
409
|
The proxy tier used is returned in the `x-proxy-tier` response header, and the total cost in the `x-unavatar-cost` header.
|
|
292
410
|
|
|
293
411
|
```bash
|
|
294
|
-
$ curl -I -H "x-api-key:
|
|
412
|
+
$ curl -I -H "x-api-key: sk_YOUR_SECRET_KEY" https://unavatar.io/instagram/kikobeats
|
|
295
413
|
|
|
296
414
|
x-pricing-tier: pro
|
|
297
415
|
|
|
@@ -327,7 +445,7 @@ To check the cache status in real requests, inspect these response headers:
|
|
|
327
445
|
| `cache-control` | Shows cache policy and effective TTL (for example `public, max-age=3600` for `ttl=1h`). |
|
|
328
446
|
|
|
329
447
|
```bash
|
|
330
|
-
$ curl -I -H "x-api-key:
|
|
448
|
+
$ curl -I -H "x-api-key: sk_YOUR_SECRET_KEY" "https://unavatar.io/github/kikobeats?ttl=1h"
|
|
331
449
|
|
|
332
450
|
cache-control: public, max-age=3600
|
|
333
451
|
|
|
@@ -378,6 +496,16 @@ e.g., [unavatar.io/github/37t?fallback=data:image/gif;base64,R0lGODlhAQABAIAAAP/
|
|
|
378
496
|
|
|
379
497
|
You can pass `fallback=false` to explicitly disable this behavior. In this case, a *404 Not Found* HTTP status code will returned when is not possible to get the user avatar.
|
|
380
498
|
|
|
499
|
+
### Token
|
|
500
|
+
|
|
501
|
+
Type: `string`
|
|
502
|
+
|
|
503
|
+
Authenticates the request with a [publishable key](https://unavatar.io/docs#publishable-keys). This is an alternative to the `x-api-key` header, designed for contexts where headers cannot be set (e.g., `<img>` tags).
|
|
504
|
+
|
|
505
|
+
e.g., [unavatar.io/github/kikobeats?token=pk_YOUR_PUBLISHABLE_KEY](https://unavatar.io/github/kikobeats?token=pk_YOUR_PUBLISHABLE_KEY)
|
|
506
|
+
|
|
507
|
+
Secret keys (`sk_`) also work as a `token` value, but should only be passed via the `x-api-key` header to avoid exposing them in URLs.
|
|
508
|
+
|
|
381
509
|
### JSON
|
|
382
510
|
|
|
383
511
|
The service returns media content by default.
|
|
@@ -879,7 +1007,7 @@ These headers help you understand pricing, limits, and request diagnostics.
|
|
|
879
1007
|
| `retry-after` | Seconds until rate limit resets (only on 429 responses) |
|
|
880
1008
|
|
|
881
1009
|
```bash
|
|
882
|
-
$ curl -I -H "x-api-key:
|
|
1010
|
+
$ curl -I -H "x-api-key: sk_YOUR_SECRET_KEY" https://unavatar.io/github/kikobeats
|
|
883
1011
|
|
|
884
1012
|
x-pricing-tier: pro
|
|
885
1013
|
|
|
@@ -908,28 +1036,34 @@ Expected errors are known operational cases returned with stable codes.
|
|
|
908
1036
|
- `more` links to documentation for common fixes.
|
|
909
1037
|
- `report` (when present) indicates how to contact support for server errors.
|
|
910
1038
|
|
|
911
|
-
| HTTP | Code | Typical trigger
|
|
912
|
-
| ---- | -------------------- |
|
|
913
|
-
| 400 | `ESESSIONID` | Missing `session_id` in `/checkout/success`
|
|
914
|
-
| 400 | `ESESSION` | Checkout session not paid or not found
|
|
915
|
-
| 400 | `ESIGNATURE` | Missing `stripe-signature` header
|
|
916
|
-
| 400 | `EWEBHOOK` | Invalid/failed Stripe webhook processing
|
|
917
|
-
| 400 | `EAPIKEYVALUE` | Missing `apiKey` query parameter
|
|
918
|
-
| 400 | `EAPIKEYLABEL` | Missing `label` query parameter
|
|
919
|
-
|
|
|
920
|
-
|
|
|
921
|
-
|
|
|
922
|
-
|
|
|
923
|
-
|
|
|
924
|
-
|
|
|
925
|
-
|
|
|
926
|
-
|
|
|
927
|
-
|
|
|
928
|
-
|
|
|
929
|
-
|
|
|
930
|
-
|
|
|
931
|
-
|
|
|
932
|
-
|
|
|
1039
|
+
| HTTP | Code | Typical trigger |
|
|
1040
|
+
| ---- | -------------------- | ------------------------------------------------------- |
|
|
1041
|
+
| 400 | `ESESSIONID` | Missing `session_id` in `/checkout/success` |
|
|
1042
|
+
| 400 | `ESESSION` | Checkout session not paid or not found |
|
|
1043
|
+
| 400 | `ESIGNATURE` | Missing `stripe-signature` header |
|
|
1044
|
+
| 400 | `EWEBHOOK` | Invalid/failed Stripe webhook processing |
|
|
1045
|
+
| 400 | `EAPIKEYVALUE` | Missing `apiKey` query parameter |
|
|
1046
|
+
| 400 | `EAPIKEYLABEL` | Missing `label` query parameter |
|
|
1047
|
+
| 400 | `EAUTOROUTE` | `/:key` used with a username instead of email/domain |
|
|
1048
|
+
| 400 | `EPKREMOVE` | Attempted to remove a publishable key directly |
|
|
1049
|
+
| 400 | `EPKUPDATE` | Attempted to update a publishable key directly |
|
|
1050
|
+
| 400 | `EPKINVALID` | Publishable key does not start with `pk_` |
|
|
1051
|
+
| 401 | `EEMAIL` | Invalid or missing authenticated email |
|
|
1052
|
+
| 401 | `EUSERUNAUTHORIZED` | Missing/invalid auth for protected routes |
|
|
1053
|
+
| 401 | `EAPIKEY` | Invalid API key via header or `?token` query param |
|
|
1054
|
+
| 403 | `ETTL` | Custom `ttl` requested without pro plan |
|
|
1055
|
+
| 403 | `EPRO` | Provider restricted to pro plan |
|
|
1056
|
+
| 403 | `EPKNOTALLOWED` | Publishable key used on a secret-key-only endpoint |
|
|
1057
|
+
| 403 | `EPKDOMAIN` | Request origin not in publishable key's allowed domains |
|
|
1058
|
+
| 404 | `ENOTFOUND` | Route not found |
|
|
1059
|
+
| 404 | `EAPIKEYNOTFOUND` | API key not found |
|
|
1060
|
+
| 409 | `EAPIKEYEXISTS` | Custom API key already exists |
|
|
1061
|
+
| 409 | `EAPIKEYLABELEXISTS` | API key label already exists |
|
|
1062
|
+
| 409 | `EAPIKEYMIN` | Attempt to remove last remaining key |
|
|
1063
|
+
| 429 | `ERATE` | Anonymous daily rate limit exceeded |
|
|
1064
|
+
| 500 | `ECHECKOUT` | Stripe checkout session creation failed |
|
|
1065
|
+
| 500 | `EAPIKEYFAILED` | API key retrieval after checkout failed |
|
|
1066
|
+
| 500 | `EINTERNAL` | Unexpected internal server failure |
|
|
933
1067
|
|
|
934
1068
|
## Contact
|
|
935
1069
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@unavatar/core",
|
|
3
3
|
"description": "Get unified user avatar from social networks, including Instagram, SoundCloud, Telegram, Twitter, YouTube & more.",
|
|
4
4
|
"homepage": "https://unavatar.io",
|
|
5
|
-
"version": "3.32.
|
|
5
|
+
"version": "3.32.14",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./src/index.js",
|