Operations (sample payloads)

Main operations

Base64 Encoder/Decoder

Base64 encode/decode a specified value. Sample Input Sample Output

Change type

Change the type of a value. Sample Input Sample Output

{
    "result": 42
}

Concatenate

Concatenate a list of texts, using a separator if provided. Sample Input Sample Output

{
    "result": "Hello world from Tray.io"
}

Contains

Check if text contains a particular pattern. Sample Input Sample Output

{
    "result": true
}

Escape characters

Escape characters from a string, specified in the input. Sample Input Sample Output

\{
    "result": "Hello, world\\! This is a test string with special characters: \\$100 \\& 50\\% off\\!"
\}

Extract all by Regular Expression

Extract a list of matches when a regular expression is applied to a given text. Sample Input Sample Output

\{
    "result": [
        "The",
        "quick",
        "brown",
        "fox",
        "jumps",
        "over",
        "the",
        "lazy",
        "dog",
        "The",
        "dog",
        "barks",
        "at",
        "cats"
    ]
\}

Extract by Regular Expression

Extract the first match when a regular expression is applied to a given text. Sample Input Sample Output

Extract URLs

Extract all of the URLs from a given piece of text, returning them as a list. Sample Input Sample Output

\{
    "result": [
        "https://www.example.com",
        "http://blog.example.org",
        "https://docs.example.net/guide",
        "www.example.io"
    ]
\}

Format currency

Format currency to the specified denomination. Sample Input

\{
    "currency": "USD",
    "amount": 1234567.89,
    "decimal_digits": 2,
    "decimal_separator": ".",
    "thousands_separator": ","
\}

Sample Output

Generate unique name

Given the name of an object (e.g. an account), and a list of one or more existing object names, generate a unique name by appending "(n)" on the end of the name. Sample Input

\{
    "name": "Sales Report",
    "existing_names": [
        "Sales Report",
        "Sales Report (1)",
        "Sales Report (2)",
        "Marketing Report",
        "Financial Report"
    ]
\}

Sample Output

Get domain from email address

Given a user's email address, extract the website domain. Sample Input

{
    "email": "john.doe@example.com"
}

Sample Output

Get domain from URL

Given a website URL, extract the full website domain. Sample Input Sample Output

{
    "result": "example.com"
}

Get first middle last name

Given a user's full name, extract their first, middle and last name. Sample Input

{
    "full_name": "John Michael Smith"
}

Sample Output

Get text after

Given a string and a pattern, this operation will return the substring between where the pattern was found depending on the match number and beginning of the string. Sample Input Sample Output

{
    "result": " again!"
}

Get text before

Given a string and a pattern, this operation will return the substring between the beginning of the string and where the pattern was found depending on the match number. Sample Input

\{
    "text": "Hello world! This is a sample text. Hello again!",
    "pattern": "Hello",
    "match_number": 2
\}

Sample Output

{
    "result": "Hello world! This is a sample text. "
}

Get text between

Extract the text between a start and an end pattern, searching in a longer piece of text. Sample Input

\{
    "text": "The quick brown fox jumps over the lazy dog. The fox is very agile.",
    "start_pattern": "The",
    "end_pattern": "dog."
\}

Sample Output

{
    "result": " quick brown fox jumps over the lazy "
}

Get text length

Get the length of a string. Sample Input Sample Output

Hex Encoder/Decoder

Hex encode/decode a specified string. Sample Input Sample Output

{
    "result": "48656C6C6F2C20576F726C6421"
}

Is domain?

Check if a string is a valid domain. Sample Input Sample Output

{
    "result": true
}

Is email?

Check if a string is a valid email address. Sample Input Sample Output

Is generic domain?

Check if a website domain is a "generic" domain, such as gmail.com or hotmail.com. Sample Input

{
    "domain": "john.doe@gmail.com"
}

Sample Output

Is numeric?

Check if a text string is a number. Sample Input Sample Output

Is URL?

Check if a string is a valid URL. Sample Input

{
    "text": "https://www.tray.io"
}

Sample Output

{
    "result": true
}

Lower case

Convert a string to lower case. Sample Input Sample Output

{
    "result": "hello world! this is a sample text."
}

Match

Retrieve the result of matching a string against a regular expression. Sample Input Sample Output

\{
    "result": [
        "Hello",
        "World",
        "This",
        "is",
        "a",
        "sample",
        "text",
        "with",
        "numbers",
        "and",
        "special",
        "characters"
    ]
\}

Parse email

Parse out an email address (such as "Name <name@domain.com>") into its component parts such as name and domain. Sample Input Sample Output

Parse email list

Parse out a list of email addresses (such as "Name <name@domain.com>") into component parts such as name and domain. Sample Input

\{
    "emails": "John Doe &lt;john.doe@example.com&gt;, Jane Smith &lt;jane.smith@company.org&gt;, support@tray.io"
\}

Sample Output

Parse URL

Parse a URL string to get each of the core components of the URL (path, query string, etc...). Sample Input Sample Output

{
    "result": {
        "protocol": "https:",
        "slashes": true,
        "auth": null,
        "host": "www.example.com:8080",
        "port": "8080",
        "hostname": "www.example.com",
        "hash": "#section1",
        "search": "?param1=value1&param2=value2",
        "query": \{
            "param1": "value1",
            "param2": "value2"
        \},
        "pathname": "/path/to/page",
        "path": "/path/to/page?param1=value1&param2=value2",
        "href": "https://www.example.com:8080/path/to/page?param1=value1&param2=value2#section1"
    }
}

Proper case

Upper case the first character of every word in the text passed. Sample Input

{
    "text": "the quick brown fox jumps over the lazy dog"
}

Sample Output

Regular expression match test

Checks if a piece of text matches a regular expression. Returns true if it matches, false otherwise. Sample Input

{
    "text": "Hello, World! This is a test string with numbers 123.",
    "regex": "/[A-Za-z]+\\s\\d+/",
    "flags": \{
        "ignore_case": true,
        "multiline": false,
        "unicode": false,
        "sticky": false,
        "global": true
    \}
}

Sample Output

Remove characters

Remove character(s) from a given string. Sample Input Sample Output

\{
    "result": "Hell, Wrld! Hw are yu?"
\}

Remove special characters

Remove all non-alpha numeric characters (including spaces) from a string. Sample Input Sample Output

{
    "result": "HelloWorldHowareyou123"
}

Replace

Replace a pattern in a text string with something else. Sample Input

\{
    "text": "Hello, World! Hello, Universe!",
    "pattern": "Hello",
    "replacement": "Greetings",
    "replace_all": true,
    "case_sensitive": true
\}

Sample Output

Select first n characters

Select the first n characters from a string. Sample Input Sample Output

{
    "first_characters": "The quick "
}

Select last n characters

Select the last n characters from a string. Sample Input

\{
    "text": "Hello, World!",
    "number_of_characters": 5
\}

Sample Output

Sentence case

Convert a string to sentence case. Sample Input Sample Output

{
    "result": "The quick brown fox jumps over the lazy dog. A second sentence here. And a third one."
}

Shorten

Shorten text to a maximum allowed length. Sample Input Sample Output

Split

Split text by a character into an list of words. Sample Input

\{
    "text": "apple,banana,cherry,date",
    "split_by": ","
\}

Sample Output

Strip HTML Tags

Strip all HTML tags from the input text leaving only the tag's text content Sample Input

{
    "text": "<p>Welcome to <strong>Tray.io</strong>! "
}

Sample Output

{
    "result": "Welcome to Tray.io! Check out our documentation for more information."
}

Trim whitespace

Returns the specified string with the leading and trailing spaces removed. Sample Input

\{
    "text": "   Hello, World!   "
\}

Sample Output

\{
    "result": "Hello, World!"
\}

Typecast

Typecast a specified value. Sample Input

{
    "value": "42"
}

Sample Output

Underscore

Convert some text to "snake case", lowercasing all text, removing special characters, and replacing spaces with underscores. Sample Input

{
    "text": "Hello World! This is a Sample Text."
}

Sample Output

Upper case

Convert a string to upper case. Sample Input

\{
    "text": "Hello, World!"
\}

Sample Output

URL encode key/value pairs

URL encode a specified set of key/value pairs. Strings only. Sample Input

{
    "pairs": \{
        "name": "John Doe",
        "email": "john.doe@example.com",
        "query": "Where is the nearest café?",
        "location": "New York, NY"
    \}
}

Sample Output

URL encode/decode

URL encode/decode a specified string. Sample Input Sample Output

{
    "result": "Hello%20World%21%20How%20are%20you%3F"
}

Was this page helpful?