Skip to main content

Hashnode_Py, The python client to interact with hashnode graphql api

Project description

Hashnode_Py

hashnode_py is a Python package designed to interact with the Hashnode GraphQL API. With this library, you have the ability to publish, update, or delete your articles and drafts. Additionally, it offers various functionalities to seamlessly interact with your publication directly from your code.

Features

  • Publish, Update, and Delete Articles/Drafts
  • Get your hashnode data including: posts, publications, followers, subscriptions and many more
  • Access your feed posts and apply filters

Installation

Install hashnode_py with pip

  pip install hashnode-py

Usage/Examples

First get your Hashnode Personal Access Token from here

Then jump in to your code

from hashnode_py import HashnodeClient

client = HashnodeClient("...ad0a")

Publish New Article

publication = client.get_publication("<YOUR_BLOG_DOMAIN_NAME>")

print(publication.publish_post(
            title="this is test title",
            content="this is a test content",
            tags_slug=[{"slug": "test", "name": "Test"}]
        ))

The message will be displayed indicating that the post has been successfully published, along with the post's ID.

Update The Article

post_id = "POST_ID"

print(publication.update_post(post_id=post_id, title="[UPDATE] this is test title"))

The message will be displayed indicating that the post has been successfully updated, along with the post's ID.

Delete The Article

print(publication.remove_post(post_id=post_id))

The message will be displayed indicating that the post has been successfully removed, along with the post's ID.

Publish Draft

draft = publication.get_drafts()[0]

print(publication.publish_draft(draft_id=draft.id))

The message will be displayed indicating that the draft has been successfully published, along with the post's ID.

License

MIT

Contributing

Contributions are always welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hashnode_py-0.0.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

hashnode_py-0.0.1-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file hashnode_py-0.0.1.tar.gz.

File metadata

  • Download URL: hashnode_py-0.0.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for hashnode_py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 61609f20dbde6c884911f1288f904a0c3f47102702f6854f946f29bdbeb38956
MD5 9c64d14f98c5ee6bd9384de0c6f4c8ff
BLAKE2b-256 47028e710787b22394533c97d1d2a77a7b72db92ce8b9f583bae89811139734e

See more details on using hashes here.

File details

Details for the file hashnode_py-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: hashnode_py-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for hashnode_py-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 783823d15efba45c56a3c1d085d5a2886fdc1037e5789b528e9ca234c03ce814
MD5 dacf61ba9714f550b5e2dc98774ab6d2
BLAKE2b-256 e831085ea4d9badf848589e6c575c69ad544f18b38580dc7a59d53df01d22872

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page