forked from zintarh/stellar-wrap-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.ts
More file actions
113 lines (100 loc) · 3.55 KB
/
Copy pathapi.ts
File metadata and controls
113 lines (100 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* Type definitions for Stellar Wrap API request and response shapes.
*
* Used by both the frontend (typed fetch calls) and documentation tooling
* (OpenAPI codegen, mock servers, etc.).
*/
// ---------------------------------------------------------------------------
// Shared primitives
// ---------------------------------------------------------------------------
/** Stellar public key — 56-character string starting with "G". */
export type StellarAddress = string;
/** Supported Stellar networks. */
export type Network = "mainnet" | "testnet";
/** Reporting period for wrap data. */
export type WrapPeriod = "weekly" | "monthly" | "yearly";
// ---------------------------------------------------------------------------
// GET /api/wrapped
// ---------------------------------------------------------------------------
/** Query parameters accepted by GET /api/wrapped. */
export interface WrappedRequestParams {
/** Required. A valid Stellar public key (56 chars, starts with "G"). */
accountId: StellarAddress;
/** Optional. Defaults to "mainnet". */
network?: Network;
/** Optional. Defaults to "monthly". */
period?: WrapPeriod;
}
/** A single dApp interaction entry returned by /api/wrapped. */
export interface WrappedDapp {
name: string;
transactions: number;
color: string;
gradient: string;
}
/** A single vibe entry returned by /api/wrapped. */
export interface WrappedVibe {
type: string;
percentage: number;
color: string;
label: string;
}
/** Successful 200 response body from GET /api/wrapped. */
export interface WrappedResponse {
username: string;
address: StellarAddress;
totalTransactions: number;
totalVolume: number;
percentile: number;
persona: string;
personaDescription: string;
dapps: WrappedDapp[];
vibes: WrappedVibe[];
/** True when this response was served from the 60-minute IndexedDB cache. */
cached: boolean;
/** ISO-8601 timestamp of when the cache entry was created, or null. */
cacheTimestamp: string | null;
/** True when a background re-index has been triggered for this address. */
refreshingInBackground: boolean;
}
/** Error response body returned for 4xx / 5xx from GET /api/wrapped. */
export interface WrappedErrorResponse {
error: string;
details?: string;
}
// ---------------------------------------------------------------------------
// GET /api/og
// ---------------------------------------------------------------------------
/** Query parameters accepted by GET /api/og. */
export interface OgRequestParams {
/** Stellar username or truncated address shown on the card. Defaults to "StellarUser". */
username?: string;
/** Total transaction count displayed on the card. Defaults to "0". */
transactions?: string;
/** Persona / archetype label. Defaults to "Network Pioneer". */
persona?: string;
/** Top vibe label (e.g. "Steady", "Power User"). Defaults to "Steady". */
topVibe?: string;
/** Vibe percentage as a string (0–100). Defaults to "0". */
vibePercentage?: string;
/**
* Path to the archetype image relative to the app's public directory.
* Defaults to a slug derived from the persona name.
* Example: "/archetypes/wizard.png"
*/
archetypeImage?: string;
}
/**
* The /api/og endpoint returns a binary PNG image (1200 × 1200 px), not JSON.
* This type represents the HTTP response metadata.
*/
export interface OgResponseMeta {
/** Always "image/png". */
contentType: "image/png";
/** Always 1200. */
width: 1200;
/** Always 1200. */
height: 1200;
/** Cache-Control header value set on the response. */
cacheControl: string;
}