Skip to content

Commit

Permalink
Fix some nits
Browse files Browse the repository at this point in the history
  • Loading branch information
halcy authored and halcy committed Nov 28, 2022
1 parent 43c7d7c commit 1704965
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
10 changes: 10 additions & 0 deletions docs/01_general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,16 @@ you can also just write
and everything will work as intended.

Snowflake IDs
~~~~~~~~~~~~~
Some IDs in Mastodon (such as those for statuses) are Snowflake IDs. These broadly
correspond to times, with a low resolution, so it is possible to convert a time to
a Snowflake ID and search for posts between two dates. Mastodon.py will do the
conversion for you automatically when you pass a `datetime` object as the id.

Note that this functionality will *not* work on anything but Mastodon and forks,
and that it is somewhat inexact due to the relatively low resolution.

Versioning
----------
Mastodon.py will check if a certain endpoint is available before doing API
Expand Down
33 changes: 20 additions & 13 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,53 @@ Mastodon.py
.. py:module:: mastodon
.. py:class: Mastodon
Usage
-----
Register your app! This only needs to be done once. Uncomment the code and substitute in your information:

.. code-block:: python
from mastodon import Mastodon
from mastodon import Mastodon
'''
Mastodon.create_app(
'''
Mastodon.create_app(
'pytooterapp',
api_base_url = 'https://mastodon.social',
to_file = 'pytooter_clientcred.secret'
)
'''
)
'''
Then login. This can be done every time, or you can use the persisted information:

.. code-block:: python
from mastodon import Mastodon
from mastodon import Mastodon
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
mastodon.log_in('my_login_email@example.com', 'incrediblygoodpassword', to_file = 'pytooter_usercred.secret')
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
mastodon.log_in(
'my_login_email@example.com',
'incrediblygoodpassword',
to_file = 'pytooter_usercred.secret'
)
To post, create an actual API instance:

.. code-block:: python
from mastodon import Mastodon
from mastodon import Mastodon
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')
mastodon.toot('Tooting from Python using #mastodonpy !')
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')
mastodon.toot('Tooting from Python using #mastodonpy !')
Introduction
------------
`Mastodon`_ is an ActivityPub-based Twitter-like federated social
network node. It has an API that allows you to interact with its
every aspect. This is a simple Python wrapper for that API, provided
as a single Python module.

Mastodon.py aims to implement the complete public Mastodon API. As
of this time, it is feature complete for Mastodon version 3.5.0. The
of this time, it is feature complete for Mastodon version 3.5.3. The
Mastodon compatible API layers of various other pieces of software as well
as forks, while not an official target, should also be basically
compatible, and Mastodon.py does make some allowances for behaviour that isn't
Expand Down Expand Up @@ -85,4 +93,3 @@ about who helped with which particular feature or fix in the changelog.

14_contributing
15_everything

0 comments on commit 1704965

Please sign in to comment.