Posts

Link previews

link-preview-service

The card of a link: what a page says of itself, read by this installation, with its picture kept here. Optional: an installation may not run it (link-previews.md).

The preview of a link, for another service

GET/internal/link-previews

Inside the installation only: activitypub-service asks it for the card of a link in a post that came from another server. The gateway sends nobody from outside here.

The preview as it is kept, the key of its picture included, which the public route does not give out. A request that came through the gateway is answered 404.

Who: Anyone, signed in or not. Inside the installation only.

Parameters

  • urlstringrequiredin query
    The link: an http or https address. At most 2000 characters.

Answers

  • 200
    OK
    Preview application/json
  • 204
    there is nothing to show
  • 400
    the request is not well formed, or a value in it is not one it may be
  • 404
    it came through the gateway
  • 429
    the services have asked for too many lately

Request

curl "https://api.example.org/internal/link-previews?url=<url>"

Answer · 200

{
  "description": "string",
  "final_url": "https://example.org/",
  "image_key": "string",
  "site_name": "string",
  "status": "string",
  "title": "string",
  "url": "https://example.org/"
}

The preview of a link

GET/link-previews

Read from the page by this installation when no fresh preview is kept, so that nobody's browser asks the other site. For the composer, while a post is written.

Who: Somebody signed in

Parameters

  • urlstringrequiredin query
    The link: an http or https address. At most 2000 characters.

Answers

  • 200
    OK
  • 204
    there is nothing to show: the page could not be read, is not a page, or says nothing of itself
  • 400
    the request is not well formed, or a value in it is not one it may be
  • 401
    no token, or one that has expired
  • 429
    the viewer has asked for too many lately

Request

curl "https://api.example.org/link-previews?url=<url>" \
  -H "Authorization: Bearer $TOKEN"

Answer · 200

{
  "description": "string",
  "image": "string",
  "site_name": "string",
  "title": "string",
  "url": "https://example.org/"
}

The preview of a link

GET/link-previews/

Read from the page by this installation when no fresh preview is kept, so that nobody's browser asks the other site. For the composer, while a post is written.

Who: Somebody signed in

Parameters

  • urlstringrequiredin query
    The link: an http or https address. At most 2000 characters.

Answers

  • 200
    OK
  • 204
    there is nothing to show: the page could not be read, is not a page, or says nothing of itself
  • 400
    the request is not well formed, or a value in it is not one it may be
  • 401
    no token, or one that has expired
  • 429
    the viewer has asked for too many lately

Request

curl "https://api.example.org/link-previews/?url=<url>" \
  -H "Authorization: Bearer $TOKEN"

Answer · 200

{
  "description": "string",
  "image": "string",
  "site_name": "string",
  "title": "string",
  "url": "https://example.org/"
}

A preview's picture

GET/link-previews/image/{name}

A redirect to the picture in storage, at an address good for a short while.

Who: Anyone, signed in or not

Parameters

  • namestringrequiredin path
    The picture's name, as a preview's image gives it: the hash of the picture and its kind (<64 hex>.jpg).

Answers

  • 302
    the picture is at the address in Location
  • 404
    there is no such picture

Request

curl "https://api.example.org/link-previews/image/<name>"

Written by Claude, reviewed by Rastin Mehr · About this