# blue.microcosm.links.getManyToManyCounts

> Published by [microcosm.blue](https://lexicon.garden/identity/did:plc:lulmyldiq4sb2ikags5sfb25)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:lulmyldiq4sb2ikags5sfb25/blue.microcosm.links.getManyToManyCounts)
- [Documentation](https://lexicon.garden/lexicon/did:plc:lulmyldiq4sb2ikags5sfb25/blue.microcosm.links.getManyToManyCounts/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:lulmyldiq4sb2ikags5sfb25/blue.microcosm.links.getManyToManyCounts/examples)

## Definitions

### `blue.microcosm.links.getManyToManyCounts`

**Type**: `query`

count many-to-many relationships with secondary link paths

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `did` | `array` | No | filter links to those from specific users |
| `limit` | `integer` | No | number of results to return |
| `source` | `string` | Yes | collection and path specification for the primary link |
| `subject` | `string` (uri) | Yes | the primary target being linked to (at-uri, did, or uri) |
| `pathToOther` | `string` | Yes | path to the secondary link in the many-to-many record (e.g., 'otherThing.uri') |
| `otherSubject` | `array` | No | filter secondary links to specific subjects |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `cursor` | `string` | No | pagination cursor |
| `counts_by_other_subject` | `array` | Yes |  |

### `blue.microcosm.links.getManyToManyCounts#countBySubject`

**Type**: `object`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `total` | `integer` | Yes | total number of links to this subject |
| `subject` | `string` | Yes | the secondary subject being counted |
| `distinct` | `integer` | Yes | number of distinct DIDs linking to this subject |

## Raw Schema

```json
{
  "id": "blue.microcosm.links.getManyToManyCounts",
  "defs": {
    "main": {
      "type": "query",
      "output": {
        "schema": {
          "type": "object",
          "required": [
            "counts_by_other_subject"
          ],
          "properties": {
            "cursor": {
              "type": "string",
              "description": "pagination cursor"
            },
            "counts_by_other_subject": {
              "type": "array",
              "items": {
                "ref": "#countBySubject",
                "type": "ref"
              }
            }
          }
        },
        "encoding": "application/json"
      },
      "parameters": {
        "type": "params",
        "required": [
          "subject",
          "source",
          "pathToOther"
        ],
        "properties": {
          "did": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "did"
            },
            "description": "filter links to those from specific users"
          },
          "limit": {
            "type": "integer",
            "default": 16,
            "maximum": 100,
            "minimum": 1,
            "description": "number of results to return"
          },
          "source": {
            "type": "string",
            "description": "collection and path specification for the primary link"
          },
          "subject": {
            "type": "string",
            "format": "uri",
            "description": "the primary target being linked to (at-uri, did, or uri)"
          },
          "pathToOther": {
            "type": "string",
            "description": "path to the secondary link in the many-to-many record (e.g., 'otherThing.uri')"
          },
          "otherSubject": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "filter secondary links to specific subjects"
          }
        }
      },
      "description": "count many-to-many relationships with secondary link paths"
    },
    "countBySubject": {
      "type": "object",
      "required": [
        "subject",
        "total",
        "distinct"
      ],
      "properties": {
        "total": {
          "type": "integer",
          "description": "total number of links to this subject"
        },
        "subject": {
          "type": "string",
          "description": "the secondary subject being counted"
        },
        "distinct": {
          "type": "integer",
          "description": "number of distinct DIDs linking to this subject"
        }
      }
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
