Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional Features #9

Open
ImFaisalKhalid opened this issue Apr 19, 2023 · 6 comments
Open

Additional Features #9

ImFaisalKhalid opened this issue Apr 19, 2023 · 6 comments

Comments

@ImFaisalKhalid
Copy link
Contributor

ImFaisalKhalid commented Apr 19, 2023

Hey Ian,

You asked me to file an issue asking for TODOs - do you have anything in mind?

@MostWrong
Copy link
Contributor

@ianklatzco

@ianklatzco
Copy link
Owner

i've added some more issues ^^

i think it would be cool if this were a full-featured client!

@ianklatzco
Copy link
Owner

what precisely does that mean?

  • every endpoint has a corresponding python function (it might be possible to codegen this from the official bsky typescript)/
    • naively could grep out all the function names and then turn each of those into python
  • i think we could stand to think about the ergonomics of the python. right now, things are a tiny bit clunky because you get the response object back, which is ever so slightly unpoggers.
# for example,
    def resolveHandle(self,username): # aka getDid
        headers = {"Authorization": "Bearer " + self.ATP_AUTH_TOKEN}
        resp = requests.get(
            self.ATP_HOST + "/xrpc/com.atproto.identity.resolveHandle?handle={}".format(username),
            headers=headers
        )
        return resp

A cleaner API would look like something like:

class BskyResponse():
    # blah blah blah
    def __init__():
        self.response = None

def resolveHandle(self, username0:
    headers = #blahblahblah
    resp = requests.get(blahblahbla)
    rrrr = BskyResponse()
    rrrr.response = resp

It would also be cool if there were a decorator in front of each def that made it so we didn't need to put headers in every function manually.

@ShreyanJain9
Copy link
Contributor

ShreyanJain9 commented May 1, 2023

I don't know if this fits what you're thinking, but @thearchduke was able to write a codegen script from the Lexicons in the ATProto repository to generate Ruby classes for each Lexicon. Something similar could probably work in Python

https://github.com/ShreyanJain9/bskyrb/blob/main/lib/bskyrb/codegen.rb

@thearchduke
Copy link

@ianklatzco
Copy link
Owner

yeah! psychonaut's approach is super cool (codegen). i think it would be super cool / instructive / good learning to do that here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants