New York Department of State (United States)
reference Facts, options, APIs
On this page
- Open data, not the live register
- Active entities only
- Settings
- Vocabulary and Properties
- Request and response
- Properties added by the enricher
- How the script handles input and errors
- Testing the enricher
- Limitations
- Process script
This example looks up an organization’s New York DOS ID in the Corporation and Business Entity Database of the New York State Department of State (Division of Corporations, State Records and Uniform Commercial Code). It uses the extract of active entities that the Department publishes on Open NY (dataset n9v6-gdp6, Active Corporations: Beginning 1800). Despite its name, the dataset covers every active entity type, including LLCs, limited partnerships and not-for-profit corporations. For each golden record it stores the entity name, entity type, jurisdiction, county, initial filing date, the address for service of process, the CEO, the registered agent and the principal executive office. No API key is needed.
Enricher version: V2
API key: not needed (an optional data.ny.gov app token raises the rate limit)
Open data, not the live register
The dataset is an extract of the Department of State’s database. Its metadata says it is posted monthly and is accurate as of the last business day of the month; in practice the portal has been refreshing it more often. It isn’t a live query of the database, so a recent filing may not be in it yet. For the current state of an entity, use the Department of State’s public inquiry search of the Corporation and Business Entity Database.
Active entities only
The dataset lists only entities that are active. An entity that has been dissolved, merged, surrendered or otherwise made inactive isn’t in it, so it gets no result. Open NY also has the Department’s complete filing history (dataset 63wc-4exh, Corporations and Other Entities: All Filings, one row per filing) and status history (dataset 3gg2-jgnp). This sample doesn’t use them: finding an inactive entity’s current name, type and status there means combining several filings and status changes, which isn’t a single, reliable lookup.
To set up the enricher, see Add REST API enricher, then use the settings and script on this page.
Settings
-
Accepted Business Domain –
/Organization, or the business domain that holds your companies. -
Version – V2 (recommended).
-
API Key – leave empty, or enter a data.ny.gov app token. Without a token, data.ny.gov limits how many requests it accepts from one address; with one, the limit is much higher. To get a token, sign in to data.ny.gov and create an app token in your developer settings (see Socrata app tokens). The script sends it in the
X-App-Tokenheader. -
Filters – we recommend a rule that only accepts golden records where
organization.newYorkDosIdhas a value. Otherwise, every record without a DOS ID is listed on the enricher’s Logs tab as having returned no results.
Vocabulary and Properties
organization.newYorkDosId
organization.newYorkDosId holds the DOS ID that the Department of State assigns to each entity, for example 30059. If your data uses another vocabulary key, change this field and the DOS_ID_KEY value at the top of the script.
Request and response
Base URL: https://data.ny.gov/resource
Endpoint: GET /n9v6-gdp6.json?dos_id={dosId}
Authentication: none; optional app token in the X-App-Token header
Rate limits: requests without an app token are throttled per IP address; requests with one aren’t, unless they are abusive (see Socrata app tokens). Each request takes about 1 second.
The script sends one request per golden record:
GET https://data.ny.gov/resource/n9v6-gdp6.json?dos_id=30059
Accept: application/json
Response (one row; the DOS ID is unique):
[
{
"dos_id": "30059",
"current_entity_name": "INTERNATIONAL BUSINESS MACHINES CORPORATION",
"initial_dos_filing_date": "1911-06-16T00:00:00.000",
"county": "Westchester",
"jurisdiction": "New York",
"entity_type": "DOMESTIC BUSINESS CORPORATION",
"dos_process_name": "C/O CORPORATION SERVICE COMPANY",
"dos_process_address_1": "80 STATE STREET",
"dos_process_city": "ALBANY",
"dos_process_state": "NY",
"dos_process_zip": "122072543",
"chairman_name": "ARVIND KRISHNA",
"chairman_address_1": "ARVIND KRISHNA",
"chairman_city": "ARMONK",
"chairman_state": "NY",
"chairman_zip": "10504"
}
]
An empty array ([]) means that the DOS ID isn’t in the dataset: the entity is inactive or the ID doesn’t exist. Fields without a value are left out of the row.
Properties added by the enricher
| Property | Response field | Example |
|---|---|---|
newyork.dosId | dos_id | 30059 |
newyork.name | current_entity_name | INTERNATIONAL BUSINESS MACHINES CORPORATION |
newyork.entityType | entity_type | DOMESTIC BUSINESS CORPORATION |
newyork.jurisdiction | jurisdiction (state or country of formation) | New York |
newyork.county | county | Westchester |
newyork.initialFilingDate | initial_dos_filing_date, as YYYY-MM-DD | 1911-06-16 |
newyork.processName | dos_process_name | C/O CORPORATION SERVICE COMPANY |
newyork.processAddress | dos_process_address_1, dos_process_address_2, dos_process_city, dos_process_state, dos_process_zip, on one line | 80 STATE STREET, ALBANY, NY 12207-2543 |
newyork.ceoName | chairman_name (CEO Name on the portal) | ARVIND KRISHNA |
newyork.registeredAgent | registered_agent_name | SPIEGEL & UTRERA, P.A., P.C. |
newyork.registeredAgentAddress | registered_agent_address_1, registered_agent_address_2, registered_agent_city, registered_agent_state, registered_agent_zip, on one line | 1 MAIDEN LANE 5TH FLOOR, NEW YORK, NEW YORK 10038 |
newyork.locationName | location_name | 011 SERVICES CORP. |
newyork.locationAddress | location_address_1, location_address_2, location_city, location_state, location_zip (the principal executive office), on one line | 61-20 185TH ST, #2, FRESH MEADOWS, NY 11365 |
A property is added only when the dataset has a value for it. Nine-digit ZIP codes are written as ZIP+4 (12207-2543). The CEO’s address isn’t added; its first line often repeats the CEO’s name.
If the enricher has a Preview tab, the results appear there first. To add them to golden records, go to the Map tab, select Map Data, and choose Auto Mapping. Select the business domain, enter a new vocabulary named New York with the key prefix newyork, and then create the mapping. Auto mapping also uses name as the golden record name, so remove that from the mapping if you want to keep your existing names. Then process the data on the Process tab. If the enricher has no Preview tab, the properties are added to the golden record as soon as it is enriched.
How the script handles input and errors
-
Spaces, dots, dashes and leading zeros are removed, so
0030059is looked up as30059. The ID must then have 1 to 8 digits. Golden records without a valid ID are skipped without calling the API. -
If the DOS ID isn’t in the dataset (because the entity is inactive or the ID doesn’t exist), the request is rejected, or the API returns an error, the script logs the reason and adds nothing, and nothing is cached.
-
If you entered an app token and data.ny.gov rejects it, the script throws an error that says so, and the golden record fails.
-
If data.ny.gov limits the requests (HTTP 429), the script throws an error that makes the enricher try the golden record again later. Enter an app token if this happens often.
-
Successful results are cached for 24 hours per DOS ID. To change this, edit
CACHE_MILLISECONDSin the script.
Testing the enricher
-
Test connection checks only that the script runs. It doesn’t call the API.
-
To try the setup, create a golden record with
organization.newYorkDosIdset to30059(International Business Machines Corporation) or69033(Pfizer Inc.).
Limitations
-
Only active entities are in the dataset (see Active entities only), so there is no status property: every result is an active entity.
-
The dataset is a periodic extract, not a live query of the database (see Open data, not the live register).
-
Lookups by name aren’t supported.
-
The service of process address is where legal documents are sent; it is often a registered agent or law firm, not the entity’s own office. Many entities have no principal executive office or registered agent in the dataset.
-
Values are in capital letters, as they are in the dataset.
Process script
// REST API enricher (V2) - New York corporation and business entity lookup
//
// Looks up a golden record's New York DOS ID in the Corporation and Business Entity Database of the
// New York State Department of State (Division of Corporations), using the extract of active
// entities that is published on Open NY (https://data.ny.gov/, dataset n9v6-gdp6, "Active
// Corporations: Beginning 1800"), and adds the result to the golden record as newyork.* properties:
//
// newyork.dosId DOS ID that was looked up
// newyork.name current entity name
// newyork.entityType entity type, for example DOMESTIC BUSINESS CORPORATION or FOREIGN LIMITED LIABILITY COMPANY
// newyork.jurisdiction state or country of jurisdiction (formation)
// newyork.county county of the entity's office in New York
// newyork.initialFilingDate date of the initial filing with the Department of State (YYYY-MM-DD)
// newyork.processName name line of the address for service of process
// newyork.processAddress address for service of process, on one line
// newyork.ceoName name of the chief executive officer (business corporations)
// newyork.registeredAgent name of the registered agent
// newyork.registeredAgentAddress registered agent's address, on one line
// newyork.locationName name line of the principal executive office (physical location)
// newyork.locationAddress address of the principal executive office, on one line
//
// The dataset lists active entities only; an inactive (dissolved, merged, surrendered...) entity
// is not in it and gets no result.
//
// No API key is needed. An optional Socrata app token (for higher rate limits) can be entered
// in the API Key field. See README.md next to this file for the enricher settings.
//
// A record gets no result (nothing is stored) when it has no valid DOS ID, when the DOS ID isn't
// in the dataset, or when the API can't answer.
// ---- Settings -------------------------------------------------------------------------
// Vocabulary key to read. Add the same key to the Vocabulary and Properties field.
const DOS_ID_KEY = "organization.newYorkDosId";
// The enricher replaces {APIKey} with the API Key field value: an optional data.ny.gov
// (Socrata) app token. Leave the field empty to call the API without one.
const APP_TOKEN = "{APIKey}";
const NEW_YORK_URL = "https://data.ny.gov/resource/n9v6-gdp6.json";
// How long to reuse an answer for the same DOS ID. 0 turns caching off.
const CACHE_MILLISECONDS = 24 * 60 * 60 * 1000;
// ---- Script ---------------------------------------------------------------------------
function getValue(key) {
// A plain loop rather than vocabularies.find(...): vocabularies is a .NET list, and when
// .find is called from inside a function, later calls return the first call's match.
const items = vocabularies || [];
for (let i = 0; i < items.length; i++) {
if (items[i].Key === key) {
const value = items[i].Value;
return value === null || value === undefined ? "" : String(value).trim();
}
}
return "";
}
// DOS IDs are numbers of up to 8 digits, for example 30059 or 4154481, stored without leading
// zeros. Spaces, dashes and dots and leading zeros are removed. Returns the ID or null.
function parseDosId(raw) {
const text = raw.replace(/[\s.\-]/g, "").replace(/^0+/, "");
return /^\d{1,8}$/.test(text) ? text : null;
}
function clean(value) {
if (value === null || value === undefined) {
return null;
}
const text = String(value).replace(/\s+/g, " ").trim();
return text === "" ? null : text;
}
function parseJson(text) {
try {
return JSON.parse(text);
} catch (e) {
return null;
}
}
// Socrata dates look like "1911-06-16T00:00:00.000". Only the date is kept.
function formatDate(value) {
const text = clean(value);
return text && /^\d{4}-\d{2}-\d{2}/.test(text) ? text.substring(0, 10) : null;
}
// ZIP codes are 5 or 9 digits; "122072543" becomes "12207-2543".
function formatZip(value) {
const text = clean(value);
return text && /^\d{9}$/.test(text) ? `${text.substring(0, 5)}-${text.substring(5)}` : text;
}
// Joins address parts on one line, for example "80 STATE STREET, ALBANY, NY 12207-2543".
function formatAddress(line1, line2, city, state, zip) {
const stateZip = [clean(state), formatZip(zip)].filter((x) => x).join(" ");
const parts = [clean(line1), clean(line2), clean(city), stateZip].filter((x) => x);
return parts.length > 0 ? parts.join(", ") : null;
}
// Calls the API. Returns the rows for the DOS ID (possibly none), or null when the API can't
// answer.
function lookUp(dosId) {
const headers = [{ Key: "Accept", Value: "application/json" }];
if (clean(APP_TOKEN)) {
headers.push({ Key: "X-App-Token", Value: APP_TOKEN.trim() });
}
const apiResponse = http.send({
url: `${NEW_YORK_URL}?dos_id=${dosId}`,
method: "GET",
headers: headers,
});
const status = String(apiResponse.HttpStatus || "");
const body = parseJson(apiResponse.Content);
if (status === "TooManyRequests") {
throw new Error("TooManyRequests - data.ny.gov is throttling requests, the record will be retried");
}
if ((status === "Forbidden" || status === "Unauthorized") && clean(APP_TOKEN)) {
throw new Error(`data.ny.gov rejected the app token in the API Key field (HTTP ${status}). ${body && body.message ? body.message : ""}`);
}
if (status === "OK" && Array.isArray(body)) {
return body;
}
log(`New York active corporations could not look up DOS ID ${dosId}. HTTP ${status}. ${String(apiResponse.Content || "").substring(0, 200)}`);
return null;
}
function run() {
const dosId = parseDosId(getValue(DOS_ID_KEY));
if (!dosId) {
// No valid DOS ID on this record (this is also what Test connection hits, because it passes
// placeholder values instead of real ones).
return [];
}
const cacheKey = `newyork:${dosId}`;
const cached = CACHE_MILLISECONDS > 0 ? cache.get(cacheKey) : null;
let row = cached ? parseJson(String(cached)) : null;
if (!row) {
const rows = lookUp(dosId);
if (!rows) {
return [];
}
// The DOS ID is unique in the dataset, so there is at most one row.
row = rows.length > 0 && rows[0] && clean(rows[0].dos_id) === dosId ? rows[0] : null;
if (!row) {
log(`New York active corporations has no entity with DOS ID ${dosId}. It may be inactive or not exist.`);
return [];
}
if (CACHE_MILLISECONDS > 0) {
cache.set(cacheKey, JSON.stringify(row), CACHE_MILLISECONDS);
}
}
const data = {
"newyork.dosId": dosId,
"newyork.name": clean(row.current_entity_name),
"newyork.entityType": clean(row.entity_type),
"newyork.jurisdiction": clean(row.jurisdiction),
"newyork.county": clean(row.county),
"newyork.initialFilingDate": formatDate(row.initial_dos_filing_date),
"newyork.processName": clean(row.dos_process_name),
"newyork.processAddress": formatAddress(row.dos_process_address_1, row.dos_process_address_2, row.dos_process_city,
row.dos_process_state, row.dos_process_zip),
"newyork.ceoName": clean(row.chairman_name),
"newyork.registeredAgent": clean(row.registered_agent_name),
"newyork.registeredAgentAddress": formatAddress(row.registered_agent_address_1, row.registered_agent_address_2,
row.registered_agent_city, row.registered_agent_state, row.registered_agent_zip),
"newyork.locationName": clean(row.location_name),
"newyork.locationAddress": formatAddress(row.location_address_1, row.location_address_2, row.location_city,
row.location_state, row.location_zip),
};
// Leave out values the register didn't return, so they don't overwrite existing data with blanks.
Object.keys(data).forEach((key) => {
if (data[key] === null) {
delete data[key];
}
});
return [{ Data: data, Score: 100 }];
}
response = JSON.stringify(run());