API reference
A service (Observables) and injection functions (Signals) for Angular 16+. Install with npm install @skyscribe-sdk/angular. See the Angular guide for walkthroughs.
Note
To fetch a Document by the slug in its URL, use getDocumentBySlug or injectDocumentBySlug. getDocument and injectDocument take the Document's record key (rkey) instead.
ScribeServiceScribeServiceAn injectable service (provided in root) whose methods return cold Observables: the fetch starts when you subscribe and is cancelled when you unsubscribe.
import { inject } from '@angular/core';
import { ScribeService } from '@skyscribe-sdk/angular';
const scribe = inject(ScribeService);
getPublicationgetPublication(author: string, publicationUrl: string): Observable<StandardPublication>
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL, e.g. "https://alice.bsky.social" |
Subscribe with the async pipe, which unsubscribes when the component is destroyed.
getDocumentBySluggetDocumentBySlug(author: string, publicationUrl: string, documentSlug: string): Observable<StandardDocument>
Looks a Document up by its slug in the Publication at publicationUrl, and emits it. Its uri is its AT URI.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
documentSlug | string | The Document's slug, as in its URL |
getDocumentgetDocument(author: string, rkey: string): Observable<StandardDocument>
Fetches a Document by its rkey.
| Parameter | Type | Description |
|---|---|---|
author | string | Handle or DID of the account the Document is stored in |
rkey | string | The Document's record key. Take both from a DocumentRef: the account is ref.uri.split('/')[2] and the rkey is slugFromUri(ref.uri) |
getPublicationUri / getDocumentUrigetPublicationUri(author: string, publicationUrl: string): Observable<string>
getDocumentUri(author: string, publicationUrl: string, documentSlug: string): Observable<string>
Return just the AT URI of a Publication, or of a Document looked up by its slug. The Observable versions of injectPublicationUri and injectDocumentUri below.
injectPublicationfunction injectPublication(author: string, publicationUrl: string): {
publication: Signal<StandardPublication | null>;
loading: Signal<boolean>;
error: Signal<Error | null>;
}
Must be called in an injection context. Fetches a Publication straight away and returns readonly signals. The request is aborted when the host component is destroyed.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL, e.g. "https://alice.bsky.social" |
injectDocumentBySlugfunction injectDocumentBySlug(author: string, publicationUrl: string, documentSlug: string): {
document: Signal<StandardDocument | null>; // document()?.uri is its AT URI
loading: Signal<boolean>;
error: Signal<Error | null>;
}
Must be called in an injection context. Looks a Document up by its slug in the Publication at publicationUrl and returns readonly signals. The request is aborted when the host component is destroyed.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
documentSlug | string | The Document's slug, as in its URL |
injectDocumentfunction injectDocument(author: string, rkey: string): {
document: Signal<StandardDocument | null>;
loading: Signal<boolean>;
error: Signal<Error | null>;
}
Must be called in an injection context. Fetches a Document by its rkey straight away and returns readonly signals. The request is aborted when the host component is destroyed.
| Parameter | Type | Description |
|---|---|---|
author | string | Handle or DID of the account the Document is stored in |
rkey | string | The Document's record key. Take both from a DocumentRef: the account is ref.uri.split('/')[2] and the rkey is slugFromUri(ref.uri) |
injectPublicationUrifunction injectPublicationUri(author: string, publicationUrl: string): {
uri: Signal<string | null>;
loading: Signal<boolean>;
error: Signal<Error | null>;
}
Must be called in an injection context. Resolves just the AT URI of a Publication (using resolvePublicationUri), without returning the whole StandardPublication. The request is aborted when the host component is destroyed.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
Use it when the AT URI is all you need, for example for your own subscribe UI.
injectDocumentUrifunction injectDocumentUri(
author: string,
publicationUrl: string,
documentSlug: string
): {
uri: Signal<string | null>;
loading: Signal<boolean>;
error: Signal<Error | null>;
}
Must be called in an injection context. Resolves just the AT URI of a Document, looked up by its slug (it uses fetchDocumentBySlug and keeps only the uri). The request is aborted when the host component is destroyed.
| Parameter | Type | Description |
|---|---|---|
author | string | Author handle or DID |
publicationUrl | string | The Publication's canonical HTTPS URL |
documentSlug | string | The Document's slug, as in its URL |
Use it when the AT URI is all you need, for example for your own like UI.
The main types from @skyscribe-sdk/core are re-exported:
import type { StandardPublication, StandardDocument, DocumentRef, Category } from '@skyscribe-sdk/angular';
See the core reference for type definitions.
ScribeService.getSite, getArticle and getArticleBySlug (still emitting { article, uri }), and injectSite (site), injectArticle (article) and injectArticleBySlug (article and uri) still work, marked @deprecated, until the next major. See Upgrading to 5.0.