Webmention¶
Discover a Webmention Endpoint¶
Webmention endpoint discovery is useful if you want to know if you can send webmentions to a site or if you want to send a webmention to a site.
You can discover if a URL has an associated webmention endpoint using the discover_webmention_endpoint function:
- indieweb_utils.discover_webmention_endpoint(target: str) WebmentionDiscoveryResponse [source]¶
Return the webmention endpoint for the given target.
- Parameters
target (str) – The target to discover the webmention endpoint for.
- Returns
The discovered webmention endpoint.
- Return type
import indieweb_utils target = "https://jamesg.blog/" webmention_endpoint = indieweb_utils.discover_webmention_endpoint( target ) print(webmention_endpoint) # https://webmention.jamesg.blog/webmention
- Raises
TargetNotProvided – Target is not provided.
WebmentionEndpointNotFound – Webmention endpoint is not found.
UnacceptableIPAddress – Endpoint does not connect to an accepted IP.
LocalhostEndpointFound – Discovered endpoint is equal to localhost.
If successful, this function returns the URL of the webmention endpoint associated with a resource. In this case, the message value is a blank string.
If a webmention endpoint could not be found, URL is equal to None. In this case, a string message value is provided that you can use for debugging or present to a user.
Send a Webmention¶
To send a webmention to a target, use this function:
- indieweb_utils.send_webmention(source: str, target: str, me: str = '') SendWebmentionResponse [source]¶
Send a webmention to a target URL.
- Parameters
- Returns
The response from the webmention endpoint.
- Return type
Example:
import indieweb_utils response = indieweb_utils.send_webmention( "https://example.com", "https://example.example.com/post/1", "https://test.example" )
- Raises
TargetIsNotApprovedDomain – Target is not in list of approved domains.
GenericWebmentionError – Generic webmention error.
CouldNotConnectToWebmentionEndpoint – Could not connect to the receiver’s webmention endpoint.
This function returns a SendWebmentionResponse object with this structure: