<commit_before># Apollo ${project_version} Management API

{:toc:2-5}

## Overview

Apollo's REST API runs on port 61680 or via SSL on port 61681. If your
running an Apollo broker on your local machine, you could access the
API at the following HTTP URLs:

    http://localhost:61680
    https://localhost:61681

For all of the rest of this document, we will be leaving off that part,
since it is the same for every API call.

### Authentication

The broker requires all requests against the management API to supply
user credentials which have administration privileges.

The user credentials should be supplied using via HTTP basic
authentication. Example:

    $ curl -u "admin:password" http://localhost:61680/broker

### JSON Representation

The API routes are intended to be access programmatically as JSON
services but they also provide an HTML representation so that the API
services can easily be browsed using a standard web browser.

You must either set the HTTP `Accept` header to `application/json` or
append `.json` to the URL to get the JSON representation of the data. 
Example:

    $ curl -H "Accept: application/json" -u "admin:password" \
    http://localhost:61680/broker

    $ curl -u "admin:password" http://localhost:61680/broker.json

### Working with Tabular Results

Many of the resource routes provided by the broker implement
a selectable paged tabular interface.  A good example of such
a resource route is the connections list.  It's route is:

    /broker/connections

Example:

    $ curl -u "admin:password" \
    'http://localhost:61680/broker/connections.json'
    
Results in a [Data Page](./api/apollo-dto/org/apache/activemq/apollo/dto/DataPageDTO.html) :

{pygmentize:: js}
{
  "page":0,
  "page_size":100,
  "total_pages":1,
  "total_rows":2,
  "headers":[
    "*"
  ],
  "rows":[
    {
      "id":"4",
      "state":"STARTED",
      "state_since":1306848325102,
      "read_counter":103,
      "write_counter":239110628,
      "transport":"tcp",
      "protocol":"stomp",
      "remote_address":"/127.0.0.1:61775",
      "protocol_version":"1.0",
      "user":"admin",
      "waiting_on":"client request",
      "subscription_count":1
    },
    {
      "id":"5",
      "state":"STARTED",
      "state_since":1306848325102,
      "read_counter":227739229,
      "write_counter":113,
      "transport":"tcp",
      "protocol":"stomp",
      "remote_address":"/127.0.0.1:61776",
      "protocol_version":"1.0",
      "user":"admin",
      "waiting_on":"blocked sending to: org.apache.activemq.apollo.broker.Queue$$anon$1@13765e9b",
      "subscription_count":0
    }
  ]
}
{pygmentiz}

The `*` header field means the record was selected. To narrow down the selected fields you can add
multiple `f` query parameters to pick the fields you want to retrieve.

Example:

    $ curl -u "admin:password" \
    'http://localhost:61680/broker/connections.json?f=id&f=read_counter'
    
Results in :

{pygmentize:: js}
{
  "page":0,
  "page_size":100,
  "total_pages":1,
  "total_rows":2,
  "headers":[
    "id",
    "read_counter"
  ],
  "rows":[
    [
      "7",
      110733109
    ],
    [
      "6",
      103
    ]
  ]
}
{pygmentiz}
    

If you want to narrow down the records which get selected, you can set a `q`
query parameter to SQL 92 style where clause which uses the record's fields
to filter down the selected records.

For example to only view local connection, you would want to use a where<commit_msg>Fixes https://issues.apache.org/jira/browse/APLO-65 : Typos in Apollo Management API doc<commit_after># Apollo ${project_version} Management API

{:toc:2-5}

## Overview

Apollo's REST API runs on port 61680 or via SSL on port 61681. If your
running an Apollo broker on your local machine, you could access the
API at the following HTTP URLs:

    http://localhost:61680
    https://localhost:61681

For all of the rest of this document, we will be leaving off that part,
since it is the same for every API call.

### Authentication

The broker requires all requests against the management API to supply
user credentials which have administration privileges.

The user credentials should be supplied using via HTTP basic
authentication. Example:

    $ curl -u "admin:password" http://localhost:61680/broker

### JSON Representation

The API routes are intended to be access programmatically as JSON
services but they also provide an HTML representation so that the API
services can easily be browsed using a standard web browser.

You must either set the HTTP `Accept` header to `application/json` or
append `.json` to the URL to get the JSON representation of the data. 
Example:

    $ curl -H "Accept: application/json" -u "admin:password" \
    http://localhost:61680/broker

    $ curl -u "admin:password" http://localhost:61680/broker.json

### Working with Tabular Results

Many of the resource routes provided by the broker implement
a selectable paged tabular interface.  A good example of such
a resource route is the connections list.  It's route is:

    /broker/connections

Example:

    $ curl -u "admin:password" \
    'http://localhost:61680/broker/connections.json'
    
Results in a [Data Page](./api/apollo-dto/org/apache/activemq/apollo/dto/DataPageDTO.html) :

{pygmentize:: js}
{
  "page":0,
  "page_size":100,
  "total_pages":1,
  "total_rows":2,
  "headers":[
    "*"
  ],
  "rows":[
    {
      "id":"4",
      "state":"STARTED",
      "state_since":1306848325102,
      "read_counter":103,
      "write_counter":239110628,
      "transport":"tcp",
      "protocol":"stomp",
      "remote_address":"/127.0.0.1:61775",
      "protocol_version":"1.0",
      "user":"admin",
      "waiting_on":"client request",
      "subscription_count":1
    },
    {
      "id":"5",
      "state":"STARTED",
      "state_since":1306848325102,
      "read_counter":227739229,
      "write_counter":113,
      "transport":"tcp",
      "protocol":"stomp",
      "remote_address":"/127.0.0.1:61776",
      "protocol_version":"1.0",
      "user":"admin",
      "waiting_on":"blocked sending to: org.apache.activemq.apollo.broker.Queue$$anon$1@13765e9b",
      "subscription_count":0
    }
  ]
}
{pygmentize}

The `*` header field means the record was selected. To narrow down the selected fields you can add
multiple `f` query parameters to pick the fields you want to retrieve.

Example:

    $ curl -u "admin:password" \
    'http://localhost:61680/broker/connections.json?f=id&f=read_counter'
    
Results in :

{pygmentize:: js}
{
  "page":0,
  "page_size":100,
  "total_pages":1,
  "total_rows":2,
  "headers":[
    "id",
    "read_counter"
  ],
  "rows":[
    [
      "7",
      110733109
    ],
    [
      "6",
      103
    ]
  ]
}
{pygmentize}
    

If you want to narrow down the records which get selected, you can set a `q`
query parameter to SQL 92 style where clause which uses the record's fields
to filter down the selected records.

For example to only view local connection, you would want to use a where
{'fraction_non_alphanumeric': 0.11688869789428448, 'fraction_numerical': 0.04669818077639307, 'mean_word_length': 3.3610243597751404, 'pattern_counts': {'":': 72, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7551983', 'n_tokens_mistral': 2408, 'n_tokens_neox': 2175, 'n_words': 712}