Skip to main content

No project description provided

Project description

BlueSky API Data Wrapper

This is built as a wrapper for the atproto package. While that package is fantastic, it can be a bit tricky to navigate. This package will hopefully give a productive user experience.

Installation

pip install bskydata

Example usage

import os
from dotenv import load_dotenv
from bskydata.api.client import BskyApiClient
from bskytdata.agents.agent import BskyAgent
from bskydata.scrapers.search_terms import SearchTermScraper
from bskydata.scrapers.profiles import ProfileScraper
from bskydata.storage.writers import JsonFileWriter
load_dotenv()

BSKY_USERNAME = os.getenv('BSKY_USERNAME')
BSKY_PASSWORD = os.getenv('BSKY_PASSWORD')

# Create a client -- reuse this across your code rather than instantiating a new one each time
# If you run this frequently, you will be rate limited
client = BskyApiClient(username = BSKY_USERNAME, password = BSKY_PASSWORD)

# Scrape all posts for the search term "rstats"
st_scraper = SearchTermScraper(client)
rstats_posts = st_scraper.fetch_all_posts("rstats", limit=200)

# Scrape user: follows, followers, profiles
pf_scraper = ProfileScraper(client)
profiles = pf_scraper.fetch_all_profiles(["stoltzmaniac.bsky.social", "bsky.app"])
profile_follows = pf_scraper.fetch_all_follows("stoltzmaniac.bsky.social", limit=200)
profile_followers = pf_scraper.fetch_all_followers("stoltzmaniac.bsky.social", limit=200)

# Add output files -- you can specify different file names within each method if you prefer not to use the defaults
json_writer = JsonFileWriter()
scraper = SearchTermScraper(client, writer=json_writer)
data = scraper.fetch_all_posts("rstats", limit=200)

pf_scraper = ProfileScraper(client, writer=json_writer)
profiles = pf_scraper.fetch_all_profiles(["stoltzmaniac.bsky.social",  "bsky.app"])
profile_follows = pf_scraper.fetch_all_follows("stoltzmaniac.bsky.social", limit=200)
profile_followers = pf_scraper.fetch_all_followers("stoltzmaniac.bsky.social", limit=200)

# Making a post
agent = BskyAgent(client)
agent.new_post()\
    .add_text("Python API (sorry for multiple)--text--")\
    .add_link("Bluesky", "https://bsky.app")\
    .add_image("https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Cute_dog.jpg/1600px-Cute_dog.jpg", "dog")\
    .add_image("cat.png", "cat")\
    .add_mention("@stoltzmaniac.bsky.social", 'did:plc:6p3e4iybr5ipik3c6tx3jpto')\
    .send_post()

# If you don't know the "did" ... which most people don't, it will look it up for you

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

bskydata-0.3.2.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bskydata-0.3.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file bskydata-0.3.2.tar.gz.

File metadata

  • Download URL: bskydata-0.3.2.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/23.5.0

File hashes

Hashes for bskydata-0.3.2.tar.gz
Algorithm Hash digest
SHA256 2154caa3e684d4f8a1bb18334cb35119983e75d0930a1fca58a32f5929e901c2
MD5 6939dfe90541c8265bd0063cae9b3f5f
BLAKE2b-256 36fb3b398470b96777c61b77883094b4c648a8d67868255957a98fb4475c24cd

See more details on using hashes here.

File details

Details for the file bskydata-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: bskydata-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/23.5.0

File hashes

Hashes for bskydata-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 03607e7cedb68ca60b3f6926b00ac1ffcd3b2cd519dabd9d5fdf3c0b25ef5aac
MD5 9008a80399b6c5841d569859e9eef203
BLAKE2b-256 1177b1824641d75bd378ab00895dc10e9dc0a06344c198bdd219c81f24a08b14

See more details on using hashes here.

Supported by

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