Ready made code samples and short explanations to have you using the Table to Text APIs as quickly as possible.

First, the Body

The body of your API call should look like what is below. To get to a JSON like below, you should:

  1. Start with a table with columns named asset_id, time, name, and asset_class. See our Column Definitions page for a more detailed breakdown of what those columns require.
  2. In addition those columns, the table should also have whatever metric columns you would like to be described. As all metric columns will be evaluated, be sure to only include metric columns that you seek to include in your content.
  3. The column names of the metric columns will be used in the generated text, so be sure to name them as you see appropriate.
  4. Note that some of the endpoints in this category require ranked data -- meaning the metrics should refer to a rank of the given asset_id relative to asset_class along a given dimension. These endpoints will return an error if the metrics are not ranked data -- meaning they do not correspond to a percent rank, and thus should be between 0 and 100.
  5. Convert this table to JSON format
  6. Add your API key, as illustrated below
{
  "metric_df": [
    {
      "points": 52,
      "assists": 93,
      "rebounds": 88,
      "time": "2020-12-23",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 502,
      "assists": 913,
      "rebounds": 85,
      "time": "2020-12-21",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 52,
      "assists": 90,
      "rebounds": 87,
      "time": "2020-12-19",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 49,
      "assists": 96,
      "rebounds": 89,
      "time": "2020-12-17",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 48,
      "assists": 94,
      "rebounds": 90,
      "time": "2020-12-15",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    }
  ],
  "key": ["api_token_here"]
}

Then, the Whole Call

After you've got the body, you can wrap the whole thing in a POST call to one of our endpoints.
Describe trend is a place to start if you're not sure. :)

curl -XPOST -d '{
  "metric_df": [
    {
      "points": 52,
      "assists": 93,
      "rebounds": 88,
      "time": "2020-12-23",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 502,
      "assists": 913,
      "rebounds": 85,
      "time": "2020-12-21",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 52,
      "assists": 90,
      "rebounds": 87,
      "time": "2020-12-19",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 49,
      "assists": 96,
      "rebounds": 89,
      "time": "2020-12-17",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    },
    {
      "points": 48,
      "assists": 94,
      "rebounds": 90,
      "time": "2020-12-15",
      "asset_id": "Ben Simmons",
      "asset_class": "NBA players"
    }
  ],
  "key": ["api_token_here"]
}' 'https://generate-text-mrwwgrktvq-ue.a.run.app/latest-best-rank'