California business records change notifications

California business records search that this val will use for automated notifications

There's nothing I like more than a little open data and transparency! This Val shows you how to use the California Secretary of State Business Search as a faux-API and get notifications when records change. This lets you know when a business updates their records, changes their good-standing status, and so on.

Here's how to use it:

  1. Fork this val
  2. Open the California Secretary of State Search.
  3. Open your browser's inspector tools.
  4. Search for the business you're interested in, and click on its header row.
  5. Now, in the network tab of your developer tools, you should see a request that ends with false. You'll find a number in that URL. Plug that number into the val at the spot at the top.

Browser inspector tools showing the number you need to copy for this API request

(We're almost there!)

Now just run the val and you should get a notification! If you want to get these intermittently, schedule the val. It's probably not necessary to run this more than once a week - businesses update these details very infrequently.

CleanShot 2023-08-28 at 10.35.45@2x.png


Notes

  • opencorporates has a way better system for open data around businesses, but to get a free API key you need to be a nonprofit or a registered journalist, and I am neither. But if you are, use that!
  • Thanks to America's laws around business registration, it's commonplace for businesses to mask their control and ownership by using registration agents and a few layers of corporate structure.
Readme
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
import { fetch } from "https://esm.town/v/std/fetch";
let { californiaBusinessNotificationsLast } = await import("https://esm.town/v/tmcw/californiaBusinessNotificationsLast");
export const californiaBusinessNotifications = (async () => {
const { parse } = await import("https://deno.land/x/xml/mod.ts");
const res: any = await fetch(
"https://bizfileonline.sos.ca.gov/api/FilingDetail/business/4603/false",
{
headers: {
Accept: "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"User-Agent": "Mozilla/5.0",
},
},
).then((r) => r.text()).then(parse);
const list = res.DRAWER.DRAWER_DETAIL_LIST.DRAWER_DETAIL.map((detail) => {
return `## ${detail.LABEL}${detail.ALERT_YN ? " (alert)" : ""}
${detail.VALUE}`;
});
const lastValue = new Set(
californiaBusinessNotificationsLast || [],
);
let newEntries = [];
let removedEntries = [];
for (let val of list) {
if (!lastValue.has(val)) {
newEntries.push(val);
}
}
for (let val of lastValue.values()) {
if (!list.includes(val)) {
removedEntries.push(val);
}
}
californiaBusinessNotificationsLast = list;
if (newEntries.length || removedEntries.length) {
console.email(
`
Removed entries:
${removedEntries.join("\n\n")}
New entries:
${newEntries.join("\n\n")}`,
`Change in California business records!`,
);
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.