Anomaly Detector

The Anomaly Detection service detects anomalies automatically in time series data. It supports two functionalities, one is for detecting the whole series with model trained by the time series, another is detecting the last point with model trained by points before. By using this service, business customers can discover incidents and establish a logic flow for root cause analysis. To ensure online service quality is one of the main reasons we developed this service. Our team is dedicated to continuing to improve the anomaly detection service to provide precise results.

Find anomalies for the entire series in batch.

This operation generates a model using an entire series, each point is detected with the same model. With this method, points before and after a certain point are used to determine whether it is an anomaly. The entire detection can give the user an overall status of the time series.

Open API testing console

Request URL

Request headers

string
Media type of the body sent to the API.
string
Subscription key which provides access to this API. Found in your Cognitive Services accounts.

Request body

Time series points and period if needed. Advanced model parameters can also be set in the request.

{ 
  "series": [
  {
    "timestamp": "1972-01-01T00:00:00Z",
    "value": 826
  },
  {
    "timestamp": "1972-02-01T00:00:00Z",
    "value": 799
  },
  {
    "timestamp": "1972-03-01T00:00:00Z",
    "value": 890
  },
  {
    "timestamp": "1972-04-01T00:00:00Z",
    "value": 900
  },
  {
    "timestamp": "1972-05-01T00:00:00Z",
    "value": 961
  },
  {
    "timestamp": "1972-06-01T00:00:00Z",
    "value": 935
  },
  {
    "timestamp": "1972-07-01T00:00:00Z",
    "value": 894
  },
  {
    "timestamp": "1972-08-01T00:00:00Z",
    "value": 855
  },
  {
    "timestamp": "1972-09-01T00:00:00Z",
    "value": 809
  },
  {
    "timestamp": "1972-10-01T00:00:00Z",
    "value": 810
  },
  {
    "timestamp": "1972-11-01T00:00:00Z",
    "value": 766
  },
  {
    "timestamp": "1972-12-01T00:00:00Z",
    "value": 805
  },
  {
    "timestamp": "1973-01-01T00:00:00Z",
    "value": 821
  },
  {
    "timestamp": "1973-02-01T00:00:00Z",
    "value": 773
  },
  {
    "timestamp": "1973-03-01T00:00:00Z",
    "value": 883
  },
  {
    "timestamp": "1973-04-01T00:00:00Z",
    "value": 898
  },
  {
    "timestamp": "1973-05-01T00:00:00Z",
    "value": 957
  },
  {
    "timestamp": "1973-06-01T00:00:00Z",
    "value": 924
  },
  {
    "timestamp": "1973-07-01T00:00:00Z",
    "value": 881
  },
  {
    "timestamp": "1973-08-01T00:00:00Z",
    "value": 837
  },
  {
    "timestamp": "1973-09-01T00:00:00Z",
    "value": 784
  },
  {
    "timestamp": "1973-10-01T00:00:00Z",
    "value": 791
  },
  {
    "timestamp": "1973-11-01T00:00:00Z",
    "value": 760
  },
  {
    "timestamp": "1973-12-01T00:00:00Z",
    "value": 802
  },
  {
    "timestamp": "1974-01-01T00:00:00Z",
    "value": 828
  },
  {
    "timestamp": "1974-02-01T00:00:00Z",
    "value": 1030
  },
  {
    "timestamp": "1974-03-01T00:00:00Z",
    "value": 889
  },
  {
    "timestamp": "1974-04-01T00:00:00Z",
    "value": 902
  },
  {
    "timestamp": "1974-05-01T00:00:00Z",
    "value": 969
  },
  {
    "timestamp": "1974-06-01T00:00:00Z",
    "value": 947
  },
  {
    "timestamp": "1974-07-01T00:00:00Z",
    "value": 908
  },
  {
    "timestamp": "1974-08-01T00:00:00Z",
    "value": 867
  },
  {
    "timestamp": "1974-09-01T00:00:00Z",
    "value": 815
  },
  {
    "timestamp": "1974-10-01T00:00:00Z",
    "value": 812
  },
  {
    "timestamp": "1974-11-01T00:00:00Z",
    "value": 773
  },
  {
    "timestamp": "1974-12-01T00:00:00Z",
    "value": 813
  },
  {
    "timestamp": "1975-01-01T00:00:00Z",
    "value": 834
  },
  {
    "timestamp": "1975-02-01T00:00:00Z",
    "value": 782
  },
  {
    "timestamp": "1975-03-01T00:00:00Z",
    "value": 892
  },
  {
    "timestamp": "1975-04-01T00:00:00Z",
    "value": 903
  },
  {
    "timestamp": "1975-05-01T00:00:00Z",
    "value": 966
  },
  {
    "timestamp": "1975-06-01T00:00:00Z",
    "value": 937
  },
  {
    "timestamp": "1975-07-01T00:00:00Z",
    "value": 896
  },
  {
    "timestamp": "1975-08-01T00:00:00Z",
    "value": 858
  },
  {
    "timestamp": "1975-09-01T00:00:00Z",
    "value": 817
  },
  {
    "timestamp": "1975-10-01T00:00:00Z",
    "value": 827
  },
  {
    "timestamp": "1975-11-01T00:00:00Z",
    "value": 797
  },
  {
    "timestamp": "1975-12-01T00:00:00Z",
    "value": 843
  }
  ],
 "maxAnomalyRatio": 0.25,
 "sensitivity": 95,
 "granularity": "monthly"
}
{
  "type": "object",
  "required": [
    "granularity",
    "series"
  ],
  "properties": {
    "series": {
      "type": "array",
      "description": "Time series data points. Points should be sorted by timestamp in ascending order to match the anomaly detection result. If the data is not sorted correctly or there is duplicated timestamp, the API will not work. In such case, an error message will be returned.",
      "items": {
        "type": "object",
        "required": [
          "timestamp",
          "value"
        ],
        "properties": {
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "1972-01-01T00:00:00Z",
            "description": "Timestamp of a data point (ISO8601 format)."
          },
          "value": {
            "type": "number",
            "format": "float",
            "example": 826.0,
            "description": "The measurement of that point, should be float."
          }
        }
      }
    },
    "granularity": {
      "type": "string",
      "example": "daily",
      "description": "Can only be one of yearly, monthly, weekly, daily, hourly or minutely. Granularity is used for verify whether input series is valid."
    },
    "customInterval": {
      "type": "integer",
      "example": 5,
      "description": "Custom Interval is used to set non-standard time interval, for example, if the series is 5 minutes, request can be set as {\"granularity\":\"minutely\", \"customInterval\":5}."
    },
    "period": {
      "type": "integer",
      "format": "int32",
      "example": 7,
      "description": "Optional argument, periodic value of a time series. If the value is null or does not present, the API will determine the period automatically."
    },
    "maxAnomalyRatio": {
      "type": "number",
      "format": "float",
      "example": 0.25,
      "description": "Optional argument, advanced model parameter, max anomaly ratio in a time series."
    },
    "sensitivity": {
      "type": "number",
      "format": "integer",
      "example": 95,
      "description": "Optional argument, advanced model parameter, between 0-99, the lower the value is, the larger the margin value will be which means less anomalies will be accepted"
    }
  },
  "example": {
    "series": [
      {
        "timestamp": "1972-01-01T00:00:00Z",
        "value": 826
      },
      {
        "timestamp": "1972-02-01T00:00:00Z",
        "value": 799
      },
      {
        "timestamp": "1972-03-01T00:00:00Z",
        "value": 890
      },
      {
        "timestamp": "1972-04-01T00:00:00Z",
        "value": 900
      },
      {
        "timestamp": "1972-05-01T00:00:00Z",
        "value": 961
      },
      {
        "timestamp": "1972-06-01T00:00:00Z",
        "value": 935
      },
      {
        "timestamp": "1972-07-01T00:00:00Z",
        "value": 894
      },
      {
        "timestamp": "1972-08-01T00:00:00Z",
        "value": 855
      },
      {
        "timestamp": "1972-09-01T00:00:00Z",
        "value": 809
      },
      {
        "timestamp": "1972-10-01T00:00:00Z",
        "value": 810
      },
      {
        "timestamp": "1972-11-01T00:00:00Z",
        "value": 766
      },
      {
        "timestamp": "1972-12-01T00:00:00Z",
        "value": 805
      },
      {
        "timestamp": "1973-01-01T00:00:00Z",
        "value": 821
      },
      {
        "timestamp": "1973-02-01T00:00:00Z",
        "value": 773
      },
      {
        "timestamp": "1973-03-01T00:00:00Z",
        "value": 883
      },
      {
        "timestamp": "1973-04-01T00:00:00Z",
        "value": 898
      },
      {
        "timestamp": "1973-05-01T00:00:00Z",
        "value": 957
      },
      {
        "timestamp": "1973-06-01T00:00:00Z",
        "value": 924
      },
      {
        "timestamp": "1973-07-01T00:00:00Z",
        "value": 881
      },
      {
        "timestamp": "1973-08-01T00:00:00Z",
        "value": 837
      },
      {
        "timestamp": "1973-09-01T00:00:00Z",
        "value": 784
      },
      {
        "timestamp": "1973-10-01T00:00:00Z",
        "value": 791
      },
      {
        "timestamp": "1973-11-01T00:00:00Z",
        "value": 760
      },
      {
        "timestamp": "1973-12-01T00:00:00Z",
        "value": 802
      },
      {
        "timestamp": "1974-01-01T00:00:00Z",
        "value": 828
      },
      {
        "timestamp": "1974-02-01T00:00:00Z",
        "value": 1030
      },
      {
        "timestamp": "1974-03-01T00:00:00Z",
        "value": 889
      },
      {
        "timestamp": "1974-04-01T00:00:00Z",
        "value": 902
      },
      {
        "timestamp": "1974-05-01T00:00:00Z",
        "value": 969
      },
      {
        "timestamp": "1974-06-01T00:00:00Z",
        "value": 947
      },
      {
        "timestamp": "1974-07-01T00:00:00Z",
        "value": 908
      },
      {
        "timestamp": "1974-08-01T00:00:00Z",
        "value": 867
      },
      {
        "timestamp": "1974-09-01T00:00:00Z",
        "value": 815
      },
      {
        "timestamp": "1974-10-01T00:00:00Z",
        "value": 812
      },
      {
        "timestamp": "1974-11-01T00:00:00Z",
        "value": 773
      },
      {
        "timestamp": "1974-12-01T00:00:00Z",
        "value": 813
      },
      {
        "timestamp": "1975-01-01T00:00:00Z",
        "value": 834
      },
      {
        "timestamp": "1975-02-01T00:00:00Z",
        "value": 782
      },
      {
        "timestamp": "1975-03-01T00:00:00Z",
        "value": 892
      },
      {
        "timestamp": "1975-04-01T00:00:00Z",
        "value": 903
      },
      {
        "timestamp": "1975-05-01T00:00:00Z",
        "value": 966
      },
      {
        "timestamp": "1975-06-01T00:00:00Z",
        "value": 937
      },
      {
        "timestamp": "1975-07-01T00:00:00Z",
        "value": 896
      },
      {
        "timestamp": "1975-08-01T00:00:00Z",
        "value": 858
      },
      {
        "timestamp": "1975-09-01T00:00:00Z",
        "value": 817
      },
      {
        "timestamp": "1975-10-01T00:00:00Z",
        "value": 827
      },
      {
        "timestamp": "1975-11-01T00:00:00Z",
        "value": 797
      },
      {
        "timestamp": "1975-12-01T00:00:00Z",
        "value": 843
      }
    ],
    "maxAnomalyRatio": 0.25,
    "sensitivity": 95,
    "granularity": "monthly"
  }
}

Response 200

Successful operation.

{
  "expectedValues": [
    827.7940908243968,
    798.9133774671927,
    888.6058431807189,
    900.5606407986661,
    962.8389426378304,
    933.2591606306954,
    891.0784104799666,
    856.1781601363697,
    809.8987227908941,
    807.375129007505,
    764.3196682448518,
    803.933498594564,
    823.5900620883058,
    794.0905641334288,
    883.164245249282,
    894.8419000690953,
    956.8430591101258,
    927.6285055190114,
    885.812983784303,
    851.6424797402517,
    806.0927886943216,
    804.6826815312029,
    762.74070738882,
    804.0251702513732,
    825.3523662579559,
    798.0404188724976,
    889.3016505577698,
    902.4226124345937,
    965.867078532635,
    937.3200495736695,
    896.1720524711102,
    862.0087368413656,
    816.4662342097423,
    814.4297745524709,
    771.8614479159354,
    811.859271346729,
    831.8998279215521,
    802.947544797165,
    892.5684407435083,
    904.5488214533809,
    966.8527063844707,
    937.3168391003043,
    895.180003672544,
    860.3649596356635,
    814.1707285969043,
    811.9054862686213,
    769.1083769610742,
    809.2328084659704
  ],
  "upperMargins": [
    41.389704541219835,
    39.94566887335964,
    44.43029215903594,
    45.02803203993331,
    48.14194713189152,
    46.66295803153477,
    44.55392052399833,
    42.808908006818484,
    40.494936139544706,
    40.36875645037525,
    38.215983412242586,
    40.196674929728196,
    41.17950310441529,
    39.70452820667144,
    44.1582122624641,
    44.74209500345477,
    47.84215295550629,
    46.38142527595057,
    44.290649189215145,
    42.58212398701258,
    40.30463943471608,
    40.234134076560146,
    38.137035369441,
    40.201258512568664,
    41.267618312897795,
    39.90202094362488,
    44.46508252788849,
    45.121130621729684,
    48.29335392663175,
    46.86600247868348,
    44.80860262355551,
    43.100436842068284,
    40.82331171048711,
    40.721488727623544,
    38.593072395796774,
    40.59296356733645,
    41.5949913960776,
    40.14737723985825,
    44.62842203717541,
    45.227441072669045,
    48.34263531922354,
    46.86584195501521,
    44.759000183627194,
    43.01824798178317,
    40.70853642984521,
    40.59527431343106,
    38.45541884805371,
    40.46164042329852
  ],
  "lowerMargins": [
    41.389704541219835,
    39.94566887335964,
    44.43029215903594,
    45.02803203993331,
    48.14194713189152,
    46.66295803153477,
    44.55392052399833,
    42.808908006818484,
    40.494936139544706,
    40.36875645037525,
    38.215983412242586,
    40.196674929728196,
    41.17950310441529,
    39.70452820667144,
    44.1582122624641,
    44.74209500345477,
    47.84215295550629,
    46.38142527595057,
    44.290649189215145,
    42.58212398701258,
    40.30463943471608,
    40.234134076560146,
    38.137035369441,
    40.201258512568664,
    41.267618312897795,
    39.90202094362488,
    44.46508252788849,
    45.121130621729684,
    48.29335392663175,
    46.86600247868348,
    44.80860262355551,
    43.100436842068284,
    40.82331171048711,
    40.721488727623544,
    38.593072395796774,
    40.59296356733645,
    41.5949913960776,
    40.14737723985825,
    44.62842203717541,
    45.227441072669045,
    48.34263531922354,
    46.86584195501521,
    44.759000183627194,
    43.01824798178317,
    40.70853642984521,
    40.59527431343106,
    38.45541884805371,
    40.46164042329852
  ],
  "isAnomaly": [
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    true,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false
  ],
  "isPositiveAnomaly": [
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    true,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false
  ],
  "isNegativeAnomaly": [
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false,
    false
  ],
  "period": 12
}

Response 400

Possible Errors:

  • BadArgument
    Invalid json format, input data is Empty.
    The 'series' field is required in request.
    The 'granularity' field is required in request.
    The 'series' field cannot be empty.
    The 'series' field must be array/list type.
    'timestamp' or 'value' is malformed in 'series' Field.
    The 'series' field cannot have none values.
  • InvalidCustomInterval
    The 'customInterval' field must be an integer > 0.
  • InvalidGranularity
    The 'granularity' field can only be one of the following: ['daily', 'minutely', 'hourly', 'weekly', 'monthly', 'yearly'].
  • InvalidPeriod
    The 'period' field must be an integer >= 0.
  • InvalidModelArgument
    The 'maxAnomalyRatio' field must be less than 50% of the series points (0 < maxAnomalyRatio < 0.5).
    The 'sensitivity' field must be an integer between 0 and 99.
    The 'series' field must have more than 2 periods points.
  • InvalidSeries
    The 'series' field must be sorted by timestamp in ascending order.
    The 'series' field cannot have duplicated timestamp.
    Time points should be uniformly spaced in time in minutely granularity with 1 gran as interval, ratio of missing points should be less than 10%.
    The 'series' field must have at least 12 points.
    The 'series' field cannot have more than 8640 points.

{
  "code" : "InvalidSeries",
  "message" : "The 'series' field cannot be empty."
}

Response 403

The certificate you provided is not accepted by server.

Response 405

Method Not Allowed.

Response 500

Internal Server Error.

Code samples

@ECHO OFF

curl -v -X POST "https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"

--data-ascii "{body}" 
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;

namespace CSHttpClientSample
{
    static class Program
    {
        static void Main()
        {
            MakeRequest();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
        
        static async void MakeRequest()
        {
            var client = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");

            var uri = "https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect?" + queryString;

            HttpResponseMessage response;

            // Request body
            byte[] byteData = Encoding.UTF8.GetBytes("{body}");

            using (var content = new ByteArrayContent(byteData))
            {
               content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
               response = await client.PostAsync(uri, content);
            }

        }
    }
}	
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class JavaSample 
{
    public static void main(String[] args) 
    {
        HttpClient httpclient = HttpClients.createDefault();

        try
        {
            URIBuilder builder = new URIBuilder("https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect");


            URI uri = builder.build();
            HttpPost request = new HttpPost(uri);
            request.setHeader("Content-Type", "application/json");
            request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");


            // Request body
            StringEntity reqEntity = new StringEntity("{body}");
            request.setEntity(reqEntity);

            HttpResponse response = httpclient.execute(request);
            HttpEntity entity = response.getEntity();

            if (entity != null) 
            {
                System.out.println(EntityUtils.toString(entity));
            }
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }
    }
}

<!DOCTYPE html>
<html>
<head>
    <title>JSSample</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>

<script type="text/javascript">
    $(function() {
        var params = {
            // Request parameters
        };
      
        $.ajax({
            url: "https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect?" + $.param(params),
            beforeSend: function(xhrObj){
                // Request headers
                xhrObj.setRequestHeader("Content-Type","application/json");
                xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
            },
            type: "POST",
            // Request body
            data: "{body}",
        })
        .done(function(data) {
            alert("success");
        })
        .fail(function() {
            alert("error");
        });
    });
</script>
</body>
</html>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    
    NSString* path = @"https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                      ];
    
    NSString* string = [array componentsJoinedByString:@"&"];
    path = [path stringByAppendingFormat:@"?%@", string];

    NSLog(@"%@", path);

    NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
    [_request setHTTPMethod:@"POST"];
    // Request headers
    [_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
    // Request body
    [_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSURLResponse *response = nil;
    NSError *error = nil;
    NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];

    if (nil != error)
    {
        NSLog(@"Error: %@", error);
    }
    else
    {
        NSError* error = nil;
        NSMutableDictionary* json = nil;
        NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
        NSLog(@"%@", dataString);
        
        if (nil != _connectionData)
        {
            json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
        }
        
        if (error || !json)
        {
            NSLog(@"Could not parse loaded json with error:%@", error);
        }
        
        NSLog(@"%@", json);
        _connectionData = nil;
    }
    
    [pool drain];

    return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';

$request = new Http_Request2('https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'Content-Type' => 'application/json',
    'Ocp-Apim-Subscription-Key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
);

$url->setQueryVariables($parameters);

$request->setMethod(HTTP_Request2::METHOD_POST);

// Request body
$request->setBody("{body}");

try
{
    $response = $request->send();
    echo $response->getBody();
}
catch (HttpException $ex)
{
    echo $ex;
}

?>
########### Python 2.7 #############
import httplib, urllib, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.urlencode({
})

try:
    conn = httplib.HTTPSConnection('westus2.api.cognitive.microsoft.com')
    conn.request("POST", "/anomalydetector/v1.0/timeseries/entire/detect?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################

########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64

headers = {
    # Request headers
    'Content-Type': 'application/json',
    'Ocp-Apim-Subscription-Key': '{subscription key}',
}

params = urllib.parse.urlencode({
})

try:
    conn = http.client.HTTPSConnection('westus2.api.cognitive.microsoft.com')
    conn.request("POST", "/anomalydetector/v1.0/timeseries/entire/detect?%s" % params, "{body}", headers)
    response = conn.getresponse()
    data = response.read()
    print(data)
    conn.close()
except Exception as e:
    print("[Errno {0}] {1}".format(e.errno, e.strerror))

####################################
require 'net/http'

uri = URI('https://westus2.api.cognitive.microsoft.com/anomalydetector/v1.0/timeseries/entire/detect')
uri.query = URI.encode_www_form({
})

request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"

response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
    http.request(request)
end

puts response.body