@unavatar/core 3.32.12 → 3.32.13

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.
Files changed (2) hide show
  1. package/README.md +154 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- ![logo](https://unavatar.io/api/og ':id=banner')
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 4, 2026
81
+ Last updated on May 13, 2026
82
+
83
+ ![logo](https://unavatar.io/api/og ":id=banner")
80
84
 
81
85
  ## Introduction
82
86
 
@@ -268,6 +272,112 @@ x-rate-limit-remaining: 24
268
272
  x-rate-limit-reset: 1744243200
269
273
  ```
270
274
 
275
+ ### Secret keys
276
+
277
+ 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.
278
+
279
+ Pass them via the `x-api-key` header:
280
+
281
+ ```bash
282
+ curl "https://unavatar.io/github/kikobeats" -H "x-api-key: sk_YOUR_SECRET_KEY"
283
+ ```
284
+
285
+ ```javascript
286
+ await fetch('https://unavatar.io/github/kikobeats', {
287
+
288
+ headers: {
289
+
290
+ 'x-api-key': 'sk_YOUR_SECRET_KEY'
291
+
292
+ }
293
+
294
+ })
295
+ ```
296
+
297
+ ```python
298
+ import requests
299
+
300
+ response = requests.get(
301
+
302
+ 'https://unavatar.io/github/kikobeats',
303
+
304
+ headers={'x-api-key': 'sk_YOUR_SECRET_KEY'}
305
+
306
+ )
307
+ ```
308
+
309
+ ```golang
310
+ package main
311
+
312
+ import "net/http"
313
+
314
+ func main() {
315
+
316
+ req, _ := http.NewRequest("GET", "https://unavatar.io/github/kikobeats", nil)
317
+
318
+ req.Header.Set("x-api-key", "sk_YOUR_SECRET_KEY")
319
+
320
+ resp, _ := http.DefaultClient.Do(req)
321
+
322
+ defer resp.Body.Close()
323
+
324
+ }
325
+ ```
326
+
327
+ ```ruby
328
+ require 'net/http'
329
+
330
+ require 'uri'
331
+
332
+ uri = URI('https://unavatar.io/github/kikobeats')
333
+
334
+ request = Net::HTTP::Get.new(uri)
335
+
336
+ request['x-api-key'] = 'sk_YOUR_SECRET_KEY'
337
+
338
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
339
+
340
+ http.request(request)
341
+
342
+ end
343
+ ```
344
+
345
+ ```php
346
+ $ch = curl_init('https://unavatar.io/github/kikobeats');
347
+
348
+ curl_setopt($ch, CURLOPT_HTTPHEADER, [
349
+
350
+ 'x-api-key: sk_YOUR_SECRET_KEY',
351
+
352
+ ]);
353
+
354
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
355
+
356
+ $response = curl_exec($ch);
357
+
358
+ curl_close($ch);
359
+ ```
360
+
361
+ ### Publishable keys
362
+
363
+ 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.
364
+
365
+ Pass them as a `token` query parameter, which makes them easy to use directly in HTML markup:
366
+
367
+ ```html
368
+ ![](https://unavatar.io/github/kikobeats?token=pk_YOUR_PUBLISHABLE_KEY)
369
+ ```
370
+
371
+ ### Domain restrictions
372
+
373
+ 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.
374
+
375
+ Domains can be managed from the [dashboard](https://unavatar.io/dashboard?tab=credentials). Valid values include:
376
+
377
+ - `example.com` — exact domain match
378
+ - `*.example.com` — all subdomains of example.com
379
+ - `app.example.com` — a specific subdomain
380
+
271
381
  ## Pricing
272
382
 
273
383
  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 +401,7 @@ Every request has a cost in tokens (**\$0.005 per token**) based on the proxy ti
291
401
  The proxy tier used is returned in the `x-proxy-tier` response header, and the total cost in the `x-unavatar-cost` header.
292
402
 
293
403
  ```bash
294
- $ curl -I -H "x-api-key: YOUR_API_KEY" https://unavatar.io/instagram/kikobeats
404
+ $ curl -I -H "x-api-key: sk_YOUR_SECRET_KEY" https://unavatar.io/instagram/kikobeats
295
405
 
296
406
  x-pricing-tier: pro
297
407
 
@@ -327,7 +437,7 @@ To check the cache status in real requests, inspect these response headers:
327
437
  | `cache-control` | Shows cache policy and effective TTL (for example `public, max-age=3600` for `ttl=1h`). |
328
438
 
329
439
  ```bash
330
- $ curl -I -H "x-api-key: YOUR_API_KEY" "https://unavatar.io/github/kikobeats?ttl=1h"
440
+ $ curl -I -H "x-api-key: sk_YOUR_SECRET_KEY" "https://unavatar.io/github/kikobeats?ttl=1h"
331
441
 
332
442
  cache-control: public, max-age=3600
333
443
 
@@ -378,6 +488,16 @@ e.g., [unavatar.io/github/37t?fallback=data:image/gif;base64,R0lGODlhAQABAIAAAP/
378
488
 
379
489
  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
490
 
491
+ ### Token
492
+
493
+ Type: `string`
494
+
495
+ 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).
496
+
497
+ e.g., [unavatar.io/github/kikobeats?token=pk_YOUR_PUBLISHABLE_KEY](https://unavatar.io/github/kikobeats?token=pk_YOUR_PUBLISHABLE_KEY)
498
+
499
+ 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.
500
+
381
501
  ### JSON
382
502
 
383
503
  The service returns media content by default.
@@ -879,7 +999,7 @@ These headers help you understand pricing, limits, and request diagnostics.
879
999
  | `retry-after` | Seconds until rate limit resets (only on 429 responses) |
880
1000
 
881
1001
  ```bash
882
- $ curl -I -H "x-api-key: YOUR_API_KEY" https://unavatar.io/github/kikobeats
1002
+ $ curl -I -H "x-api-key: sk_YOUR_SECRET_KEY" https://unavatar.io/github/kikobeats
883
1003
 
884
1004
  x-pricing-tier: pro
885
1005
 
@@ -908,28 +1028,34 @@ Expected errors are known operational cases returned with stable codes.
908
1028
  - `more` links to documentation for common fixes.
909
1029
  - `report` (when present) indicates how to contact support for server errors.
910
1030
 
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
- | 401 | `EEMAIL` | Invalid or missing authenticated email |
920
- | 401 | `EUSERUNAUTHORIZED` | Missing/invalid auth for protected routes |
921
- | 401 | `EAPIKEY` | Invalid `x-api-key` |
922
- | 403 | `ETTL` | Custom `ttl` requested without pro plan |
923
- | 403 | `EPRO` | Provider restricted to pro plan |
924
- | 404 | `ENOTFOUND` | Route not found |
925
- | 404 | `EAPIKEYNOTFOUND` | API key not found |
926
- | 409 | `EAPIKEYEXISTS` | Custom API key already exists |
927
- | 409 | `EAPIKEYLABELEXISTS` | API key label already exists |
928
- | 409 | `EAPIKEYMIN` | Attempt to remove last remaining key |
929
- | 429 | `ERATE` | Anonymous daily rate limit exceeded |
930
- | 500 | `ECHECKOUT` | Stripe checkout session creation failed |
931
- | 500 | `EAPIKEYFAILED` | API key retrieval after checkout failed |
932
- | 500 | `EINTERNAL` | Unexpected internal server failure |
1031
+ | HTTP | Code | Typical trigger |
1032
+ | ---- | -------------------- | ------------------------------------------------------- |
1033
+ | 400 | `ESESSIONID` | Missing `session_id` in `/checkout/success` |
1034
+ | 400 | `ESESSION` | Checkout session not paid or not found |
1035
+ | 400 | `ESIGNATURE` | Missing `stripe-signature` header |
1036
+ | 400 | `EWEBHOOK` | Invalid/failed Stripe webhook processing |
1037
+ | 400 | `EAPIKEYVALUE` | Missing `apiKey` query parameter |
1038
+ | 400 | `EAPIKEYLABEL` | Missing `label` query parameter |
1039
+ | 400 | `EAUTOROUTE` | `/:key` used with a username instead of email/domain |
1040
+ | 400 | `EPKREMOVE` | Attempted to remove a publishable key directly |
1041
+ | 400 | `EPKUPDATE` | Attempted to update a publishable key directly |
1042
+ | 400 | `EPKINVALID` | Publishable key does not start with `pk_` |
1043
+ | 401 | `EEMAIL` | Invalid or missing authenticated email |
1044
+ | 401 | `EUSERUNAUTHORIZED` | Missing/invalid auth for protected routes |
1045
+ | 401 | `EAPIKEY` | Invalid API key via header or `?token` query param |
1046
+ | 403 | `ETTL` | Custom `ttl` requested without pro plan |
1047
+ | 403 | `EPRO` | Provider restricted to pro plan |
1048
+ | 403 | `EPKNOTALLOWED` | Publishable key used on a secret-key-only endpoint |
1049
+ | 403 | `EPKDOMAIN` | Request origin not in publishable key's allowed domains |
1050
+ | 404 | `ENOTFOUND` | Route not found |
1051
+ | 404 | `EAPIKEYNOTFOUND` | API key not found |
1052
+ | 409 | `EAPIKEYEXISTS` | Custom API key already exists |
1053
+ | 409 | `EAPIKEYLABELEXISTS` | API key label already exists |
1054
+ | 409 | `EAPIKEYMIN` | Attempt to remove last remaining key |
1055
+ | 429 | `ERATE` | Anonymous daily rate limit exceeded |
1056
+ | 500 | `ECHECKOUT` | Stripe checkout session creation failed |
1057
+ | 500 | `EAPIKEYFAILED` | API key retrieval after checkout failed |
1058
+ | 500 | `EINTERNAL` | Unexpected internal server failure |
933
1059
 
934
1060
  ## Contact
935
1061
 
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.12",
5
+ "version": "3.32.13",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",