@apiverve/treasuryyields 1.1.13 → 1.2.0

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 CHANGED
@@ -1,13 +1,13 @@
1
1
  # Treasury Yields API
2
2
 
3
- Treasury Yields provides current and historical interest rates for US Treasury securities including T-bills, T-notes, T-bonds, TIPS, and Floating Rate Notes. Essential data for yield curve analysis and fixed income research.
3
+ Treasury Yields provides current and historical US Treasury constant-maturity market yields across the full curve (1-month through 30-year), plus TIPS real yields. Essential data for yield curve analysis and fixed income research.
4
4
 
5
5
  ![Build Status](https://img.shields.io/badge/build-passing-green)
6
6
  ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
7
7
  ![Prod Ready](https://img.shields.io/badge/production-ready-blue)
8
8
  [![npm version](https://img.shields.io/npm/v/@apiverve/treasuryyields.svg)](https://www.npmjs.com/package/@apiverve/treasuryyields)
9
9
 
10
- This is a Javascript Wrapper for the [Treasury Yields API](https://apiverve.com/marketplace/treasuryyields?utm_source=npm&utm_medium=readme)
10
+ This is a Javascript Wrapper for the [Treasury Yields API](https://treasuryyields.apiverve.com?utm_source=npm&utm_medium=readme)
11
11
 
12
12
  ---
13
13
 
@@ -60,8 +60,8 @@ Using the API is simple. All you have to do is make a request. The API will retu
60
60
 
61
61
  ```javascript
62
62
  var query = {
63
- date: "2024-01-15",
64
- type: "bonds"
63
+ date: "2025-06",
64
+ type: "10yr"
65
65
  };
66
66
 
67
67
  api.execute(query, function (error, data) {
@@ -81,8 +81,8 @@ You can also use promises to make requests. The API returns a promise that you c
81
81
 
82
82
  ```javascript
83
83
  var query = {
84
- date: "2024-01-15",
85
- type: "bonds"
84
+ date: "2025-06",
85
+ type: "10yr"
86
86
  };
87
87
 
88
88
  api.execute(query)
@@ -103,8 +103,8 @@ You can also use async/await to make requests. The API returns a promise that yo
103
103
  ```javascript
104
104
  async function makeRequest() {
105
105
  var query = {
106
- date: "2024-01-15",
107
- type: "bonds"
106
+ date: "2025-06",
107
+ type: "10yr"
108
108
  };
109
109
 
110
110
  try {
@@ -130,7 +130,30 @@ async function makeRequest() {
130
130
  "notes": 4.35,
131
131
  "bonds": 4.67,
132
132
  "tips": 2.15,
133
- "frn": 5.31
133
+ "frn": 5.31,
134
+ "changes": {
135
+ "bills": {
136
+ "change1d": 0.02,
137
+ "direction": "up"
138
+ },
139
+ "notes": {
140
+ "change1d": -0.03,
141
+ "direction": "down"
142
+ },
143
+ "bonds": {
144
+ "change1d": 0.01,
145
+ "direction": "up"
146
+ },
147
+ "tips": {
148
+ "change1d": 0,
149
+ "direction": "unchanged"
150
+ },
151
+ "frn": {
152
+ "change1d": 0.02,
153
+ "direction": "up"
154
+ }
155
+ },
156
+ "previousDate": "2024-01-31"
134
157
  }
135
158
  }
136
159
  ```
package/index.d.ts CHANGED
@@ -4,21 +4,48 @@ declare module '@apiverve/treasuryyields' {
4
4
  secure?: boolean;
5
5
  }
6
6
 
7
+ /**
8
+ * Describes fields the current plan does not unlock. Locked fields arrive as null
9
+ * in `data`; `locked_fields` names them, using dot paths for nested fields.
10
+ * Absent when the plan unlocks everything.
11
+ */
12
+ export interface PremiumInfo {
13
+ message: string;
14
+ upgrade_url: string;
15
+ locked_fields: string[];
16
+ }
17
+
7
18
  export interface treasuryyieldsResponse {
8
19
  status: string;
9
20
  error: string | null;
10
21
  data: TreasuryYieldsData;
11
22
  code?: number;
23
+ premium?: PremiumInfo;
12
24
  }
13
25
 
14
26
 
15
27
  interface TreasuryYieldsData {
16
- date: Date;
17
- bills: number;
18
- notes: number;
19
- bonds: number;
20
- tips: number;
21
- frn: number;
28
+ date: Date | null;
29
+ bills: number | null;
30
+ notes: number | null;
31
+ bonds: number | null;
32
+ tips: number | null;
33
+ frn: number | null;
34
+ changes: Changes;
35
+ previousDate: Date | null;
36
+ }
37
+
38
+ interface Changes {
39
+ bills: Bills;
40
+ notes: Bills;
41
+ bonds: Bills;
42
+ tips: Bills;
43
+ frn: Bills;
44
+ }
45
+
46
+ interface Bills {
47
+ change1D: number | null;
48
+ direction: null | string;
22
49
  }
23
50
 
24
51
  export default class treasuryyieldsWrapper {
package/index.js CHANGED
@@ -13,16 +13,10 @@ class treasuryyieldsWrapper {
13
13
  throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
14
14
  }
15
15
 
16
- // Validate API key format (GUID or alphanumeric with hyphens)
17
- const apiKeyPattern = /^[a-zA-Z0-9-]+$/;
16
+ // Validate API key format (GUID, prefixed keys like apv_xxx, or alphanumeric)
17
+ const apiKeyPattern = /^[a-zA-Z0-9_-]+$/;
18
18
  if (!apiKeyPattern.test(api_key)) {
19
- throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
20
- }
21
-
22
- // Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
23
- const trimmedKey = api_key.replace(/-/g, '');
24
- if (trimmedKey.length < 32) {
25
- throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
19
+ throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens and underscores. Get your API key at: https://apiverve.com');
26
20
  }
27
21
 
28
22
  if (typeof secure !== 'boolean') {
@@ -36,7 +30,7 @@ class treasuryyieldsWrapper {
36
30
  this.baseURL = 'https://api.apiverve.com/v1/treasuryyields';
37
31
 
38
32
  // Validation rules for parameters (generated from schema)
39
- this.validationRules = {"date":{"type":"string","required":false,"format":"date"},"type":{"type":"string","required":false}};
33
+ this.validationRules = {"date":{"type":"string","required":false},"type":{"type":"string","required":false}};
40
34
  }
41
35
 
42
36
  /**
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@apiverve/treasuryyields",
3
- "version": "1.1.13",
4
- "description": "Treasury Yields provides current and historical interest rates for US Treasury securities including T-bills, T-notes, T-bonds, TIPS, and Floating Rate Notes. Essential data for yield curve analysis and fixed income research.",
3
+ "version": "1.2.0",
4
+ "description": "Treasury Yields provides current and historical US Treasury constant-maturity market yields across the full curve (1-month through 30-year), plus TIPS real yields. Essential data for yield curve analysis and fixed income research.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "sideEffects": false,
8
8
  "engines": {
9
- "node": ">=14.0.0"
9
+ "node": ">=18.0.0"
10
10
  },
11
11
  "files": [
12
12
  "index.js",
@@ -23,7 +23,7 @@
23
23
  "directory": "npm"
24
24
  },
25
25
  "keywords": [
26
- ""
26
+ "treasury yields", "t-bill rates", "treasury bonds", "treasury notes", "tips rates"
27
27
  ],
28
28
  "author": {
29
29
  "name": "APIVerve",
@@ -34,15 +34,14 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/apiverve/treasuryyields-api/issues"
36
36
  },
37
- "homepage": "https://apiverve.com/marketplace/treasuryyields?utm_source=npm&utm_medium=homepage",
37
+ "homepage": "https://treasuryyields.apiverve.com?utm_source=npm&utm_medium=homepage",
38
38
  "devDependencies": {
39
39
  "mocha": "^11.0.1",
40
40
  "chai": "^5.1.2",
41
41
  "dotenv": "^16.4.7"
42
42
  },
43
43
  "dependencies": {
44
- "node-fetch": "^3.3.2",
45
- "promise": "^8.3.0",
46
- "axios": "1.13.2"
44
+ "axios": "1.13.2",
45
+ "form-data": "^4.0.1"
47
46
  }
48
47
  }