# activitypub-types

> ActivityPub Typescript types

Latest version **1.1.0** (published 2024-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install activitypub-types
pnpm add activitypub-types
yarn add activitypub-types
bun add activitypub-types
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-02-28 |
| First published | 2023-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 72.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | SiranWeb |
| Maintainers | siranweb |
| Keywords | activitypub, typescript, types, models, activitystreams |

## Links

- npm: https://www.npmjs.com/package/activitypub-types
- Repository: https://github.com/SiranWeb/activitypub-types
- Homepage: https://github.com/SiranWeb/activitypub-types#readme
- Issues: https://github.com/SiranWeb/activitypub-types/issues
- npm.io page: https://npm.io/package/activitypub-types

## Recent versions

- 1.1.0 (latest) — 2024-02-28
- 1.0.3 — 2023-09-07
- 1.0.2 — 2023-09-02
- 1.0.1 — 2023-03-11
- 1.0.0 — 2023-03-11

## README

# ActivityPub Types
TypeScript typings for ActivityPub

## Installation
```bash
npm i activitypub-types
# or
yarn add activitypub-types
```

## How to use
Implemented and documented every structure from [specification](https://www.w3.org/TR/activitystreams-vocabulary).
You can use interfaces and extend them by yourself, or you can use specified fields types.

To specify object use correct type:
```ts
import { APAdd } from 'activitypub-types';
const addActivity: APAdd = {
    type: 'Add',
    actor: 'https://actor.example.org',
    // ...
}
```
Fields in types are pretty flexible, so you can pass different variations:
```ts
import { APAdd, APActor } from 'activitypub-types';

const actor1 = 'https://actor.example.org';

const actor2: APActor = {
    type: 'Person',
    id: 'https://actor2.example.org',
    summary: 'Another actor',
    inbox: 'https://actor2.example.org/inbox',
    outbox: 'https://actor2.example.org/outbox',
};

const addActivity: APAdd = {
    type: 'Add',
    actor: [actor1, actor2],
    // ...
};
```

To provide `@context` field use `APRoot`:
```typescript
import { APAdd, APRoot } from 'activitypub-types';

const addActivity: APRoot<APAdd> = {
    '@context': 'https://www.w3.org/ns/activitystreams',
    type: 'Add',
    // ...
}
```

If you need field types themselves, you can import as well:
```typescript
import { TypeField, NameField } from 'activitypub-types';

interface APExample {
    type: TypeField;
    name?: NameField;
    // ...
}
```

## Changelog
### v1.1.0
- Update activities and documents types ([#3](https://github.com/siranweb/activitypub-types/pull/3), by [@Saiv46](https://github.com/Saiv46))
- Add `APRoot` type and removed `@context` from `APObject` ([#5](https://github.com/siranweb/activitypub-types/pull/5))
- Improve AP documentation ([#3](https://github.com/siranweb/activitypub-types/pull/3), by [@Saiv46](https://github.com/Saiv46))
- Update README docs
- Refactor ([#3](https://github.com/siranweb/activitypub-types/pull/3), by [@Saiv46](https://github.com/Saiv46))

### v1.0.3
- Use `orderedItems` instead of `items` in `OrderedCollection` ([#1](https://github.com/siranweb/activitypub-types/pull/1), by [@RangerMauve](https://github.com/RangerMauve))

## License
[MIT](LICENSE)

---
_Source: https://npm.io/package/activitypub-types · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
