### Install ntfy-api Python Package Source: https://github.com/tanrbobanr/ntfy-api/blob/main/README.md Instructions to install the ntfy-api Python library using pip. ```Shell pip install ntfy-api ``` -------------------------------- ### Example ntfy API JSON Response Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/invalid.txt This snippet shows a sample JSON object, illustrating a potential structure for responses or data payloads within the ntfy API. It demonstrates a simple key-value pair. ```JSON {"some_key_that_will_realistically_never_appear_in_the_standard_ntfy_responses":"value"} ``` -------------------------------- ### Example ntfy-api Message Event JSON Payload Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/received_delay.txt This snippet shows a typical JSON structure for a message event received from the ntfy-api. It demonstrates the format for event notifications, including unique identifiers, timestamps, event type, associated topic, and the actual message content. ```JSON {"id":"y6zmFB5A0alc","time":1736027349,"expires":1736070549,"event":"message","topic":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","message":"triggered"} ``` -------------------------------- ### Example Ntfy Message JSON Payload Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/received_long.txt This JSON object represents a complete ntfy message, demonstrating all possible fields and their data types. It includes details such as message ID, timestamp, topic, message content (with newlines), priority, associated tags, a click action URL, an icon URL, interactive actions, and an attachment. ```JSON {"id":"v9A2aAPD2QY5","time":1736027254,"expires":1736070454,"event":"message","topic":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","title":"title","message":"message\nwith\nnewlines","priority":5,"tags":["abacus","central_african_republic"],"click":"https://youtube.com","icon":"https://ntfy.sh/_next/static/media/logo.077f6a13.svg","actions":[{"id":"gZIg3J8hmF","action":"http","label":"label","clear":false,"url":"url","method":"GET"}],"attachment":{"name":"ntfy_logo.svg","url":"https://ntfy.sh/_next/static/media/logo.077f6a13.svg"},"content_type":"text/markdown"} ``` -------------------------------- ### Ntfy API Message JSON Structure Example Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/received_templating.txt This snippet shows a typical JSON object representing a message or event payload from the ntfy API. It includes unique identifiers, timestamps for creation and expiration, the event type, a topic identifier, and the message's title and content. This structure is common for push notification or event-driven systems. ```JSON {"id":"YY2dUeLnnRPd","time":1736028600,"expires":1736071800,"event":"message","topic":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","title":"phil-pc: A severe error has occurred","message":"Error message: Disk has run out of space"} ``` -------------------------------- ### ntfy_api.message.Message Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the Message class for constructing messages to be sent via ntfy. It includes numerous properties for message content, priority, tags, actions, and more, along with a method to get arguments. ```APIDOC Class: ntfy_api.message.Message (Inherits: (implied)) Properties: topic message title priority tags markdown delay templating actions click attachment filename icon email call cache firebase unified_push data Methods: get_args() ``` -------------------------------- ### Example ntfy API Message Payload Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/received_empty.txt This snippet shows a typical JSON structure for a message object within the ntfy API. It includes fields such as a unique identifier, timestamp, expiration time, event type, topic hash, and the message content itself. This structure is common for event-driven notifications received from or sent to the ntfy service. ```JSON {"id":"eYbSoQxDmcRu","time":1736190375,"expires":1736233575,"event":"message","topic":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","message":"triggered"} ``` -------------------------------- ### Ntfy Message Event with Attachment Payload Structure Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/received_local_attachment.txt This JSON payload represents a 'message' event from the ntfy.sh service, specifically when a file attachment is included. It contains details about the message itself, the topic it belongs to, and comprehensive metadata for the attachment, such as its name, type, size, expiration timestamp, and a direct URL to the file. ```JSON {"id":"memGzQhOBU0W","time":1736041039,"expires":1736084239,"event":"message","topic":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","message":"You received a file: attachment.gif","attachment":{"name":"attachment.gif","type":"image/gif","size":11321,"expires":1736051839,"url":"https://ntfy.sh/file/memGzQhOBU0W.gif"}} ``` -------------------------------- ### Python Project Build and Release Dependencies Source: https://github.com/tanrbobanr/ntfy-api/blob/main/requirements-build.txt Lists the Python packages necessary for the project's build and release process. This includes tools for packaging, building, and publishing, as well as HTTP client libraries. A specific version of `tomli` is required for Python versions older than 3.11. ```Python packaging build twine httpx tomli >= 1.1.0; python_version < "3.11" ``` -------------------------------- ### Send ntfy Messages with Python Source: https://github.com/tanrbobanr/ntfy-api/blob/main/README.md Demonstrates how to create an NtfyClient, construct a Message object with various parameters (topic, message, title, priority, tags, actions, attachments), and publish it using the client. ```Python import ntfy_api # create a client client = ntfy_api.NtfyClient( base_url="https://www.example.com", credentials=ntfy_api.Credentials(...), # if authorization is needed ) # create a message msg = Message( topic="my-topic", message="**Hello World**", title="Super Cool Message", priority=Priority.urgent, # or `5` tags=[Tag._100], # or `["100"]` markdown=True, delay="10m", actions=[ ViewAction(label="GOOGLE", url="https://google.com"), BroadcastAction( label="Take picture", extras={"cmd": "pic", "camera": "front"} ) ], click="https://youtube.com", attach="https://docs.ntfy.sh/static/img/ntfy.png", filename="ntfy_api.png", icon="https://ntfy.sh/_next/static/media/logo.077f6a13.svg" ) # send message client.publish(msg) ``` -------------------------------- ### ntfy_api.actions.ViewAction Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines a ViewAction class for opening URLs. It includes properties for label, URL, and clear, along with a serialization method. ```APIDOC Class: ntfy_api.actions.ViewAction (Inherits: (implied)) Properties: label url clear Methods: serialize() ``` -------------------------------- ### ntfy_api.client.NtfyClient Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the NtfyClient class for interacting with the ntfy service. It manages base URL, default topic, and credentials, providing methods for connecting, closing, publishing, polling, and subscribing. ```APIDOC Class: ntfy_api.client.NtfyClient Properties: base_url default_topic credentials Methods: connect() close() publish() poll() subscribe() __enter__() __exit__() ``` -------------------------------- ### ntfy_api.__version__.__download_url__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the download URL constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__download_url__ ``` -------------------------------- ### ntfy-api URL Utility Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Utility class for parsing and unparsing URLs, breaking them down into components like scheme, netloc, path, params, query, and fragment. ```APIDOC Class: ntfy_api._internals.URL Instance Variables: scheme: str netloc: str path: str params: str query: str fragment: str Methods: parse() unparse() ``` -------------------------------- ### ntfy_api.__version__.__description__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the description constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__description__ ``` -------------------------------- ### ntfy_api.__version__.version_info Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the version info constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.version_info ``` -------------------------------- ### ntfy_api.__version__.__version__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the version string constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__version__ ``` -------------------------------- ### ntfy_api.__version__.__license__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the license constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__license__ ``` -------------------------------- ### ntfy_api.__version__.__release__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the release constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__release__ ``` -------------------------------- ### ntfy_api.__version__.__copyright__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the copyright constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__copyright__ ``` -------------------------------- ### ntfy-api Version Information Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Defines the structure for version information of the ntfy-api package, including major, minor, micro, pre, post, and dev components, along with methods to generate string representations of the version. ```APIDOC Class: ntfy_api.__version__._version_info Inherits: (Parent class not specified in snippet) Properties: major: int minor: int micro: int pre: str post: str dev: str Methods: version_str() release_str() ``` -------------------------------- ### ntfy_api.__version__.__title__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the title constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__title__ ``` -------------------------------- ### ntfy_api.subscription.NtfySubscription Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the NtfySubscription class for managing subscriptions to ntfy topics. It handles base URL, credentials, filters, and message queues, with methods for connecting and closing subscriptions. ```APIDOC Class: ntfy_api.subscription.NtfySubscription Properties: base_url credentials filter max_queue_size messages topics Methods: close() connect() __enter__() __exit__() ``` -------------------------------- ### ntfy_api.__version__.__url__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the URL constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__url__ ``` -------------------------------- ### ntfy_api.actions.HTTPAction Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines an HTTPAction class for performing HTTP requests. It includes properties for label, URL, method, headers, body, and clear, along with a serialization method. ```APIDOC Class: ntfy_api.actions.HTTPAction (Inherits: (implied)) Properties: label url method headers body clear Methods: serialize() ``` -------------------------------- ### ntfy-api Wrapping Dataclass Base Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst A base dataclass providing a utility method to instantiate an object from a JSON dictionary. ```APIDOC Class: ntfy_api._internals.WrappingDataclass Methods: from_json() ``` -------------------------------- ### ntfy_api.creds.Credentials Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the Credentials class for managing authentication details, supporting basic and bearer tokens. It provides a method to retrieve the appropriate authorization header. ```APIDOC Class: ntfy_api.creds.Credentials Properties: basic bearer Methods: get_header() ``` -------------------------------- ### ntfy_api.actions.ReceivedBroadcastAction Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the ReceivedBroadcastAction class, representing a broadcast action received with a message. It includes properties for ID, label, clear, intent, and extras, along with a method to create from JSON. ```APIDOC Class: ntfy_api.actions.ReceivedBroadcastAction (Inherits: (implied)) Properties: id label clear intent extras Methods: from_json() ``` -------------------------------- ### ntfy_api.actions.ReceivedViewAction Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the ReceivedViewAction class, representing a view action received with a message. It includes properties for ID, label, URL, and clear, along with a method to create from JSON. ```APIDOC Class: ntfy_api.actions.ReceivedViewAction (Inherits: (implied)) Properties: id label url clear Methods: from_json() ``` -------------------------------- ### ntfy_api.actions.BroadcastAction Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines a BroadcastAction class, used for sending broadcast intents. It includes properties for label, intent, extras, and clear, along with a serialization method. ```APIDOC Class: ntfy_api.actions.BroadcastAction (Inherits: (implied)) Properties: label intent extras clear Methods: serialize() ``` -------------------------------- ### ntfy_api.__version__.__author__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the author information constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__author__ ``` -------------------------------- ### Poll and Subscribe to ntfy Messages in Python Source: https://github.com/tanrbobanr/ntfy-api/blob/main/README.md Illustrates two methods for receiving messages: polling a topic for messages and subscribing to a topic using a context manager to retrieve messages. ```Python # poll messages for msg in client.poll("my-topic"): print('>> Message received <<') print(f'Title: {msg.title}') print(f'Message: {msg.message}') print(f'Click: {msg.click}') if msg.attachment: print(f'Attachments: {msg.attachment}') # subscribe with client.subscribe("my-topic") as subscription: msg = subscription.messages.get() print('>> Message received <<') print(f'Title: {msg.title}') print(f'Message: {msg.message}') print(f'Click: {msg.click}') if msg.attachment: print(f'Attachments: {msg.attachment}') ``` -------------------------------- ### ntfy_api.actions.ReceivedHTTPAction Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the ReceivedHTTPAction class, representing an HTTP action received with a message. It includes properties for ID, label, URL, clear, method, headers, and body, along with a method to create from JSON. ```APIDOC Class: ntfy_api.actions.ReceivedHTTPAction() (Inherits: (implied)) Properties: id label url clear method headers body Methods: from_json() ``` -------------------------------- ### ntfy-api Action Base Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Base class for actions within the ntfy-api package, providing a serialization method for action objects. ```APIDOC Class: ntfy_api.actions._Action Methods: serialize() ``` -------------------------------- ### ntfy_api.__version__.__email__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the email constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__email__ ``` -------------------------------- ### ntfy-api Clearable Queue Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst A queue implementation that extends standard queue functionality with a method to clear all elements. ```APIDOC Class: ntfy_api._internals.ClearableQueue Inherits: (Parent class not specified in snippet) Methods: clear() ``` -------------------------------- ### ntfy_api.enums.HTTPMethod Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the HTTPMethod enumeration, representing standard HTTP request methods. ```APIDOC Class: ntfy_api.enums.HTTPMethod() (Inherits: (implied)) ``` -------------------------------- ### ntfy_api.__version__.__author_email__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the author's email constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__author_email__ ``` -------------------------------- ### ntfy_api.__version__.__cookie__ Constant Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the cookie constant for the ntfy-api package. ```APIDOC Constant: ntfy_api.__version__.__cookie__ ``` -------------------------------- ### ntfy_api.enums.Priority Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the Priority enumeration, representing different priority levels for ntfy messages. ```APIDOC Class: ntfy_api.enums.Priority() (Inherits: (implied)) ``` -------------------------------- ### ntfy_api.actions.ReceivedAction Type Alias Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the ReceivedAction type alias. ```APIDOC Type Alias: ntfy_api.actions.ReceivedAction -> ntfy_api.actions.ReceivedAction ``` -------------------------------- ### ntfy_api.errors.APIError Exception Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Reference to the APIError exception, indicating errors encountered during API operations. ```APIDOC Exception: ntfy_api.errors.APIError ``` -------------------------------- ### ntfy_api.message.ReceivedMessage Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the ReceivedMessage class, representing a message received from ntfy. It includes numerous properties detailing the message content, actions, attachments, and metadata. ```APIDOC Class: ntfy_api.message.ReceivedMessage() (Inherits: (implied)) Properties: actions attachment click content_type event expires icon id message priority tags time title topic ``` -------------------------------- ### ntfy-api Message Base Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Base class for messages within the ntfy-api package, providing a serialization method for message objects. ```APIDOC Class: ntfy_api.message._Message Methods: serialize() ``` -------------------------------- ### ntfy-api Received Message Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Represents a received ntfy message, including its content, metadata, and associated actions or attachments. ```APIDOC Class: ntfy_api.message._ReceivedMessage Inherits: (Parent class not specified in snippet) Instance Variables: actions: list attachment: ntfy_api.message._ReceivedAttachment click: str content_type: str event: str expires: int icon: str id: str message: str priority: int tags: list time: int title: str topic: str ``` -------------------------------- ### ntfy_api.enums.Event Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the Event enumeration, likely representing different types of events within the ntfy system. ```APIDOC Class: ntfy_api.enums.Event() (Inherits: (implied)) ``` -------------------------------- ### ntfy_api.enums.Tag Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the Tag enumeration, likely representing predefined tags for ntfy messages. ```APIDOC Class: ntfy_api.enums.Tag() (Inherits: (implied)) ``` -------------------------------- ### ntfy-api Filter Base Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Base class for filters within the ntfy-api package, providing a serialization method for filter objects. ```APIDOC Class: ntfy_api.filter._Filter Methods: serialize() ``` -------------------------------- ### ntfy_api.filter.Filter Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the Filter class for specifying criteria to filter messages, including properties like ID, message content, priority, and tags. It also includes a serialization method. ```APIDOC Class: ntfy_api.filter.Filter (Inherits: (implied)) Properties: id message priority scheduled since tags title Methods: serialize() ``` -------------------------------- ### ntfy-api Generic Type Variable Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst A generic type variable used internally for type hinting within the ntfy-api package. ```APIDOC Type Variable: ntfy_api._internals._T ``` -------------------------------- ### ntfy_api.message.ReceivedAttachment Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/api.rst Defines the ReceivedAttachment class, representing an attachment received with a message. It includes properties for expiration, name, size, type, and URL. ```APIDOC Class: ntfy_api.message.ReceivedAttachment (Inherits: (implied)) Properties: expires name size type url ``` -------------------------------- ### ntfy-api Received Attachment Class Reference Source: https://github.com/tanrbobanr/ntfy-api/blob/main/docs/internals.rst Represents an attachment received with a ntfy message, detailing its expiration, name, size, type, and URL. ```APIDOC Class: ntfy_api.message._ReceivedAttachment Inherits: (Parent class not specified in snippet) Instance Variables: expires: int name: str size: int type: str url: str ``` -------------------------------- ### ntfy API Error Response: Invalid Phone Number Source: https://github.com/tanrbobanr/ntfy-api/blob/main/tests/responses/sent_error.txt This snippet provides the JSON structure returned by the ntfy API when a publish request fails due to an invalid phone number. It includes the error code (40033), HTTP status (400), a descriptive error message, and a link to the official ntfy documentation for further context on phone call publishing. ```JSON {"code":40033,"http":400,"error":"invalid request: phone number invalid","link":"https://ntfy.sh/docs/publish/#phone-calls"} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.