@apiverve/zipdemographics 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
@@ -139,22 +139,13 @@ async function makeRequest() {
139
139
  "medianHomeValue": 2875000,
140
140
  "medianRent": 3250,
141
141
  "totalUnits": 10234,
142
- "occupiedUnits": 8976,
143
- "vacantUnits": 1258,
144
- "ownerOccupied": 5678,
145
- "renterOccupied": 3298,
146
142
  "homeOwnershipRate": 63.2
147
143
  },
148
144
  "education": {
149
- "collegeEducatedPct": 72.4,
150
- "bachelors": 4523,
151
- "masters": 2341,
152
- "professional": 1234,
153
- "doctorate": 567
145
+ "collegeEducatedPct": 72.4
154
146
  },
155
147
  "employment": {
156
148
  "laborForce": 11234,
157
- "unemployed": 423,
158
149
  "unemploymentRate": 3.8
159
150
  },
160
151
  "race": {
@@ -162,18 +153,16 @@ async function makeRequest() {
162
153
  "count": 16892,
163
154
  "percent": 77.7
164
155
  },
165
- "black": {
166
- "count": 542,
167
- "percent": 2.5
168
- },
169
156
  "asian": {
170
157
  "count": 2345,
171
158
  "percent": 10.8
172
- },
173
- "hispanic": {
174
- "count": 1423,
175
- "percent": 6.5
176
159
  }
160
+ },
161
+ "formatted": {
162
+ "medianHouseholdIncome": "$153,891",
163
+ "perCapitaIncome": "$98,234",
164
+ "medianHomeValue": "$2,875,000",
165
+ "medianRent": "$3,250"
177
166
  }
178
167
  }
179
168
  }
package/index.d.ts CHANGED
@@ -4,73 +4,82 @@ declare module '@apiverve/zipdemographics' {
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 zipdemographicsResponse {
8
19
  status: string;
9
20
  error: string | null;
10
21
  data: ZIPDemographicsData;
11
22
  code?: number;
23
+ premium?: PremiumInfo;
12
24
  }
13
25
 
14
26
 
15
27
  interface ZIPDemographicsData {
16
- zip: string;
17
- name: string;
18
- acsYear: number;
28
+ zip: null | string;
29
+ name: null | string;
30
+ acsYear: number | null;
19
31
  population: Population;
20
32
  income: Income;
21
33
  housing: Housing;
22
34
  education: Education;
23
35
  employment: Employment;
24
36
  race: Race;
37
+ formatted: Formatted;
25
38
  }
26
39
 
27
40
  interface Education {
28
- collegeEducatedPct: number;
29
- bachelors: number;
30
- masters: number;
31
- professional: number;
32
- doctorate: number;
41
+ collegeEducatedPct: number | null;
33
42
  }
34
43
 
35
44
  interface Employment {
36
- laborForce: number;
37
- unemployed: number;
38
- unemploymentRate: number;
45
+ laborForce: number | null;
46
+ unemploymentRate: number | null;
47
+ }
48
+
49
+ interface Formatted {
50
+ medianHouseholdIncome: null | string;
51
+ perCapitaIncome: null | string;
52
+ medianHomeValue: null | string;
53
+ medianRent: null | string;
39
54
  }
40
55
 
41
56
  interface Housing {
42
- medianHomeValue: number;
43
- medianRent: number;
44
- totalUnits: number;
45
- occupiedUnits: number;
46
- vacantUnits: number;
47
- ownerOccupied: number;
48
- renterOccupied: number;
49
- homeOwnershipRate: number;
57
+ medianHomeValue: number | null;
58
+ medianRent: number | null;
59
+ totalUnits: number | null;
60
+ homeOwnershipRate: number | null;
50
61
  }
51
62
 
52
63
  interface Income {
53
- medianHousehold: number;
54
- perCapita: number;
64
+ medianHousehold: number | null;
65
+ perCapita: number | null;
55
66
  }
56
67
 
57
68
  interface Population {
58
- total: number;
59
- male: number;
60
- female: number;
61
- medianAge: number;
69
+ total: number | null;
70
+ male: number | null;
71
+ female: number | null;
72
+ medianAge: number | null;
62
73
  }
63
74
 
64
75
  interface Race {
65
- white: Asian;
66
- black: Asian;
67
- asian: Asian;
68
- hispanic: Asian;
76
+ white: Asian;
77
+ asian: Asian;
69
78
  }
70
79
 
71
80
  interface Asian {
72
- count: number;
73
- percent: number;
81
+ count: number | null;
82
+ percent: number | null;
74
83
  }
75
84
 
76
85
  export default class zipdemographicsWrapper {
package/index.js CHANGED
@@ -13,16 +13,10 @@ class zipdemographicsWrapper {
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') {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@apiverve/zipdemographics",
3
- "version": "1.1.13",
3
+ "version": "1.2.0",
4
4
  "description": "ZIP Demographics provides detailed demographic data for any US ZIP code including population, income, education, housing, employment, and racial composition from the US Census American Community Survey.",
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
+ "zip code demographics", "census data", "population by zip", "income by zip", "demographics api"
27
27
  ],
28
28
  "author": {
29
29
  "name": "APIVerve",
@@ -41,8 +41,7 @@
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
  }