Skip to main content

Normalize List API

Written by Kadri - RichAPI Support Team

POST /normalize_list • Credits: 0.5 credits per call

Normalize List takes one string, splits it into items, trims the whitespace around each item and removes the duplicates. The endpoint accepts a comma-separated string or a JSON array. It returns the original item count, the deduplicated count, the clean array and the clean joined string. Each call costs 0.5 credits.

What does Normalize List do?

A list that comes from a spreadsheet column, a form field or a CRM export carries stray spaces, blank cells and repeated values. Normalize List cleans that string in one call. The endpoint splits the string on the comma, trims every item, drops the empty items and keeps the first occurrence of each value. Normalize List runs inside RichAPI and calls no external provider, so the response is immediate. Use Normalize List before a bulk enrichment call, to cut the duplicate rows that you pay for twice.

Which endpoint does Normalize List use?

  • Method: POST

  • URL: https://api.richapi.ai/api/v1/normalize_list

  • Authentication: x-api-key header

  • Response: Synchronous JSON

  • Credits: 0.5 credits per call

How to send a Normalize List request

  1. Copy your API key from the RichAPI dashboard.

  2. Put the messy list in the input parameter as one string.

  3. Separate the items with a comma.

  4. To keep the empty items, set remove_empty_values to false.

  5. Send a POST request to https://api.richapi.ai/api/v1/normalize_list.

  6. Send the API key in the x-api-key header.

  7. Read the deduped_list array from the response.

cURL

curl -X POST https://api.richapi.ai/api/v1/normalize_list   
-H "x-api-key: YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"input": " acme.com, Acme.com ,, globex.io ,acme.com, initech.dev, ",
"remove_empty_values": true
}'

Python

import requests

response = requests.post(
"https://api.richapi.ai/api/v1/normalize_list",
headers={"x-api-key": "YOUR_API_KEY"},
json={
"input": " acme.com, Acme.com ,, globex.io ,acme.com, initech.dev, ",
"remove_empty_values": True,
},
timeout=60,
)
response.raise_for_status()
print(response.json())

Node.js

const response = await fetch("https://api.richapi.ai/api/v1/normalize_list", {
method: "POST",
headers: {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
input: " acme.com, Acme.com ,, globex.io ,acme.com, initech.dev, ",
remove_empty_values: true,
}),
});

const data = await response.json();
console.log(data);

Which parameters does Normalize List accept?

Parameter

Type

Required

Default

Description

input

string

Yes

None

The list to clean, as one string. The string is a comma-separated list or a JSON array. The maximum size is 1 MB.

remove_empty_values

boolean

No

true

Set to false to keep the empty items in deduped_list.

The parameter names in the request body match the names in the RichAPI dashboard, the MCP tool normalize_list and the n8n operation normalize_list.

What does Normalize List normalize?

Normalize List runs a fixed sequence of operations on the input string.

#

Operation

What Normalize List does

1

Outer trim

Removes the whitespace at the start and at the end of the whole input string.

2

JSON parse

If the string parses as a JSON array, every element becomes one item. A number becomes its string form.

3

Comma split

If the string is not a JSON array, Normalize List splits the string on every comma.

4

Item trim

Removes the whitespace at the start and at the end of every item.

5

Count

Sets original_count to the item count after the split and before the empty removal.

6

Empty removal

If remove_empty_values is true, drops every item that is now an empty string.

7

Deduplication

Keeps the first occurrence of each exact value. The match is case-sensitive.

Normalize List changes no letter case, and it sorts nothing. Acme.com and acme.com are two different values, and both stay in the result. The output order is the input order.

CAUTION: The comma is the only separator. A newline-separated list or a pipe-separated list returns as one item and still costs 0.5 credits. Replace the separator with a comma before you send the request.

How does Normalize List clean a messy domain list?

The following worked example uses a domain column from a CRM export. The column carries stray spaces, two blank cells, one repeated domain and one domain in a different case.

{
"input": " acme.com, Acme.com ,, globex.io ,acme.com, initech.dev, ",
"remove_empty_values": true
}

Normalize List processes that request body in seven steps.

#

Step

Result

1

Trim the whole input string.

acme.com, Acme.com ,, globex.io ,acme.com, initech.dev,

2

Test the string as a JSON array.

The string is not a JSON array, so the comma split runs.

3

Split the string on every comma.

7 items. The ,, pair and the trailing comma each produce an empty item.

4

Trim every item.

acme.com, Acme.com, empty, globex.io, acme.com, initech.dev, empty

5

Set original_count.

7

6

Drop the empty items, because remove_empty_values is true.

acme.com, Acme.com, globex.io, acme.com, initech.dev

7

Keep the first occurrence of each exact value.

acme.com, Acme.com, globex.io, initech.dev

The result holds both acme.com and Acme.com, because the match in step 7 is case-sensitive. The result keeps the input order, because Normalize List sorts nothing. The messy domain list returns as this response.

{
"original_count": 7,
"deduplicated_count": 4,
"deduped_list": ["acme.com", "Acme.com", "globex.io", "initech.dev"],
"deduped_string": "acme.com, Acme.com, globex.io, initech.dev"
}

Five paid enrichment calls drop to four. The deduped_string value is ready for the next endpoint that takes a comma-separated list.

What does Normalize List return?

Normalize List returns a synchronous JSON response with four fields. The following block is an example response for the request body {"input": "apple, Banana, apple, , cherry", "remove_empty_values": true}.

{
"original_count": 5,
"deduplicated_count": 3,
"deduped_list": ["apple", "Banana", "cherry"],
"deduped_string": "apple, Banana, cherry"
}

Which fields does the Normalize List response hold?

Field

Type

Description

original_count

integer

The item count after the split and before the empty removal. The count includes every empty item and every duplicate.

deduplicated_count

integer

The item count in deduped_list. The value is the length of that array.

deduped_list

array of strings

The clean items, in the input order. Every item is trimmed, and every value appears one time.

deduped_string

string

The items of deduped_list joined with a comma and one space.

What happens if remove_empty_values is false?

If remove_empty_values is false, Normalize List keeps the empty items and deduplicates them into a single empty string. The request body {"input": " acme.com, Acme.com ,, globex.io ,acme.com, initech.dev, ", "remove_empty_values": false} returns this response.

{
"original_count": 7,
"deduplicated_count": 5,
"deduped_list": ["acme.com", "Acme.com", "", "globex.io", "initech.dev"],
"deduped_string": "acme.com, Acme.com, , globex.io, initech.dev"
}

The empty item leaves a gap in deduped_string. For a value that you pass to another endpoint, keep remove_empty_values at the default true.

How does Normalize List handle a JSON array?

If the input string parses as a JSON array, Normalize List uses the array elements as the items and runs no comma split. A comma inside an element is then safe. Every element converts to a string, so the number 42 becomes "42". The request body {"input": "[\" Sales \", \"Sales\", \"\", 42]"} returns original_count4, deduplicated_count2 and the deduped_list value ["Sales", "42"].

CAUTION: Send input as a string, and not as a real JSON array. A real array returns 400 with the message Invalid value for input: expected string, and RichAPI charges no credit.

How much does Normalize List cost?

Normalize List costs 0.5 credits per call. At $0.02 a credit, the rate on the 1,000 and 5,000 credit packs, one call costs $0.01. Larger packs cost less per credit. The credit count does not change with the length of the list. A 2-item list and a 20,000-item list both cost 0.5 credits.

Calls

Credits

Cost

1

0.5

$0.01

100

50

$1.00

1,000

500

$10.00

10,000

5,000

$100.00

To clean 4,000 exported columns, send 4,000 calls. That costs 2,000 credits, or $40.00.

Which errors can Normalize List return?

Status

Meaning

What to do

400

The request body is absent, is not valid JSON, is not a JSON object, holds an empty input, or holds an input that is not a string.

Send a JSON object with a non-empty input string.

401

The API key is missing, wrong or revoked.

Send a valid key in the x-api-key header.

403

This API key has no access to this endpoint (Endpoint not available on your plan).

Call GET /api/v1/my-endpoints to see the endpoints that this key can use. Contact support for access.

404

The endpoint name is wrong.

Send the request to /normalize_list.

405

The request used a method other than POST.

Send the request as POST.

429

The request rate is over the limit.

Wait, then send the request again. For a higher limit, contact support.

500

The API failed.

Send the request again. If the failure repeats, contact support.

An error response holds one error field with the reason. RichAPI charges credits only for a 200 response. Every error status in the table above costs no credit.

Frequently asked questions

Is Normalize List deduplication case-sensitive?

Yes. Normalize List compares the exact string, so Acme.com and acme.com stay as two separate items in deduped_list. To merge two items that differ only in case, convert the list to one case before you send the request.

Does Normalize List split on a newline or a pipe character?

No. The comma is the only separator that Normalize List splits on. A newline-separated list or a pipe-separated list returns as a single item, so replace the separator with a comma first. A JSON array is the other accepted form of the input string.

Does Normalize List sort the result?

No. Normalize List keeps the input order and returns the first occurrence of each value in that position. To sort the result, sort the deduped_list array in your own code.

How large can the input string be?

The input string holds up to 1 MB. An input string above 1 MB returns a 400 response with the message about the maximum size. For a larger list, split the list into blocks and send one call per block.

Does a list with no duplicate still cost 0.5 credits?

Yes. Normalize List costs 0.5 credits for every 200 response, and the price does not change with the result. A call that removes 500 duplicates and a call that removes none both cost 0.5 credits.

What does original_count count?

The original_count field holds the item count after the split and before the empty removal. The count includes the empty items and the duplicates. Subtract deduplicated_count from original_count to get the number of items that Normalize List removed.

Related articles

Did this answer your question?