# aggregateOpenalexWorks

**Identifier:** `openalex_aggregateOpenalexWorks`

**Provider:** [OpenAlex](https://kirha.com/providers/openalex.md)

Get aggregate counts of works grouped by a dimension (year, type, OA status, institution, country, etc.).

## Run it with the CLI

```bash
kirha tools run openalex_aggregateOpenalexWorks \
  --input '{
    "groupBy": "publication_year"
  }'
```

`--input` takes a JSON object that matches the input schema. Pass `--input -` to read it from stdin.

## Call it over HTTP

```bash
curl https://api.kirha.com/tools/v1/execute \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'Authorization: **********' \
  --data '{
  "tool_name": "openalex_aggregateOpenalexWorks",
  "input": {
    "groupBy": "publication_year"
  }
}'
```

Replace the stars with an API key from https://app.kirha.com/api-keys.

## Input schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "authorIds": {
      "description": "Author OpenAlex IDs",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "fromDate": {
      "description": "YYYY-MM-DD",
      "type": "string"
    },
    "groupBy": {
      "enum": [
        "publication_year",
        "type",
        "open_access.oa_status",
        "is_oa",
        "primary_location.source.id",
        "primary_location.source.type",
        "authorships.institutions.id",
        "authorships.institutions.country_code",
        "authorships.institutions.continent",
        "topics.domain.id",
        "topics.field.id",
        "topics.subfield.id",
        "primary_topic.id",
        "language",
        "is_retracted"
      ],
      "type": "string"
    },
    "institutionIds": {
      "description": "Institution OpenAlex IDs",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "isOa": {
      "type": "boolean"
    },
    "search": {
      "type": "string"
    },
    "sourceIds": {
      "description": "Source OpenAlex IDs",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "toDate": {
      "description": "YYYY-MM-DD",
      "type": "string"
    },
    "topicIds": {
      "description": "Topic OpenAlex IDs",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "type": {
      "enum": [
        "article",
        "preprint",
        "book",
        "book-chapter",
        "dissertation",
        "dataset",
        "review",
        "report",
        "letter",
        "editorial",
        "grant",
        "software"
      ],
      "type": "string"
    }
  },
  "required": [
    "groupBy"
  ],
  "type": "object"
}
```

## Output schema

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "properties": {
    "context": {
      "type": "string"
    },
    "groups": {
      "items": {
        "additionalProperties": false,
        "properties": {
          "count": {
            "type": "number"
          },
          "key": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "name",
          "count"
        ],
        "type": "object"
      },
      "type": "array"
    },
    "groupsCount": {
      "type": "number"
    },
    "totalCount": {
      "type": "number"
    }
  },
  "required": [
    "context",
    "totalCount",
    "groupsCount",
    "groups"
  ],
  "type": "object"
}
```

-----

[All OpenAlex tools](https://kirha.com/providers/openalex.md) · [< Back to tools list](https://kirha.com/tools.md)